Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | List of all members
dart_runner::DartRunner Class Reference

#include <dart_runner.h>

Inheritance diagram for dart_runner::DartRunner:

Public Member Functions

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

Private Member Functions

void Start (fuchsia::component::runner::ComponentStartInfo start_info, fidl::InterfaceRequest< fuchsia::component::runner::ComponentController > controller) 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 189 of file dart_runner.cc.

189 : context_(context) {
190 context_->outgoing()
191 ->AddPublicService<fuchsia::component::runner::ComponentRunner>(
192 [this](fidl::InterfaceRequest<
193 fuchsia::component::runner::ComponentRunner> request) {
194 component_runner_bindings_.AddBinding(this, std::move(request));
195 });
196
197#if !defined(DART_PRODUCT)
198 // The VM service isolate uses the process-wide namespace. It writes the
199 // vm service protocol port under /tmp. The VMServiceObject exposes that
200 // port number to The Hub.
201 context_->outgoing()->debug_dir()->AddEntry(
203 std::make_unique<dart_utils::VMServiceObject>());
204
205#endif // !defined(DART_PRODUCT)
206
208
209 char* error =
210 Dart_SetVMFlags(dart_utils::ArraySize(kDartVMArgs), kDartVMArgs);
211 if (error) {
212 FML_LOG(FATAL) << "Dart_SetVMFlags failed: " << error;
213 }
214
217#if defined(AOT_RUNTIME)
218 params.vm_snapshot_data = ::_kDartVmSnapshotData;
219 params.vm_snapshot_instructions = ::_kDartVmSnapshotInstructions;
220#else
222 nullptr, "/pkg/data/vm_snapshot_data.bin", vm_snapshot_data_)) {
223 FML_LOG(FATAL) << "Failed to load vm snapshot data";
224 }
225 params.vm_snapshot_data = vm_snapshot_data_.address();
226#endif
227 params.create_group = IsolateGroupCreateCallback;
228 params.shutdown_isolate = IsolateShutdownCallback;
229 params.cleanup_group = IsolateGroupCleanupCallback;
230 params.entropy_source = EntropySource;
231#if !defined(DART_PRODUCT)
232 params.get_service_assets = GetVMServiceAssetsArchiveCallback;
233#endif
235 if (error)
236 FML_LOG(FATAL) << "Dart_Initialize failed: " << error;
237}
static bool LoadFromNamespace(fdio_ns_t *namespc, const std::string &path, MappedResource &resource, bool executable=false)
const uint8_t * address() const
static constexpr const char * kPortDirName
#define DART_INITIALIZE_PARAMS_CURRENT_VERSION
Definition dart_api.h:839
DART_EXPORT DART_WARN_UNUSED_RESULT char * Dart_Initialize(Dart_InitializeParams *params)
DART_EXPORT DART_WARN_UNUSED_RESULT char * Dart_SetVMFlags(int argc, const char **argv)
const EmbeddedViewParams * params
#define FATAL(error)
const uint8_t uint32_t uint32_t GError ** error
#define FML_LOG(severity)
Definition logging.h:82
void BootstrapDartIo()
Dart_Handle GetVMServiceAssetsArchiveCallback()
size_t ArraySize(T(&array)[SIZE])
Definition inlines.h:11

◆ ~DartRunner()

dart_runner::DartRunner::~DartRunner ( )
override

Definition at line 239 of file dart_runner.cc.

239 {
240 char* error = Dart_Cleanup();
241 if (error)
242 FML_LOG(FATAL) << "Dart_Cleanup failed: " << error;
243}
DART_EXPORT DART_WARN_UNUSED_RESULT char * Dart_Cleanup(void)

Member Function Documentation

◆ Start()

void dart_runner::DartRunner::Start ( fuchsia::component::runner::ComponentStartInfo  start_info,
fidl::InterfaceRequest< fuchsia::component::runner::ComponentController >  controller 
)
overrideprivate

Definition at line 245 of file dart_runner.cc.

248 {
249 // Parse the program field of the component's cml and check if it is a test
250 // component. If so, serve the |fuchsia.test.Suite| protocol from the
251 // component's outgoing directory, via DartTestComponentController.
252 if (IsTestProgram(start_info.program())) {
253 std::string url_copy = start_info.resolved_url();
254 TRACE_EVENT1("dart", "Start", "url", url_copy.c_str());
255 std::thread thread(
256 RunTestApplication, this, std::move(start_info), context_->svc(),
257 std::move(controller),
258 // component_created_callback
259 [this](std::shared_ptr<DartTestComponentController> ptr) {
260 test_components_.emplace(ptr.get(), std::move(ptr));
261 },
262 // done_callback
263 [this](DartTestComponentController* ptr) {
264 auto it = test_components_.find(ptr);
265 if (it != test_components_.end()) {
266 test_components_.erase(it);
267 }
268 });
269 thread.detach();
270 } else {
271 std::string url_copy = start_info.resolved_url();
272 TRACE_EVENT1("dart", "Start", "url", url_copy.c_str());
273 std::thread thread(RunApplication, this, std::move(start_info),
274 context_->svc(), std::move(controller));
275 thread.detach();
276 }
277}
bool IsTestProgram(const fuchsia::data::Dictionary &program_metadata)
#define TRACE_EVENT1(category_group, name, arg1_name, arg1_val)

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