Flutter Engine
 
Loading...
Searching...
No Matches
platform_message_response_dart_port.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
7#include <array>
8#include <utility>
9
13#include "third_party/dart/runtime/include/dart_native_api.h"
18
19namespace flutter {
20
22 Dart_Port send_port,
23 int64_t identifier,
24 const std::string& channel)
25 : send_port_(send_port), identifier_(identifier), channel_(channel) {
26 FML_DCHECK(send_port != ILLEGAL_PORT);
27}
28
30 std::unique_ptr<fml::Mapping> data) {
31 is_complete_ = true;
32 Dart_CObject response_identifier = {
33 .type = Dart_CObject_kInt64,
34 };
35 response_identifier.value.as_int64 = identifier_;
36 Dart_CObject response_data = {
37 .type = Dart_CObject_kTypedData,
38 };
39 response_data.value.as_typed_data.type = Dart_TypedData_kUint8;
40 response_data.value.as_typed_data.length = data->GetSize();
41 response_data.value.as_typed_data.values = data->GetMapping();
42
43 std::array<Dart_CObject*, 2> response_values = {&response_identifier,
44 &response_data};
45
46 Dart_CObject response = {
47 .type = Dart_CObject_kArray,
48 };
49 response.value.as_array.length = response_values.size();
50 response.value.as_array.values = response_values.data();
51
52 bool did_send = Dart_PostCObject(send_port_, &response);
53 FML_CHECK(did_send);
54}
55
57 is_complete_ = true;
58 Dart_CObject response = {
59 .type = Dart_CObject_kNull,
60 };
61 bool did_send = Dart_PostCObject(send_port_, &response);
62 FML_CHECK(did_send);
63}
64
65} // namespace flutter
void Complete(std::unique_ptr< fml::Mapping > data) override
PlatformMessageResponseDartPort(Dart_Port send_port, int64_t identifier, const std::string &channel)
const gchar * channel
#define FML_CHECK(condition)
Definition logging.h:104
#define FML_DCHECK(condition)
Definition logging.h:122
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switch_defs.h:36