From 555f0b25063ed3faa3453905a97ca882e5d8dced Mon Sep 17 00:00:00 2001 From: Kaushik Iska Date: Wed, 18 Sep 2019 17:45:46 -0700 Subject: [PATCH] [flutter_runner] Move from runner context to component context (flutter/engine#12346) * [flutter_runner] Move from runner context to component context * remove the file references --- .../ci/licenses_golden/licenses_flutter | 2 - .../fuchsia/flutter/engine_flutter_runner.gni | 2 - .../shell/platform/fuchsia/flutter/runner.cc | 11 +-- .../shell/platform/fuchsia/flutter/runner.h | 3 +- .../fuchsia/flutter/runner_context.cc | 40 ----------- .../platform/fuchsia/flutter/runner_context.h | 70 ------------------- 6 files changed, 7 insertions(+), 121 deletions(-) delete mode 100644 engine/src/flutter/shell/platform/fuchsia/flutter/runner_context.cc delete mode 100644 engine/src/flutter/shell/platform/fuchsia/flutter/runner_context.h diff --git a/engine/src/flutter/ci/licenses_golden/licenses_flutter b/engine/src/flutter/ci/licenses_golden/licenses_flutter index 970783583d2..a7484675f12 100644 --- a/engine/src/flutter/ci/licenses_golden/licenses_flutter +++ b/engine/src/flutter/ci/licenses_golden/licenses_flutter @@ -955,8 +955,6 @@ FILE: ../../../flutter/shell/platform/fuchsia/flutter/platform_view.cc FILE: ../../../flutter/shell/platform/fuchsia/flutter/platform_view.h FILE: ../../../flutter/shell/platform/fuchsia/flutter/runner.cc FILE: ../../../flutter/shell/platform/fuchsia/flutter/runner.h -FILE: ../../../flutter/shell/platform/fuchsia/flutter/runner_context.cc -FILE: ../../../flutter/shell/platform/fuchsia/flutter/runner_context.h FILE: ../../../flutter/shell/platform/fuchsia/flutter/sample_unittests.cc FILE: ../../../flutter/shell/platform/fuchsia/flutter/session_connection.cc FILE: ../../../flutter/shell/platform/fuchsia/flutter/session_connection.h diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/engine_flutter_runner.gni b/engine/src/flutter/shell/platform/fuchsia/flutter/engine_flutter_runner.gni index 862db5ad770..1237e99d4be 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/engine_flutter_runner.gni +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/engine_flutter_runner.gni @@ -60,8 +60,6 @@ template("flutter_runner") { "platform_view.h", "runner.cc", "runner.h", - "runner_context.cc", - "runner_context.h", "session_connection.cc", "session_connection.h", "surface.cc", diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/runner.cc b/engine/src/flutter/shell/platform/fuchsia/flutter/runner.cc index 22c70d5a853..762eddfd4d6 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/runner.cc +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/runner.cc @@ -16,6 +16,7 @@ #include "flutter/fml/make_copyable.h" #include "flutter/lib/ui/text/font_collection.h" #include "flutter/runtime/dart_vm.h" +#include "lib/sys/cpp/component_context.h" #include "runtime/dart/utils/files.h" #include "runtime/dart/utils/vmo.h" #include "runtime/dart/utils/vmservice_object.h" @@ -102,12 +103,12 @@ static void RegisterProfilerSymbols(const char* symbols_path, #endif // !defined(DART_PRODUCT) Runner::Runner(async::Loop* loop) - : loop_(loop), runner_context_(RunnerContext::CreateFromStartupInfo()) { + : loop_(loop), context_(sys::ComponentContext::Create()) { #if !defined(DART_PRODUCT) // The VM service isolate uses the process-wide namespace. It writes the // vm service protocol port under /tmp. The VMServiceObject exposes that // port number to The Hub. - runner_context_->debug_dir()->AddEntry( + context_->outgoing()->debug_dir()->AddEntry( dart_utils::VMServiceObject::kPortDirName, std::make_unique()); @@ -122,7 +123,7 @@ Runner::Runner(async::Loop* loop) SetThreadName("io.flutter.runner.main"); - runner_context_->AddPublicService( + context_->outgoing()->AddPublicService( std::bind(&Runner::RegisterApplication, this, std::placeholders::_1)); #if !defined(DART_PRODUCT) @@ -137,7 +138,7 @@ Runner::Runner(async::Loop* loop) } Runner::~Runner() { - runner_context_->RemovePublicService(); + context_->outgoing()->RemovePublicService(); #if !defined(DART_PRODUCT) trace_observer_->Stop(); @@ -181,7 +182,7 @@ void Runner::StartComponent( std::move(termination_callback), // termination callback std::move(package), // application package std::move(startup_info), // startup info - runner_context_->svc(), // runner incoming services + context_->svc(), // runner incoming services std::move(controller) // controller request ); diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/runner.h b/engine/src/flutter/shell/platform/fuchsia/flutter/runner.h index bb5573e4422..047678c9ce3 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/runner.h +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/runner.h @@ -17,7 +17,6 @@ #include "component.h" #include "flutter/fml/macros.h" #include "lib/fidl/cpp/binding_set.h" -#include "runner_context.h" #include "runtime/dart/utils/vmservice_object.h" #include "thread.h" @@ -45,7 +44,7 @@ class Runner final : public fuchsia::sys::Runner { ActiveApplication() = default; }; - std::unique_ptr runner_context_; + std::unique_ptr context_; fidl::BindingSet active_applications_bindings_; std::unordered_map active_applications_; diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/runner_context.cc b/engine/src/flutter/shell/platform/fuchsia/flutter/runner_context.cc deleted file mode 100644 index ee36dbbd4ac..00000000000 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/runner_context.cc +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "runner_context.h" - -namespace flutter_runner { - -RunnerContext::RunnerContext(std::shared_ptr svc, - zx::channel directory_request) - : svc_(std::move(svc)), - root_dir_(std::make_shared()), - public_dir_(std::make_shared()), - debug_dir_(std::make_shared()), - ctrl_dir_(std::make_shared()) { - root_dir_->AddSharedEntry("svc", public_dir_); - root_dir_->AddSharedEntry("debug", debug_dir_); - root_dir_->AddSharedEntry("ctrl", ctrl_dir_); - - root_dir_->Serve( - fuchsia::io::OPEN_RIGHT_READABLE | fuchsia::io::OPEN_RIGHT_WRITABLE, - std::move(directory_request)); -} - -RunnerContext::~RunnerContext() = default; - -std::unique_ptr RunnerContext::CreateFromStartupInfo() { - zx_handle_t directory_request = zx_take_startup_handle(PA_DIRECTORY_REQUEST); - return std::make_unique( - sys::ServiceDirectory::CreateFromNamespace(), - zx::channel(directory_request)); -} - -zx_status_t RunnerContext::AddPublicService( - std::unique_ptr service, - std::string service_name) const { - return public_dir_->AddEntry(std::move(service_name), std::move(service)); -} - -} // namespace flutter_runner diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/runner_context.h b/engine/src/flutter/shell/platform/fuchsia/flutter/runner_context.h deleted file mode 100644 index 46a8f6ddb16..00000000000 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/runner_context.h +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef FLUTTER_SHELL_PLATFORM_FUCHSIA_RUNNER_CONTEXT_H_ -#define FLUTTER_SHELL_PLATFORM_FUCHSIA_RUNNER_CONTEXT_H_ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "flutter/fml/macros.h" - -namespace flutter_runner { - -class RunnerContext { - public: - RunnerContext(std::shared_ptr svc, - zx::channel directory_request); - ~RunnerContext(); - - static std::unique_ptr CreateFromStartupInfo(); - - const std::shared_ptr& svc() const { return svc_; } - const std::shared_ptr& root_dir() const { return root_dir_; } - const std::shared_ptr& public_dir() const { - return public_dir_; - } - const std::shared_ptr& debug_dir() const { - return debug_dir_; - } - const std::shared_ptr& ctrl_dir() const { return ctrl_dir_; } - - template - zx_status_t AddPublicService( - fidl::InterfaceRequestHandler handler, - std::string service_name = Interface::Name_) const { - return AddPublicService(std::make_unique(std::move(handler)), - std::move(service_name)); - } - - zx_status_t AddPublicService(std::unique_ptr service, - std::string service_name) const; - - template - zx_status_t RemovePublicService( - const std::string& name = Interface::Name_) const { - return public_dir_->RemoveEntry(name); - } - - private: - std::shared_ptr svc_; - std::shared_ptr root_dir_; - std::shared_ptr public_dir_; - std::shared_ptr debug_dir_; - std::shared_ptr ctrl_dir_; - - FML_DISALLOW_COPY_AND_ASSIGN(RunnerContext); -}; - -} // namespace flutter_runner - -#endif // FLUTTER_SHELL_PLATFORM_FUCHSIA_RUNNER_CONTEXT_H_