Flutter Engine
tonic::DartState Class Reference

#include <dart_state.h>

Inheritance diagram for tonic::DartState:
flutter::UIDartState flutter::DartIsolate

Classes

class  Scope
 

Public Member Functions

 DartState (int dirfd=-1, std::function< void(Dart_Handle)> message_epilogue=nullptr)
 
virtual ~DartState ()
 
std::weak_ptr< DartStateGetWeakPtr ()
 
Dart_Isolate isolate ()
 
void SetIsolate (Dart_Isolate isolate)
 
Dart_PersistentHandle private_constructor_name ()
 
DartClassLibraryclass_library ()
 
DartMessageHandlermessage_handler ()
 
FileLoaderfile_loader ()
 
void MessageEpilogue (Dart_Handle message_result)
 
void SetReturnCode (uint32_t return_code)
 
void SetReturnCodeCallback (std::function< void(uint32_t)> callback)
 
bool has_set_return_code () const
 
void SetIsShuttingDown ()
 
bool IsShuttingDown ()
 
virtual void DidSetIsolate ()
 

Static Public Member Functions

static DartStateFrom (Dart_Isolate isolate)
 
static DartStateCurrent ()
 
static Dart_Handle HandleLibraryTag (Dart_LibraryTag tag, Dart_Handle library, Dart_Handle url)
 

Protected Member Functions

Dart_Isolate isolate () const
 
 TONIC_DISALLOW_COPY_AND_ASSIGN (DartState)
 

Detailed Description

Definition at line 28 of file dart_state.h.

Constructor & Destructor Documentation

◆ DartState()

tonic::DartState::DartState ( int  dirfd = -1,
std::function< void(Dart_Handle)>  message_epilogue = nullptr 
)
explicit

Definition at line 22 of file dart_state.cc.

24  : isolate_(nullptr),
25  private_constructor_name_(),
26  class_library_(new DartClassLibrary),
27  message_handler_(new DartMessageHandler()),
28  file_loader_(new FileLoader(dirfd)),
29  message_epilogue_(message_epilogue),
30  has_set_return_code_(false),
31  is_shutting_down_(false) {}

◆ ~DartState()

tonic::DartState::~DartState ( )
virtual

Definition at line 33 of file dart_state.cc.

33 {}

Member Function Documentation

◆ class_library()

DartClassLibrary& tonic::DartState::class_library ( )
inline

◆ Current()

◆ DidSetIsolate()

void tonic::DartState::DidSetIsolate ( )
virtual

Definition at line 77 of file dart_state.cc.

Referenced by IsShuttingDown(), and SetIsolate().

77 {}

◆ file_loader()

FileLoader& tonic::DartState::file_loader ( )
inline

Definition at line 62 of file dart_state.h.

Referenced by HandleLibraryTag().

62 { return *file_loader_; }

◆ From()

DartState * tonic::DartState::From ( Dart_Isolate  isolate)
static

Definition at line 50 of file dart_state.cc.

Referenced by tonic::DartMessageHandler::OnHandleMessage().

50  {
51  auto isolate_data =
52  static_cast<std::shared_ptr<DartState>*>(Dart_IsolateData(isolate));
53  return isolate_data->get();
54 }
Dart_Isolate isolate()
Definition: dart_state.h:51

◆ GetWeakPtr()

std::weak_ptr< DartState > tonic::DartState::GetWeakPtr ( )

Definition at line 62 of file dart_state.cc.

Referenced by tonic::DartMessageHandler::OnMessage(), tonic::DartWeakPersistentValue::Set(), and tonic::DartPersistentValue::Set().

62  {
63  return shared_from_this();
64 }

◆ HandleLibraryTag()

Dart_Handle tonic::DartState::HandleLibraryTag ( Dart_LibraryTag  tag,
Dart_Handle  library,
Dart_Handle  url 
)
static

Definition at line 79 of file dart_state.cc.

References Current(), file_loader(), and tonic::FileLoader::HandleLibraryTag().

Referenced by flutter::DartIsolate::GetServiceId(), IsShuttingDown(), and flutter::DartIsolate::Shutdown().

