Flutter Engine
flutter_runner::Runner Class Referencefinal

#include <runner.h>

Inheritance diagram for flutter_runner::Runner:

Public Member Functions

 Runner (fml::RefPtr< fml::TaskRunner > task_runner, sys::ComponentContext *context)
 
 ~Runner ()
 

Detailed Description

Publishes the CF v1 and CF v2 runner services.

Each component will be run on a separate thread dedicated to that component.

TODO(fxb/50694): Add unit tests for CF v2.

Definition at line 33 of file runner.h.

Constructor & Destructor Documentation

◆ Runner()

flutter_runner::Runner::Runner ( fml::RefPtr< fml::TaskRunner task_runner,
sys::ComponentContext *  context 
)

Definition at line 152 of file runner.cc.

References dart_utils::VMServiceObject::GetContents(), dart_utils::RootInspectNode::GetInspector(), dart_utils::VMServiceObject::kPortDirName, name, flutter_runner::RegisterProfilerSymbols(), flutter_runner::SetProcessName(), and flutter_runner::SetThreadName().

154  : task_runner_(task_runner), context_(context) {
155 #if !defined(DART_PRODUCT)
156  // The VM service isolate uses the process-wide namespace. It writes the
157  // vm service protocol port under /tmp. The VMServiceObject exposes that
158  // port number to The Hub.
159  context_->outgoing()->debug_dir()->AddEntry(
161  std::make_unique<dart_utils::VMServiceObject>());
162 
163  inspect::Inspector* inspector = dart_utils::RootInspectNode::GetInspector();
164  inspector->GetRoot().CreateLazyValues(
165  "vmservice_port",
166  [&]() {
167  inspect::Inspector inspector;
168  dart_utils::VMServiceObject::LazyEntryVector out;
170  std::string name = "";
171  if (out.size() > 0) {
172  name = out[0].name;
173  }
174  inspector.GetRoot().CreateString("vm_service_port", name, &inspector);
175  return fpromise::make_ok_promise(inspector);
176  },
177  inspector);
178 
179  SetupTraceObserver();
180 #endif // !defined(DART_PRODUCT)
181 
182  SkGraphics::Init();
183 
184  SetupICU();
185 
186  SetProcessName();
187 
188  SetThreadName("io.flutter.runner.main");
189 
190  context_->outgoing()->AddPublicService<fuchsia::sys::Runner>(
191  std::bind(&Runner::RegisterComponentV1, this, std::placeholders::_1));
192  context_->outgoing()
193  ->AddPublicService<fuchsia::component::runner::ComponentRunner>(
194  std::bind(&Runner::RegisterComponentV2, this, std::placeholders::_1));
195 
196 #if !defined(DART_PRODUCT)
197  if (Dart_IsPrecompiledRuntime()) {
198  RegisterProfilerSymbols("pkg/data/flutter_aot_runner.dartprofilersymbols",
199  "");
200  } else {
201  RegisterProfilerSymbols("pkg/data/flutter_jit_runner.dartprofilersymbols",
202  "");
203  }
204 #endif // !defined(DART_PRODUCT)
205 }
static void SetThreadName(const std::string &thread_name)
Definition: runner.cc:134
static inspect::Inspector * GetInspector()
static void RegisterProfilerSymbols(const char *symbols_path, const char *dso_name)
Definition: runner.cc:141
const char * name
Definition: fuchsia.cc:50
void GetContents(LazyEntryVector *out_vector) const override
static constexpr const char * kPortDirName
static void SetProcessName()
Definition: runner.cc:118

◆ ~Runner()

flutter_runner::Runner::~Runner ( )

Definition at line 207 of file runner.cc.

References flutter_runner::ActiveComponentV1::component, flutter_runner::ActiveComponentV2::component, flutter_runner::ComponentV1::Create(), flutter_runner::ComponentV2::Create(), FML_LOG, fml::icu::InitializeICU(), key, fml::MakeCopyable(), flutter_runner::ActiveComponentV1::platform_thread, flutter_runner::ActiveComponentV2::platform_thread, fml::TaskRunner::RunNowOrPostTask(), fml::AutoResetWaitableEvent::Signal(), TRACE_EVENT1, and fml::AutoResetWaitableEvent::Wait().

207  {
208  context_->outgoing()->RemovePublicService<fuchsia::sys::Runner>();
209  context_->outgoing()
210  ->RemovePublicService<fuchsia::component::runner::ComponentRunner>();
211 
212 #if !defined(DART_PRODUCT)
213  trace_observer_->Stop();
214 #endif // !defined(DART_PRODUCT)
215 }

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