Flutter Engine
flutter::DartVMData Class Reference

Provides thread-safe access to data that is necessary to bootstrap a new Dart VM instance. All snapshots referenced by this object are read-only. More...

#include <dart_vm_data.h>

Public Member Functions

 ~DartVMData ()
 Collect the DartVMData instance. More...
 
const SettingsGetSettings () const
 The settings object from which the Dart snapshots were inferred. More...
 
const DartSnapshotGetVMSnapshot () const
 Gets the VM snapshot. This can be in the call to bootstrap the Dart VM via Dart_Initialize. More...
 
fml::RefPtr< const DartSnapshotGetIsolateSnapshot () const
 Get the isolate snapshot necessary to launch isolates in the Dart VM. The Dart VM instance in which these isolates are launched must be the same as the VM created using snapshot accessed via GetVMSnapshot. More...
 

Static Public Member Functions

static std::shared_ptr< const DartVMDataCreate (Settings settings, fml::RefPtr< DartSnapshot > vm_snapshot, fml::RefPtr< DartSnapshot > isolate_snapshot)
 Creates a new instance of DartVMData. Both the VM and isolate snapshot members are optional and may be nullptr. If nullptr, the snapshot resolvers present in the settings object are used to infer the snapshots. If the snapshots cannot be inferred from the settings object, this method return nullptr. More...
 

Detailed Description

Provides thread-safe access to data that is necessary to bootstrap a new Dart VM instance. All snapshots referenced by this object are read-only.

Definition at line 18 of file dart_vm_data.h.

Constructor & Destructor Documentation

◆ ~DartVMData()

flutter::DartVMData::~DartVMData ( )
default

Collect the DartVMData instance.

Referenced by Create().

Member Function Documentation

◆ Create()

std::shared_ptr< const DartVMData > flutter::DartVMData::Create ( Settings  settings,
fml::RefPtr< DartSnapshot vm_snapshot,
fml::RefPtr< DartSnapshot isolate_snapshot 
)
static

Creates a new instance of DartVMData. Both the VM and isolate snapshot members are optional and may be nullptr. If nullptr, the snapshot resolvers present in the settings object are used to infer the snapshots. If the snapshots cannot be inferred from the settings object, this method return nullptr.

Parameters
[in]settingsThe settings used to infer the VM and isolate snapshots if they are not provided directly.
[in]vm_snapshotThe VM snapshot or nullptr.
[in]isolate_snapshotThe isolate snapshot or nullptr.
Returns
A new instance of VM data that can be used to bootstrap a Dart VM. nullptr if the snapshots are not provided and cannot be inferred from the settings object.

Definition at line 9 of file dart_vm_data.cc.

References FML_LOG, flutter::DartSnapshot::IsolateSnapshotFromSettings(), flutter::DartSnapshot::VMSnapshotFromSettings(), and ~DartVMData().

12  {
13  if (!vm_snapshot || !vm_snapshot->IsValid()) {
14  // Caller did not provide a valid VM snapshot. Attempt to infer one
15  // from the settings.
16  vm_snapshot = DartSnapshot::VMSnapshotFromSettings(settings);
17  if (!vm_snapshot) {
18  FML_LOG(ERROR)
19  << "VM snapshot invalid and could not be inferred from settings.";
20  return {};
21  }
22  }
23 
24  if (!isolate_snapshot || !isolate_snapshot->IsValid()) {
25  // Caller did not provide a valid isolate snapshot. Attempt to infer one
26  // from the settings.
27  isolate_snapshot = DartSnapshot::IsolateSnapshotFromSettings(settings);
28  if (!isolate_snapshot) {
29  FML_LOG(ERROR) << "Isolate snapshot invalid and could not be inferred "
30  "from settings.";
31  return {};
32  }
33  }
34 
35  return std::shared_ptr<const DartVMData>(new DartVMData(
36  std::move(settings), //
37  std::move(vm_snapshot), //
38  std::move(isolate_snapshot) //
39  ));
40 }
static fml::RefPtr< DartSnapshot > IsolateSnapshotFromSettings(const Settings &settings)
From the fields present in the given settings object, infer the isolate snapshot. ...
#define FML_LOG(severity)
Definition: logging.h:65
static fml::RefPtr< DartSnapshot > VMSnapshotFromSettings(const Settings &settings)
From the fields present in the given settings object, infer the core snapshot.

◆ GetIsolateSnapshot()

fml::RefPtr< const DartSnapshot > flutter::DartVMData::GetIsolateSnapshot ( ) const

Get the isolate snapshot necessary to launch isolates in the Dart VM. The Dart VM instance in which these isolates are launched must be the same as the VM created using snapshot accessed via GetVMSnapshot.

Returns
The isolate snapshot.

Definition at line 59 of file dart_vm_data.cc.

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

59  {
60  return isolate_snapshot_;
61 }

◆ GetSettings()

const Settings & flutter::DartVMData::GetSettings ( ) const

The settings object from which the Dart snapshots were inferred.

Returns
The settings.

Definition at line 51 of file dart_vm_data.cc.

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

51  {
52  return settings_;
53 }

◆ GetVMSnapshot()

const DartSnapshot & flutter::DartVMData::GetVMSnapshot ( ) const

Gets the VM snapshot. This can be in the call to bootstrap the Dart VM via Dart_Initialize.

Returns
The VM snapshot.

Definition at line 55 of file dart_vm_data.cc.

55  {
56  return *vm_snapshot_;
57 }

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