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
This commit is contained in:
James Robinson 2015-01-14 14:33:07 -08:00
parent 1dee21f363
commit be2f656ab1
8 changed files with 34 additions and 22 deletions

View File

@ -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);
}

View File

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

View File

@ -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<mojo::String> args) override {}
void AcceptConnection(const mojo::String& requestor_url,
mojo::ServiceProviderPtr provider) override {
mojo::InterfaceRequest<mojo::ServiceProvider> 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<mojo::ServiceProvider> services,
mojo::ServiceProviderPtr exposed_services,
mojo::URLResponsePtr response) {
new DocumentView(services.Pass(), exposed_services.Pass(), response.Pass(),
shell_.get());
}
mojo::String url_;

View File

@ -73,7 +73,8 @@ mojo::Target WebNavigationPolicyToNavigationTarget(
static int s_next_debugger_id = 1;
DocumentView::DocumentView(
mojo::ServiceProviderPtr provider,
mojo::InterfaceRequest<mojo::ServiceProvider> 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() {

View File

@ -47,7 +47,8 @@ class DocumentView : public blink::ServiceProvider,
public mojo::ViewManagerDelegate,
public mojo::ViewObserver {
public:
DocumentView(mojo::ServiceProviderPtr provider,
DocumentView(mojo::InterfaceRequest<mojo::ServiceProvider> services,
mojo::ServiceProviderPtr exported_services,
mojo::URLResponsePtr response,
mojo::Shell* shell);
virtual ~DocumentView();

View File

@ -100,11 +100,13 @@ mojo::Handle Internals::PassShellProxyHandle() {
}
void Internals::ConnectToApplication(
const mojo::String& application_url,
mojo::InterfaceRequest<mojo::ServiceProvider> provider) {
if (document_view_)
const mojo::String& application_url,
mojo::InterfaceRequest<mojo::ServiceProvider> 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());

View File

@ -31,8 +31,9 @@ class Internals : public gin::Wrappable<Internals>,
// mojo::Shell method:
void ConnectToApplication(
const mojo::String& application_url,
mojo::InterfaceRequest<mojo::ServiceProvider> provider) override;
const mojo::String& application_url,
mojo::InterfaceRequest<mojo::ServiceProvider> services,
mojo::ServiceProviderPtr exposed_services) override;
mojo::Handle PassShellProxyHandle();
std::string RenderTreeAsText();

View File

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