提交 2e74a6ba 编写于 作者: A Adam Barth 提交者: GitHub

Add support for PA_SERVICE_REQUEST (#3746)

This patch adds support for the new way of exposing services from applications.
上级 ffba1d61
......@@ -42,6 +42,7 @@ template("flutter_content_handler") {
deps = [
"//application/lib/app",
"//application/lib/svc",
"//apps/icu_data/lib",
"//apps/mozart/lib/flutter/sdk_ext",
"//apps/mozart/lib/skia:vmo",
......
......@@ -38,15 +38,29 @@ ApplicationControllerImpl::ApplicationControllerImpl(
// startup handles.
if (startup_info->launch_info->services) {
service_provider_bindings_.AddBinding(
this, std::move(startup_info->launch_info->services));
service_provider_bridge_.AddBinding(
std::move(startup_info->launch_info->services));
}
if (startup_info->launch_info->service_request.is_valid()) {
service_provider_bridge_.ServeDirectory(
std::move(startup_info->launch_info->service_request));
}
service_provider_bridge_.AddService<mozart::ViewProvider>(
[this](fidl::InterfaceRequest<mozart::ViewProvider> request) {
view_provider_bindings_.AddBinding(this, std::move(request));
});
app::ServiceProviderPtr service_provider;
auto request = service_provider.NewRequest();
service_provider_bridge_.set_backend(std::move(service_provider));
url_ = startup_info->launch_info->url;
runtime_holder_.reset(new RuntimeHolder());
runtime_holder_->Init(
app::ApplicationContext::CreateFrom(std::move(startup_info)),
fidl::GetProxy(&dart_service_provider_), std::move(bundle));
std::move(request), std::move(bundle));
}
ApplicationControllerImpl::~ApplicationControllerImpl() = default;
......@@ -61,17 +75,6 @@ void ApplicationControllerImpl::Detach() {
binding_.set_connection_error_handler(ftl::Closure());
}
void ApplicationControllerImpl::ConnectToService(
const fidl::String& service_name,
mx::channel channel) {
if (service_name == mozart::ViewProvider::Name_) {
view_provider_bindings_.AddBinding(
this, fidl::InterfaceRequest<mozart::ViewProvider>(std::move(channel)));
} else {
dart_service_provider_->ConnectToService(service_name, std::move(channel));
}
}
void ApplicationControllerImpl::CreateView(
fidl::InterfaceRequest<mozart::ViewOwner> view_owner_request,
fidl::InterfaceRequest<app::ServiceProvider> services) {
......
......@@ -7,6 +7,7 @@
#include <memory>
#include "application/lib/svc/service_provider_bridge.h"
#include "application/services/application_controller.fidl.h"
#include "application/services/application_runner.fidl.h"
#include "application/services/service_provider.fidl.h"
......@@ -22,7 +23,6 @@ class App;
class RuntimeHolder;
class ApplicationControllerImpl : public app::ApplicationController,
public app::ServiceProvider,
public mozart::ViewProvider {
public:
ApplicationControllerImpl(
......@@ -38,11 +38,6 @@ class ApplicationControllerImpl : public app::ApplicationController,
void Kill() override;
void Detach() override;
// |app::ServiceProvider| implementation
void ConnectToService(const fidl::String& service_name,
mx::channel channel) override;
// |mozart::ViewProvider| implementation
void CreateView(
......@@ -58,8 +53,7 @@ class ApplicationControllerImpl : public app::ApplicationController,
App* app_;
fidl::Binding<app::ApplicationController> binding_;
fidl::BindingSet<app::ServiceProvider> service_provider_bindings_;
app::ServiceProviderPtr dart_service_provider_;
app::ServiceProviderBridge service_provider_bridge_;
fidl::BindingSet<mozart::ViewProvider> view_provider_bindings_;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册