Flutter Engine
dart_runner::DartRunner Class Reference

#include <dart_runner.h>

Inheritance diagram for dart_runner::DartRunner:

Public Member Functions

 DartRunner (sys::ComponentContext *context)
 
 ~DartRunner () override
 

Detailed Description

Definition at line 16 of file dart_runner.h.

Constructor & Destructor Documentation

◆ DartRunner()

dart_runner::DartRunner::DartRunner ( sys::ComponentContext *  context)
explicit

Definition at line 124 of file dart_runner.cc.

References dart_utils::MappedResource::address(), dart_utils::ArraySize(), dart_runner::GetVMServiceAssetsArchiveCallback(), dart_utils::VMServiceObject::kPortDirName, dart_utils::MappedResource::LoadFromNamespace(), and LOG_TAG.

124  : context_(context) {
125  context_->outgoing()->AddPublicService<fuchsia::sys::Runner>(
126  [this](fidl::InterfaceRequest<fuchsia::sys::Runner> request) {
127  bindings_.AddBinding(this, std::move(request));
128  });
129 
130 #if !defined(DART_PRODUCT)
131  // The VM service isolate uses the process-wide namespace. It writes the
132  // vm service protocol port under /tmp. The VMServiceObject exposes that
133  // port number to The Hub.
134  context_->outgoing()->debug_dir()->AddEntry(
136  std::make_unique<dart_utils::VMServiceObject>());
137 
138 #endif // !defined(DART_PRODUCT)
139 
140  dart::bin::BootstrapDartIo();
141 
142  char* error =
143  Dart_SetVMFlags(dart_utils::ArraySize(kDartVMArgs), kDartVMArgs);
144  if (error) {
145  FX_LOGF(FATAL, LOG_TAG, "Dart_SetVMFlags failed: %s", error);
146  }
147 
148  Dart_InitializeParams params = {};
149  params.version = DART_INITIALIZE_PARAMS_CURRENT_VERSION;
150 #if defined(AOT_RUNTIME)
151  params.vm_snapshot_data = ::_kDartVmSnapshotData;
152  params.vm_snapshot_instructions = ::_kDartVmSnapshotInstructions;
153 #else
155  nullptr, "/pkg/data/vm_snapshot_data.bin", vm_snapshot_data_)) {
156  FX_LOG(FATAL, LOG_TAG, "Failed to load vm snapshot data");
157  }
159  nullptr, "/pkg/data/vm_snapshot_instructions.bin",
160  vm_snapshot_instructions_, true /* executable */)) {
161  FX_LOG(FATAL, LOG_TAG, "Failed to load vm snapshot instructions");
162  }
163  params.vm_snapshot_data = vm_snapshot_data_.address();
164  params.vm_snapshot_instructions = vm_snapshot_instructions_.address();
165 #endif
166  params.create_group = IsolateGroupCreateCallback;
167  params.shutdown_isolate = IsolateShutdownCallback;
168  params.cleanup_group = IsolateGroupCleanupCallback;
169  params.entropy_source = EntropySource;
170 #if !defined(DART_PRODUCT)
171  params.get_service_assets = GetVMServiceAssetsArchiveCallback;
172 #endif
173  error = Dart_Initialize(&params);
174  if (error)
175  FX_LOGF(FATAL, LOG_TAG, "Dart_Initialize failed: %s", error);
176 }
size_t ArraySize(T(&array)[SIZE])
Definition: inlines.h:26
FlMethodResponse GError ** error
Dart_Handle GetVMServiceAssetsArchiveCallback()
static bool LoadFromNamespace(fdio_ns_t *namespc, const std::string &path, MappedResource &resource, bool executable=false)
const uint8_t * address() const
#define LOG_TAG
Definition: logging.h:11
static constexpr const char * kPortDirName

◆ ~DartRunner()

dart_runner::DartRunner::~DartRunner ( )
override

Definition at line 178 of file dart_runner.cc.

References LOG_TAG, and TRACE_EVENT1.

178  {
179  char* error = Dart_Cleanup();
180  if (error)
181  FX_LOGF(FATAL, LOG_TAG, "Dart_Cleanup failed: %s", error);
182 }
FlMethodResponse GError ** error
#define LOG_TAG
Definition: logging.h:11

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