Flutter Engine
tonic::DartPersistentValue Class Reference

#include <dart_persistent_value.h>

Public Member Functions

 DartPersistentValue ()
 
 DartPersistentValue (DartPersistentValue &&other)
 
 DartPersistentValue (DartState *dart_state, Dart_Handle value)
 
 ~DartPersistentValue ()
 
Dart_PersistentHandle value () const
 
bool is_empty () const
 
void Set (DartState *dart_state, Dart_Handle value)
 
void Clear ()
 
Dart_Handle Get ()
 
Dart_Handle Release ()
 
const std::weak_ptr< DartState > & dart_state () const
 

Detailed Description

Definition at line 20 of file dart_persistent_value.h.

Constructor & Destructor Documentation

◆ DartPersistentValue() [1/3]

tonic::DartPersistentValue::DartPersistentValue ( )

Definition at line 12 of file dart_persistent_value.cc.

12 : value_(nullptr) {}

◆ DartPersistentValue() [2/3]

tonic::DartPersistentValue::DartPersistentValue ( DartPersistentValue &&  other)

Definition at line 14 of file dart_persistent_value.cc.

15  : dart_state_(other.dart_state_), value_(other.value_) {
16  other.dart_state_.reset();
17  other.value_ = nullptr;
18 }

◆ DartPersistentValue() [3/3]

tonic::DartPersistentValue::DartPersistentValue ( DartState dart_state,
Dart_Handle  value 
)

Definition at line 20 of file dart_persistent_value.cc.

References Set().

22  : value_(nullptr) {
24 }
Dart_PersistentHandle value() const
void Set(DartState *dart_state, Dart_Handle value)
const std::weak_ptr< DartState > & dart_state() const

◆ ~DartPersistentValue()

tonic::DartPersistentValue::~DartPersistentValue ( )

Definition at line 26 of file dart_persistent_value.cc.

References Clear().

26  {
27  Clear();
28 }

Member Function Documentation

◆ Clear()

void tonic::DartPersistentValue::Clear ( )

Definition at line 36 of file dart_persistent_value.cc.

References dart_state().

Referenced by is_empty(), Release(), tonic::DartState::SetIsolate(), and ~DartPersistentValue().

36  {
37  if (!value_) {
38  return;
39  }
40 
41  auto dart_state = dart_state_.lock();
42  if (!dart_state) {
43  return;
44  }
45 
46  if (Dart_CurrentIsolateGroup()) {
47  Dart_DeletePersistentHandle(value_);
48  } else {
49  DartIsolateScope scope(dart_state->isolate());
50  Dart_DeletePersistentHandle(value_);
51  }
52  dart_state_.reset();
53  value_ = nullptr;
54 }
const std::weak_ptr< DartState > & dart_state() const

◆ dart_state()

◆ Get()

Dart_Handle tonic::DartPersistentValue::Get ( )

Definition at line 56 of file dart_persistent_value.cc.

Referenced by is_empty(), Release(), and zircon::dart::Handle::ScheduleCallback().

56  {
57  if (!value_)
58  return nullptr;
59  return Dart_HandleFromPersistent(value_);
60 }

◆ is_empty()

◆ Release()

Dart_Handle tonic::DartPersistentValue::Release ( )

Definition at line 62 of file dart_persistent_value.cc.

References Clear(), and Get().

Referenced by zircon::dart::HandleWaiter::Cancel(), is_empty(), and zircon::dart::Handle::ScheduleCallback().

62  {
63  Dart_Handle local = Get();
64  Clear();
65  return local;
66 }

◆ Set()

void tonic::DartPersistentValue::Set ( DartState dart_state,
Dart_Handle  value 
)

Definition at line 30 of file dart_persistent_value.cc.

References tonic::DartState::GetWeakPtr(), is_empty(), and TONIC_DCHECK.

Referenced by tonic::DartClassProvider::DartClassProvider(), DartPersistentValue(), flutter::PlatformConfiguration::DidCreateIsolate(), is_empty(), tonic::DartState::SetIsolate(), and flutter::Window::Window().

30  {
32  dart_state_ = dart_state->GetWeakPtr();
33  value_ = Dart_NewPersistentHandle(value);
34 }
#define TONIC_DCHECK
Definition: macros.h:32
Dart_PersistentHandle value() const
const std::weak_ptr< DartState > & dart_state() const

◆ value()


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