[fuchsia] create component context in main (flutter/engine#25290)

This commit is contained in:
Chase Latta
2021-04-13 13:42:17 -07:00
committed by GitHub
parent a949b99621
commit 3c5b4c6ef0
4 changed files with 31 additions and 2 deletions

View File

@@ -65,6 +65,7 @@ template("runner") {
"$fuchsia_sdk_root/pkg:async-loop-cpp",
"$fuchsia_sdk_root/pkg:async-loop-default",
"$fuchsia_sdk_root/pkg:fidl_cpp",
"$fuchsia_sdk_root/pkg:sys_inspect_cpp",
"$fuchsia_sdk_root/pkg:sys_cpp",
"$fuchsia_sdk_root/pkg:syslog",
"$fuchsia_sdk_root/pkg:trace",

View File

@@ -4,6 +4,7 @@
#include <lib/async-loop/cpp/loop.h>
#include <lib/async-loop/default.h>
#include <lib/sys/inspect/cpp/component.h>
#include <lib/syslog/global.h>
#include <lib/trace-provider/provider.h>
#include <lib/trace/event.h>
@@ -34,6 +35,14 @@ static void RegisterProfilerSymbols(const char* symbols_path,
int main(int argc, const char** argv) {
async::Loop loop(&kAsyncLoopConfigAttachToCurrentThread);
// Create our component context which is served later.
auto context = sys::ComponentContext::Create();
sys::ComponentInspector inspector(context.get());
inspect::Node& root = inspector.inspector()->GetRoot();
dart::SetDartVmNode(std::make_unique<inspect::Node>(root.CreateChild("vm")));
std::unique_ptr<trace::TraceProviderWithFdio> provider;
{
bool already_started;
@@ -51,7 +60,11 @@ int main(int argc, const char** argv) {
#endif // !defined(DART_PRODUCT)
dart_utils::RunnerTemp runner_temp;
dart_runner::DartRunner runner(dart::ComponentContext());
dart_runner::DartRunner runner(context.get());
// Wait to serve until we have finished all of our setup.
context->outgoing()->ServeFromStartupInfo();
loop.Run();
return 0;
}

View File

@@ -124,6 +124,7 @@ template("runner_sources") {
public_deps = [
"$fuchsia_sdk_root/pkg:scenic_cpp",
"$fuchsia_sdk_root/pkg:sys_cpp",
"$fuchsia_sdk_root/pkg:sys_inspect_cpp",
"//flutter/shell/platform/fuchsia/runtime/dart/utils",
] + flutter_public_deps

View File

@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <lib/async-loop/cpp/loop.h>
#include <lib/sys/inspect/cpp/component.h>
#include <lib/trace-provider/provider.h>
#include <lib/trace/event.h>
@@ -16,6 +17,16 @@
int main(int argc, char const* argv[]) {
std::unique_ptr<async::Loop> loop(flutter_runner::MakeObservableLoop(true));
// Create our component context which is served later.
auto context = sys::ComponentContext::Create();
sys::ComponentInspector inspector(context.get());
inspect::Node& root = inspector.inspector()->GetRoot();
// We inject the 'vm' node into the dart vm so that it can add any inspect
// data that it needs to the inspect tree.
dart::SetDartVmNode(std::make_unique<inspect::Node>(root.CreateChild("vm")));
std::unique_ptr<trace::TraceProviderWithFdio> provider;
{
bool already_started;
@@ -29,7 +40,10 @@ int main(int argc, char const* argv[]) {
FML_DLOG(INFO) << "Flutter application services initialized.";
flutter_runner::Runner runner(loop.get(), dart::ComponentContext());
flutter_runner::Runner runner(loop.get(), context.get());
// Wait to serve until we have finished all of our setup.
context->outgoing()->ServeFromStartupInfo();
loop->Run();
FML_DLOG(INFO) << "Flutter application services terminated.";