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 17 of file dart_runner.h.

Constructor & Destructor Documentation

◆ DartRunner()

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

Definition at line 162 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.

162  : context_(context) {
163  context_->outgoing()->AddPublicService<fuchsia::sys::Runner>(
164  [this](fidl::InterfaceRequest<fuchsia::sys::Runner> request) {
165  bindings_.AddBinding(this, std::move(request));
166  });
167 
168  context_->outgoing()
169  ->AddPublicService<fuchsia::component::runner::ComponentRunner>(
170  [this](fidl::InterfaceRequest<
171  fuchsia::component::runner::ComponentRunner> request) {
172  component_runner_bindings_.AddBinding(this, std::move(request));
173  });
174 
175 #if !defined(DART_PRODUCT)
176  // The VM service isolate uses the process-wide namespace. It writes the
177  // vm service protocol port under /tmp. The VMServiceObject exposes that
178  // port number to The Hub.
179  context_->outgoing()->debug_dir()->AddEntry(
181  std::make_unique<dart_utils::VMServiceObject>());
182 
183 #endif // !defined(DART_PRODUCT)
184 
185  dart::bin::BootstrapDartIo();
186 
187  char* error =
188  Dart_SetVMFlags(dart_utils::ArraySize(kDartVMArgs), kDartVMArgs);
189  if (error) {
190  FX_LOGF(FATAL, LOG_TAG, "Dart_SetVMFlags failed: %s", error);
191  }
192 
193  Dart_InitializeParams params = {};
194  params.version = DART_INITIALIZE_PARAMS_CURRENT_VERSION;
195 #if defined(AOT_RUNTIME)
196  params.vm_snapshot_data = ::_kDartVmSnapshotData;
197  params.vm_snapshot_instructions = ::_kDartVmSnapshotInstructions;
198 #else
200  nullptr, "/pkg/data/vm_snapshot_data.bin", vm_snapshot_data_)) {
201  FX_LOG(FATAL, LOG_TAG, "Failed to load vm snapshot data");
202  }
204  nullptr, "/pkg/data/vm_snapshot_instructions.bin",
205  vm_snapshot_instructions_, true /* executable */)) {
206  FX_LOG(FATAL, LOG_TAG, "Failed to load vm snapshot instructions");
207  }
208  params.vm_snapshot_data = vm_snapshot_data_.address();
209  params.vm_snapshot_instructions = vm_snapshot_instructions_.address();
210 #endif
211  params.create_group = IsolateGroupCreateCallback;
212  params.shutdown_isolate = IsolateShutdownCallback;
213  params.cleanup_group = IsolateGroupCleanupCallback;
214  params.entropy_source = EntropySource;
215 #if !defined(DART_PRODUCT)
216  params.get_service_assets = GetVMServiceAssetsArchiveCallback;
217 #endif
218  error = Dart_Initialize(&params);
219  if (error)
220  FX_LOGF(FATAL, LOG_TAG, "Dart_Initialize failed: %s", error);
221 }
size_t ArraySize(T(&array)[SIZE])
Definition: inlines.h:26
const uint8_t uint32_t uint32_t 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 223 of file dart_runner.cc.

References LOG_TAG, and TRACE_EVENT1.

223  {
224  char* error = Dart_Cleanup();
225  if (error)
226  FX_LOGF(FATAL, LOG_TAG, "Dart_Cleanup failed: %s", error);
227 }
const uint8_t uint32_t uint32_t GError ** error
#define LOG_TAG
Definition: logging.h:11

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