Skip to content

Commit

Permalink
Add support for PA_SERVICE_REQUEST (flutter#3746)
Browse files Browse the repository at this point in the history
This patch adds support for the new way of exposing services from applications.
  • Loading branch information
abarth authored Jun 6, 2017
1 parent ffba1d6 commit 2e74a6b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
1 change: 1 addition & 0 deletions content_handler/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
31 changes: 17 additions & 14 deletions content_handler/application_controller_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
10 changes: 2 additions & 8 deletions content_handler/application_controller_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -22,7 +23,6 @@ class App;
class RuntimeHolder;

class ApplicationControllerImpl : public app::ApplicationController,
public app::ServiceProvider,
public mozart::ViewProvider {
public:
ApplicationControllerImpl(
Expand All @@ -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(
Expand All @@ -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_;

Expand Down

0 comments on commit 2e74a6b

Please sign in to comment.