Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Unified Diff: mojo/application_manager/application_manager.cc

Issue 845593003: Pass ServiceProvider and ServiceProvider& params in Connect (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: services & exposed_services Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/application_manager/application_manager.cc
diff --git a/mojo/application_manager/application_manager.cc b/mojo/application_manager/application_manager.cc
index 2ff28c3d1527aa7df5dab9a4ea1db4f8293cb1ee..d0ed1c97da05447ef5b89d8ce4ab0521472df88c 100644
--- a/mojo/application_manager/application_manager.cc
+++ b/mojo/application_manager/application_manager.cc
@@ -71,9 +71,10 @@ class ApplicationManager::ShellImpl : public Shell, public ErrorHandler {
~ShellImpl() override {}
void ConnectToClient(const GURL& requestor_url,
- ServiceProviderPtr service_provider) {
- client()->AcceptConnection(String::From(requestor_url),
- service_provider.Pass());
+ InterfaceRequest<ServiceProvider> services,
+ ServiceProviderPtr exposed_services) {
+ client()->AcceptConnection(String::From(requestor_url), services.Pass(),
+ exposed_services.Pass());
}
Application* client() { return binding_.client(); }
@@ -92,17 +93,16 @@ class ApplicationManager::ShellImpl : public Shell, public ErrorHandler {
}
// Shell implementation:
- void ConnectToApplication(
- const String& app_url,
- InterfaceRequest<ServiceProvider> in_service_provider) override {
- ServiceProviderPtr out_service_provider;
- out_service_provider.Bind(in_service_provider.PassMessagePipe());
+ void ConnectToApplication(const String& app_url,
+ InterfaceRequest<ServiceProvider> services,
+ ServiceProviderPtr exposed_services) override {
GURL app_gurl(app_url);
if (!app_gurl.is_valid()) {
LOG(ERROR) << "Error: invalid URL: " << app_url;
return;
}
- manager_->ConnectToApplication(app_gurl, url_, out_service_provider.Pass());
+ manager_->ConnectToApplication(app_gurl, url_, services.Pass(),
+ exposed_services.Pass());
}
// ErrorHandler implementation:
@@ -121,12 +121,10 @@ class ApplicationManager::ContentHandlerConnection : public ErrorHandler {
ContentHandlerConnection(ApplicationManager* manager,
const GURL& content_handler_url)
: manager_(manager), content_handler_url_(content_handler_url) {
- ServiceProviderPtr service_provider;
- StubServiceProvider* service_provider_impl =
- BindToProxy(new StubServiceProvider, &service_provider);
- manager->ConnectToApplication(
- content_handler_url, GURL(), service_provider.Pass());
- mojo::ConnectToService(service_provider_impl->client(), &content_handler_);
+ ServiceProviderPtr services;
+ manager->ConnectToApplication(content_handler_url, GURL(),
+ GetProxy(&services), ServiceProviderPtr());
+ mojo::ConnectToService(services.get(), &content_handler_);
content_handler_.set_error_handler(this);
}
@@ -181,13 +179,14 @@ void ApplicationManager::TerminateShellConnections() {
void ApplicationManager::ConnectToApplication(
const GURL& requested_url,
const GURL& requestor_url,
- ServiceProviderPtr service_provider) {
+ InterfaceRequest<ServiceProvider> services,
+ ServiceProviderPtr exposed_services) {
DCHECK(requested_url.is_valid());
ApplicationLoader* loader = GetLoaderForURL(requested_url,
DONT_INCLUDE_DEFAULT_LOADER);
if (loader) {
ConnectToApplicationImpl(requested_url, requested_url, requestor_url,
- service_provider.Pass(), loader);
+ services.Pass(), exposed_services.Pass(), loader);
return;
}
@@ -195,7 +194,7 @@ void ApplicationManager::ConnectToApplication(
loader = GetLoaderForURL(resolved_url, INCLUDE_DEFAULT_LOADER);
if (loader) {
ConnectToApplicationImpl(requested_url, resolved_url, requestor_url,
- service_provider.Pass(), loader);
+ services.Pass(), exposed_services.Pass(), loader);
return;
}
@@ -207,7 +206,8 @@ void ApplicationManager::ConnectToApplicationImpl(
const GURL& requested_url,
const GURL& resolved_url,
const GURL& requestor_url,
- ServiceProviderPtr service_provider,
+ InterfaceRequest<ServiceProvider> services,
+ ServiceProviderPtr exposed_services,
ApplicationLoader* loader) {
ShellImpl* shell = nullptr;
URLToShellImplMap::const_iterator shell_it =
@@ -225,14 +225,18 @@ void ApplicationManager::ConnectToApplicationImpl(
base::Bind(&ApplicationManager::LoadWithContentHandler,
weak_ptr_factory_.GetWeakPtr()));
}
- ConnectToClient(shell, resolved_url, requestor_url, service_provider.Pass());
+ ConnectToClient(shell, resolved_url, requestor_url, services.Pass(),
+ exposed_services.Pass());
}
-void ApplicationManager::ConnectToClient(ShellImpl* shell_impl,
- const GURL& url,
- const GURL& requestor_url,
- ServiceProviderPtr service_provider) {
- shell_impl->ConnectToClient(requestor_url, service_provider.Pass());
+void ApplicationManager::ConnectToClient(
+ ShellImpl* shell_impl,
+ const GURL& url,
+ const GURL& requestor_url,
+ InterfaceRequest<ServiceProvider> services,
+ ServiceProviderPtr exposed_services) {
+ shell_impl->ConnectToClient(requestor_url, services.Pass(),
+ exposed_services.Pass());
}
void ApplicationManager::RegisterExternalApplication(
@@ -325,13 +329,11 @@ void ApplicationManager::OnContentHandlerError(
ScopedMessagePipeHandle ApplicationManager::ConnectToServiceByName(
const GURL& application_url,
const std::string& interface_name) {
- StubServiceProvider* stub_sp = new StubServiceProvider;
- ServiceProviderPtr spp;
- BindToProxy(stub_sp, &spp);
- ConnectToApplication(application_url, GURL(), spp.Pass());
+ ServiceProviderPtr services;
+ ConnectToApplication(application_url, GURL(), GetProxy(&services),
+ ServiceProviderPtr());
MessagePipe pipe;
- stub_sp->GetRemoteServiceProvider()->ConnectToService(interface_name,
- pipe.handle1.Pass());
+ services->ConnectToService(interface_name, pipe.handle1.Pass());
return pipe.handle0.Pass();
}

Powered by Google App Engine
This is Rietveld 408576698