81  {
82  return Current()->file_loader().HandleLibraryTag(tag, library, url);
83 }
static DartState * Current()
Definition: dart_state.cc:56
Dart_Handle HandleLibraryTag(Dart_LibraryTag tag, Dart_Handle library, Dart_Handle url)
Definition: file_loader.cc:118
FileLoader & file_loader()
Definition: dart_state.h:62

◆ has_set_return_code()

bool tonic::DartState::has_set_return_code ( ) const
inline

Definition at line 71 of file dart_state.h.

Referenced by tonic::DartMessageHandler::OnHandleMessage().

71 { return has_set_return_code_; }

◆ isolate() [1/2]

◆ isolate() [2/2]

Dart_Isolate tonic::DartState::isolate ( ) const
inlineprotected

Definition at line 83 of file dart_state.h.

References TONIC_DISALLOW_COPY_AND_ASSIGN().

83 { return isolate_; }

◆ IsShuttingDown()

bool tonic::DartState::IsShuttingDown ( )
inline

Definition at line 74 of file dart_state.h.

References DidSetIsolate(), and HandleLibraryTag().

Referenced by flutter::testing::TEST_F().

74 { return is_shutting_down_; }

◆ message_handler()

DartMessageHandler& tonic::DartState::message_handler ( )
inline

Definition at line 61 of file dart_state.h.

Referenced by flutter::UIDartState::GetLastError(), flutter::DartIsolate::LoadLoadingUnitError(), and tonic::DartMessageHandler::OnMessage().

61 { return *message_handler_; }

◆ MessageEpilogue()

void tonic::DartState::MessageEpilogue ( Dart_Handle  message_result)
inline

Definition at line 64 of file dart_state.h.

References callback, function, SetReturnCode(), and SetReturnCodeCallback().

Referenced by tonic::DartMessageHandler::OnHandleMessage().

64  {
65  if (message_epilogue_) {
66  message_epilogue_(message_result);
67  }
68  }

◆ private_constructor_name()

Dart_PersistentHandle tonic::DartState::private_constructor_name ( )
inline

Definition at line 56 of file dart_state.h.

Referenced by tonic::DartWrappable::CreateDartWrapper().

56  {
57  return private_constructor_name_.Get();
58  }

◆ SetIsolate()

void tonic::DartState::SetIsolate ( Dart_Isolate  isolate)

Definition at line 35 of file dart_state.cc.

References tonic::DartPersistentValue::Clear(), DidSetIsolate(), isolate(), and tonic::DartPersistentValue::Set().

Referenced by flutter::DartIsolate::GetServiceId(), and isolate().

35  {
36  isolate_ = isolate;
37 
38  if (!isolate_)
39  return;
40 
41  private_constructor_name_.Clear();
42  Dart_EnterScope();
43  private_constructor_name_.Set(
44  this, Dart_NewPersistentHandle(Dart_NewStringFromCString("_")));
45  Dart_ExitScope();
46 
47  DidSetIsolate();
48 }
Dart_Isolate isolate()
Definition: dart_state.h:51
void Set(DartState *dart_state, Dart_Handle value)
virtual void DidSetIsolate()
Definition: dart_state.cc:77

◆ SetIsShuttingDown()

void tonic::DartState::SetIsShuttingDown ( )
inline

Definition at line 73 of file dart_state.h.

Referenced by flutter::DartIsolate::AddIsolateShutdownCallback().

73 { is_shutting_down_ = true; }

◆ SetReturnCode()

void tonic::DartState::SetReturnCode ( uint32_t  return_code)

Definition at line 66 of file dart_state.cc.

Referenced by MessageEpilogue().

66  {
67  if (set_return_code_callback_) {
68  set_return_code_callback_(return_code);
69  }
70  has_set_return_code_ = true;
71 }

◆ SetReturnCodeCallback()

void tonic::DartState::SetReturnCodeCallback ( std::function< void(uint32_t)>  callback)

Definition at line 73 of file dart_state.cc.

References callback.

Referenced by MessageEpilogue().

73  {
74  set_return_code_callback_ = callback;
75 }
FlKeyEvent FlKeyResponderAsyncCallback callback

◆ TONIC_DISALLOW_COPY_AND_ASSIGN()

tonic::DartState::TONIC_DISALLOW_COPY_AND_ASSIGN ( DartState  )
protected

Referenced by isolate().


The documentation for this class was generated from the following files: