Flutter Engine
The 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
5#include "flutter/lib/ui/window/platform_message_response_dart_port.h"
6
7#include <array>
8#include <utility>
9
10#include "flutter/common/task_runners.h"
11#include "flutter/fml/make_copyable.h"
12#include "flutter/fml/trace_event.h"
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 = {
34 };
35 response_identifier.value.as_int64 = identifier_;
36 Dart_CObject response_data = {
38 };
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 = {
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 = {
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)
static SkString identifier(const FontFamilyDesc &family, const FontDesc &font)
#define ILLEGAL_PORT
Definition dart_api.h:1530
int64_t Dart_Port
Definition dart_api.h:1524
@ Dart_TypedData_kUint8
Definition dart_api.h:2606
@ Dart_CObject_kInt64
@ Dart_CObject_kTypedData
@ Dart_CObject_kArray
@ Dart_CObject_kNull
DART_EXPORT bool Dart_PostCObject(Dart_Port port_id, Dart_CObject *message)
#define FML_CHECK(condition)
Definition logging.h:85
#define FML_DCHECK(condition)
Definition logging.h:103
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 switches.h:41
union _Dart_CObject::@86 value
Dart_CObject_Type type
struct _Dart_CObject::@86::@90 as_typed_data
struct _Dart_CObject::@86::@89 as_array
struct _Dart_CObject ** values