From be2f656ab12589d8993c88b458e83fd3e92337ea Mon Sep 17 00:00:00 2001 From: James Robinson Date: Wed, 14 Jan 2015 14:33:07 -0800 Subject: [PATCH] Pass ServiceProvider and ServiceProvider& params in Connect In preperation for removing the Client annotation from ServiceProvider this passes a second parameter of type ServiceProvider in the shell and application Connect calls. In this patch the type signatures are updated but the second parameter is basically unused. The intention is that the first parameter |services| will be used for the connecting application to request services from the connected application (as it does currently) and the second parameter |exported_services| be used for the connecting application to provide services to the connected application. We have very few services exported in the second direction today - I'll update them to use the second parameter in a follow-up patch. R=darin@chromium.org Review URL: https://codereview.chromium.org/845593003 --- compositor/surface_holder.cc | 2 +- engine/v8_inspector/inspector_backend_mojo.cc | 2 +- viewer/content_handler_impl.cc | 22 +++++++++++-------- viewer/document_view.cc | 6 +++-- viewer/document_view.h | 3 ++- viewer/internals.cc | 13 ++++++----- viewer/internals.h | 5 +++-- viewer/services/inspector_impl.cc | 3 ++- 8 files changed, 34 insertions(+), 22 deletions(-) diff --git a/compositor/surface_holder.cc b/compositor/surface_holder.cc index f2ad3297a07..e46490226ef 100644 --- a/compositor/surface_holder.cc +++ b/compositor/surface_holder.cc @@ -20,7 +20,7 @@ SurfaceHolder::SurfaceHolder(Client* client, mojo::Shell* shell) : client_(client), id_namespace_(0u), local_id_(0u), weak_factory_(this) { mojo::ServiceProviderPtr service_provider; shell->ConnectToApplication("mojo:surfaces_service", - mojo::GetProxy(&service_provider)); + mojo::GetProxy(&service_provider), nullptr); mojo::ConnectToService(service_provider.get(), &surface_); surface_.set_client(this); } diff --git a/engine/v8_inspector/inspector_backend_mojo.cc b/engine/v8_inspector/inspector_backend_mojo.cc index df8a08833a2..c4349efdead 100644 --- a/engine/v8_inspector/inspector_backend_mojo.cc +++ b/engine/v8_inspector/inspector_backend_mojo.cc @@ -111,7 +111,7 @@ void InspectorBackendMojoImpl::Connect() { service_provider_request.Bind(pipe.handle0.Pass()); inspector_service_provider_.BindToHandle(pipe.handle1.Pass()); shell->ConnectToApplication("mojo:sky_inspector_server", - service_provider_request.Pass()); + service_provider_request.Pass(), nullptr); mojo::ConnectToService(&inspector_service_provider_, &frontend_); // Theoretically we should load our state from the inspector cookie. diff --git a/viewer/content_handler_impl.cc b/viewer/content_handler_impl.cc index e4ceaec945b..3bf26f52d74 100644 --- a/viewer/content_handler_impl.cc +++ b/viewer/content_handler_impl.cc @@ -21,17 +21,18 @@ class SkyApplication : public mojo::Application { shell_.set_client(this); mojo::ServiceProviderPtr service_provider; shell_->ConnectToApplication("mojo:network_service", - mojo::GetProxy(&service_provider)); + mojo::GetProxy(&service_provider), nullptr); mojo::ConnectToService(service_provider.get(), &network_service_); } void Initialize(mojo::Array args) override {} void AcceptConnection(const mojo::String& requestor_url, - mojo::ServiceProviderPtr provider) override { + mojo::InterfaceRequest services, + mojo::ServiceProviderPtr exposed_services) override { if (initial_response_) { - OnResponseReceived(mojo::URLLoaderPtr(), provider.Pass(), - initial_response_.Pass()); + OnResponseReceived(mojo::URLLoaderPtr(), services.Pass(), + exposed_services.Pass(), initial_response_.Pass()); } else { mojo::URLLoaderPtr loader; network_service_->CreateURLLoader(mojo::GetProxy(&loader)); @@ -47,15 +48,18 @@ class SkyApplication : public mojo::Application { request.Pass(), base::Bind(&SkyApplication::OnResponseReceived, base::Unretained(this), base::Passed(&loader), - base::Passed(&provider))); + base::Passed(&services), base::Passed(&exposed_services))); } } private: - void OnResponseReceived(mojo::URLLoaderPtr loader, - mojo::ServiceProviderPtr provider, - mojo::URLResponsePtr response) { - new DocumentView(provider.Pass(), response.Pass(), shell_.get()); + void OnResponseReceived( + mojo::URLLoaderPtr loader, + mojo::InterfaceRequest services, + mojo::ServiceProviderPtr exposed_services, + mojo::URLResponsePtr response) { + new DocumentView(services.Pass(), exposed_services.Pass(), response.Pass(), + shell_.get()); } mojo::String url_; diff --git a/viewer/document_view.cc b/viewer/document_view.cc index 0e26a4c0bb6..72b8681012d 100644 --- a/viewer/document_view.cc +++ b/viewer/document_view.cc @@ -73,7 +73,8 @@ mojo::Target WebNavigationPolicyToNavigationTarget( static int s_next_debugger_id = 1; DocumentView::DocumentView( - mojo::ServiceProviderPtr provider, + mojo::InterfaceRequest services, + mojo::ServiceProviderPtr exported_services, mojo::URLResponsePtr response, mojo::Shell* shell) : response_(response.Pass()), @@ -84,8 +85,9 @@ DocumentView::DocumentView( inspector_service_factory_(this), weak_factory_(this), debugger_id_(s_next_debugger_id++) { + // TODO(jamesr): Is this right? exported_services_.AddService(&view_manager_client_factory_); - mojo::WeakBindToPipe(&exported_services_, provider.PassMessagePipe()); + mojo::WeakBindToPipe(&exported_services_, services.PassMessagePipe()); } DocumentView::~DocumentView() { diff --git a/viewer/document_view.h b/viewer/document_view.h index 98d8513ca39..1c80db9f695 100644 --- a/viewer/document_view.h +++ b/viewer/document_view.h @@ -47,7 +47,8 @@ class DocumentView : public blink::ServiceProvider, public mojo::ViewManagerDelegate, public mojo::ViewObserver { public: - DocumentView(mojo::ServiceProviderPtr provider, + DocumentView(mojo::InterfaceRequest services, + mojo::ServiceProviderPtr exported_services, mojo::URLResponsePtr response, mojo::Shell* shell); virtual ~DocumentView(); diff --git a/viewer/internals.cc b/viewer/internals.cc index f52e7ed1ed6..5edf79affc6 100644 --- a/viewer/internals.cc +++ b/viewer/internals.cc @@ -100,11 +100,13 @@ mojo::Handle Internals::PassShellProxyHandle() { } void Internals::ConnectToApplication( - const mojo::String& application_url, - mojo::InterfaceRequest provider) { - if (document_view_) + const mojo::String& application_url, + mojo::InterfaceRequest services, + mojo::ServiceProviderPtr exposed_services) { + if (document_view_) { document_view_->shell()->ConnectToApplication( - application_url, provider.Pass()); + application_url, services.Pass(), exposed_services.Pass()); + } } mojo::Handle Internals::ConnectToService( @@ -113,7 +115,8 @@ mojo::Handle Internals::ConnectToService( return mojo::Handle(); mojo::ServiceProviderPtr service_provider; - ConnectToApplication(application_url, mojo::GetProxy(&service_provider)); + ConnectToApplication(application_url, mojo::GetProxy(&service_provider), + nullptr); mojo::MessagePipe pipe; service_provider->ConnectToService(interface_name, pipe.handle1.Pass()); diff --git a/viewer/internals.h b/viewer/internals.h index 58a7781af99..e546b922dd6 100644 --- a/viewer/internals.h +++ b/viewer/internals.h @@ -31,8 +31,9 @@ class Internals : public gin::Wrappable, // mojo::Shell method: void ConnectToApplication( - const mojo::String& application_url, - mojo::InterfaceRequest provider) override; + const mojo::String& application_url, + mojo::InterfaceRequest services, + mojo::ServiceProviderPtr exposed_services) override; mojo::Handle PassShellProxyHandle(); std::string RenderTreeAsText(); diff --git a/viewer/services/inspector_impl.cc b/viewer/services/inspector_impl.cc index 367c71544b5..d85c3e37df1 100644 --- a/viewer/services/inspector_impl.cc +++ b/viewer/services/inspector_impl.cc @@ -29,7 +29,8 @@ void InspectorServiceImpl::Inject() { mojo::ServiceProviderPtr inspector_service_provider; view_->shell()->ConnectToApplication("mojo:sky_inspector_server", - GetProxy(&inspector_service_provider)); + GetProxy(&inspector_service_provider), + nullptr); InspectorServerPtr inspector; mojo::ConnectToService(inspector_service_provider.get(), &inspector); inspector->Listen(9898, base::Bind(&Ignored));