[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
This commit is contained in:
Kaushik Iska 2019-09-18 17:45:46 -07:00 committed by GitHub
parent 4063939bd8
commit 555f0b2506
6 changed files with 7 additions and 121 deletions

View File

@ -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

View File

@ -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",

View File

@ -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<dart_utils::VMServiceObject>());
@ -122,7 +123,7 @@ Runner::Runner(async::Loop* loop)
SetThreadName("io.flutter.runner.main");
runner_context_->AddPublicService<fuchsia::sys::Runner>(
context_->outgoing()->AddPublicService<fuchsia::sys::Runner>(
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<fuchsia::sys::Runner>();
context_->outgoing()->RemovePublicService<fuchsia::sys::Runner>();
#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
);

View File

@ -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<RunnerContext> runner_context_;
std::unique_ptr<sys::ComponentContext> context_;
fidl::BindingSet<fuchsia::sys::Runner> active_applications_bindings_;
std::unordered_map<const Application*, ActiveApplication>
active_applications_;

View File

@ -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<sys::ServiceDirectory> svc,
zx::channel directory_request)
: svc_(std::move(svc)),
root_dir_(std::make_shared<vfs::PseudoDir>()),
public_dir_(std::make_shared<vfs::PseudoDir>()),
debug_dir_(std::make_shared<vfs::PseudoDir>()),
ctrl_dir_(std::make_shared<vfs::PseudoDir>()) {
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> RunnerContext::CreateFromStartupInfo() {
zx_handle_t directory_request = zx_take_startup_handle(PA_DIRECTORY_REQUEST);
return std::make_unique<RunnerContext>(
sys::ServiceDirectory::CreateFromNamespace(),
zx::channel(directory_request));
}
zx_status_t RunnerContext::AddPublicService(
std::unique_ptr<vfs::Service> service,
std::string service_name) const {
return public_dir_->AddEntry(std::move(service_name), std::move(service));
}
} // namespace flutter_runner

View File

@ -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 <memory>
#include <unordered_map>
#include <fuchsia/sys/cpp/fidl.h>
#include <lib/async-loop/cpp/loop.h>
#include <lib/sys/cpp/component_context.h>
#include <lib/vfs/cpp/pseudo_dir.h>
#include <lib/vfs/cpp/service.h>
#include <zircon/process.h>
#include <zircon/processargs.h>
#include "flutter/fml/macros.h"
namespace flutter_runner {
class RunnerContext {
public:
RunnerContext(std::shared_ptr<sys::ServiceDirectory> svc,
zx::channel directory_request);
~RunnerContext();
static std::unique_ptr<RunnerContext> CreateFromStartupInfo();
const std::shared_ptr<sys::ServiceDirectory>& svc() const { return svc_; }
const std::shared_ptr<vfs::PseudoDir>& root_dir() const { return root_dir_; }
const std::shared_ptr<vfs::PseudoDir>& public_dir() const {
return public_dir_;
}
const std::shared_ptr<vfs::PseudoDir>& debug_dir() const {
return debug_dir_;
}
const std::shared_ptr<vfs::PseudoDir>& ctrl_dir() const { return ctrl_dir_; }
template <typename Interface>
zx_status_t AddPublicService(
fidl::InterfaceRequestHandler<Interface> handler,
std::string service_name = Interface::Name_) const {
return AddPublicService(std::make_unique<vfs::Service>(std::move(handler)),
std::move(service_name));
}
zx_status_t AddPublicService(std::unique_ptr<vfs::Service> service,
std::string service_name) const;
template <typename Interface>
zx_status_t RemovePublicService(
const std::string& name = Interface::Name_) const {
return public_dir_->RemoveEntry(name);
}
private:
std::shared_ptr<sys::ServiceDirectory> svc_;
std::shared_ptr<vfs::PseudoDir> root_dir_;
std::shared_ptr<vfs::PseudoDir> public_dir_;
std::shared_ptr<vfs::PseudoDir> debug_dir_;
std::shared_ptr<vfs::PseudoDir> ctrl_dir_;
FML_DISALLOW_COPY_AND_ASSIGN(RunnerContext);
};
} // namespace flutter_runner
#endif // FLUTTER_SHELL_PLATFORM_FUCHSIA_RUNNER_CONTEXT_H_