Flutter Engine
The Flutter Engine
dart_message_handler.h
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#ifndef LIB_TONIC_DART_MESSAGE_HANDLER_H_
6#define LIB_TONIC_DART_MESSAGE_HANDLER_H_
7
8#include <functional>
9
10#include "third_party/dart/runtime/include/dart_api.h"
12
13namespace tonic {
14class DartState;
15
17 public:
18 using TaskDispatcher = std::function<void(std::function<void(void)>)>;
19
21
23
24 // Messages for the current isolate will be scheduled on |runner|.
25 void Initialize(TaskDispatcher dispatcher);
26
27 // Handle an unhandled error. If the error is fatal then shut down the
28 // isolate. The message handler's isolate must be the current isolate.
30
31 // Did the isolate exit?
32 bool isolate_exited() const { return isolate_exited_; }
33
34 // Did the isolate have an uncaught exception error?
37 }
38
40
41 protected:
42 // Called from an unknown thread for each message.
43 void OnMessage(DartState* dart_state);
44 // By default, called on the task runner's thread for each message.
45 void OnHandleMessage(DartState* dart_state);
46
48
51 }
52
59
60 private:
61 static void MessageNotifyCallback(Dart_Isolate dest_isolate);
62};
63
64} // namespace tonic
65
66#endif // LIB_TONIC_DART_MESSAGE_HANDLER_H_
void OnHandleMessage(DartState *dart_state)
void UnhandledError(Dart_Handle error)
std::function< void(std::function< void(void)>)> TaskDispatcher
void OnMessage(DartState *dart_state)
bool isolate_had_uncaught_exception_error() const
DartErrorHandleType isolate_last_error_
void Initialize(TaskDispatcher dispatcher)
void set_handled_first_message(bool handled_first_message)
DartErrorHandleType isolate_last_error() const
struct _Dart_Handle * Dart_Handle
Definition: dart_api.h:258
struct _Dart_Isolate * Dart_Isolate
Definition: dart_api.h:88
const uint8_t uint32_t uint32_t GError ** error
Dart_NativeFunction function
Definition: fuchsia.cc:51
DartErrorHandleType
Definition: dart_error.h:67