Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
native_message_handler.cc
Go to the documentation of this file.
1// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
6
7#include <memory>
8
10#include "vm/isolate.h"
11#include "vm/message.h"
12#include "vm/message_snapshot.h"
13#include "vm/snapshot.h"
14
15namespace dart {
16
19 : name_(Utils::StrDup(name)), func_(func) {}
20
24
25#if defined(DEBUG)
26void NativeMessageHandler::CheckAccess() const {
27 ASSERT(Isolate::Current() == nullptr);
28}
29#endif
30
32 std::unique_ptr<Message> message) {
33 if (message->IsOOB()) {
34 // We currently do not use OOB messages for native ports.
36 }
37 // We create a native scope for handling the message.
38 // All allocation of objects for decoding the message is done in the
39 // zone associated with this scope.
40 ApiNativeScope scope;
41 Dart_CObject* object = ReadApiMessage(scope.zone(), message.get());
42 (*func())(message->dest_port(), object);
43 return kOK;
44}
45
46} // namespace dart
#define UNREACHABLE()
Definition assert.h:248
static Isolate * Current()
Definition isolate.h:939
NativeMessageHandler(const char *name, Dart_NativeMessageHandler func)
Dart_NativeMessageHandler func() const
MessageStatus HandleMessage(std::unique_ptr< Message > message)
void(* Dart_NativeMessageHandler)(Dart_Port dest_port_id, Dart_CObject *message)
#define ASSERT(E)
Win32Message message
const char *const name
Dart_CObject * ReadApiMessage(Zone *zone, Message *message)