Remove [Client=] annotation from ServiceProvider

This removes the symmetrical nature of ServiceProvider and consistently
passes and uses a ServiceProvider + ServiceProvider& pair in places that
wish to bidirectionally expose services, such as the view manager.

The
view manager library now deals with InterfaceRequest<ServiceProvider>
and ServiceProviderPtr objects (i.e. c++ wrappers for handles) instead
of a concrete implementation of ServiceProvider to make it easier for
callers.

A number of places that were assuming a particular
ServiceProvider would always exist are updated to reflect the nullability
of the parameters in mojom and places that do not wish to ever look up
or provide services now pass nullptr instead of doomed pipe handles.

The JS application startup classes are reworked a bit to accomodate
exposing services on the third ConnectToApplication/AcceptConnection
parameter.

BUG=449432
R=abarth@chromium.org, sky@chromium.org

Review URL: https://codereview.chromium.org/858103002
This commit is contained in:
James Robinson
2015-01-21 18:36:01 -08:00
parent 31de067e43
commit 4f3537a797
5 changed files with 29 additions and 32 deletions

View File

@@ -15,6 +15,7 @@ SkyDebugger::SkyDebugger()
content_(nullptr),
navigator_host_factory_(this),
weak_factory_(this) {
exposed_services_impl_.AddService(&navigator_host_factory_);
}
SkyDebugger::~SkyDebugger() {
@@ -45,8 +46,8 @@ bool SkyDebugger::ConfigureOutgoingConnection(
void SkyDebugger::OnEmbed(
mojo::View* root,
mojo::ServiceProviderImpl* exported_services,
scoped_ptr<mojo::ServiceProvider> imported_services) {
mojo::InterfaceRequest<mojo::ServiceProvider> services,
mojo::ServiceProviderPtr exposed_services) {
root_ = root;
root_->AddObserver(this);
@@ -64,13 +65,10 @@ void SkyDebugger::OnEmbed(
NavigateToURL(pending_url_);
}
void SkyDebugger::Embed(
const mojo::String& url,
mojo::InterfaceRequest<mojo::ServiceProvider> service_provider) {
scoped_ptr<mojo::ServiceProviderImpl> exported_services(
new mojo::ServiceProviderImpl());
// exported_services->AddService(TBD) -- no exported services for now.
content_->Embed(url, exported_services.Pass());
void SkyDebugger::Embed(const mojo::String& url,
mojo::InterfaceRequest<mojo::ServiceProvider> services,
mojo::ServiceProviderPtr exposed_services) {
content_->Embed(url, nullptr, nullptr);
}
void SkyDebugger::OnViewManagerDisconnected(mojo::ViewManager* view_manager) {
@@ -97,10 +95,9 @@ void SkyDebugger::NavigateToURL(const mojo::String& url) {
// embedded into the view and content_ created.
// Just save the last one.
if (content_) {
scoped_ptr<mojo::ServiceProviderImpl> exported_services(
new mojo::ServiceProviderImpl());
exported_services->AddService(&navigator_host_factory_);
viewer_services_ = content_->Embed(url, exported_services.Pass());
mojo::ServiceProviderPtr exposed_services;
exposed_services_impl_.Bind(GetProxy(&exposed_services));
content_->Embed(url, GetProxy(&viewer_services_), exposed_services.Pass());
} else {
pending_url_ = url;
}

View File

@@ -48,8 +48,8 @@ class SkyDebugger : public mojo::ApplicationDelegate,
// Overridden from mojo::ViewManagerDelegate:
void OnEmbed(mojo::View* root,
mojo::ServiceProviderImpl* exported_services,
scoped_ptr<mojo::ServiceProvider> imported_services) override;
mojo::InterfaceRequest<mojo::ServiceProvider> services,
mojo::ServiceProviderPtr exposed_services) override;
void OnViewManagerDisconnected(mojo::ViewManager* view_manager) override;
// Overriden from mojo::ViewObserver:
@@ -63,9 +63,9 @@ class SkyDebugger : public mojo::ApplicationDelegate,
mojo::InterfaceRequest<Debugger> request) override;
// Overridden from WindowManagerDelegate
void Embed(
const mojo::String& url,
mojo::InterfaceRequest<mojo::ServiceProvider> service_provider) override;
void Embed(const mojo::String& url,
mojo::InterfaceRequest<mojo::ServiceProvider> services,
mojo::ServiceProviderPtr exposed_services) override;
scoped_ptr<window_manager::WindowManagerApp> window_manager_app_;
@@ -73,9 +73,10 @@ class SkyDebugger : public mojo::ApplicationDelegate,
mojo::View* content_;
std::string pending_url_;
scoped_ptr<mojo::ServiceProvider> viewer_services_;
mojo::ServiceProviderPtr viewer_services_;
NavigatorHostFactory navigator_host_factory_;
mojo::ServiceProviderImpl exposed_services_impl_;
base::WeakPtrFactory<SkyDebugger> weak_factory_;

View File

@@ -7,7 +7,6 @@
#include <iostream>
#include "base/bind.h"
#include "mojo/public/cpp/application/connect.h"
#include "mojo/public/cpp/application/service_provider_impl.h"
#include "mojo/services/view_manager/public/cpp/view.h"
namespace sky {
@@ -24,11 +23,11 @@ TestRunner::TestRunner(TestRunnerClient* client, mojo::View* container,
enable_pixel_dumping_(enable_pixel_dumping) {
CHECK(client);
scoped_ptr<mojo::ServiceProviderImpl> exported_services(
new mojo::ServiceProviderImpl());
exported_services->AddService(&test_harness_factory_);
mojo::ServiceProviderPtr test_harness_provider;
test_harness_provider_impl_.AddService(&test_harness_factory_);
test_harness_provider_impl_.Bind(GetProxy(&test_harness_provider));
container->Embed(url, exported_services.Pass());
container->Embed(url, nullptr, test_harness_provider.Pass());
}
TestRunner::~TestRunner() {

View File

@@ -6,6 +6,7 @@
#define SKY_TOOLS_TESTER_TEST_RUNNER_H_
#include "base/memory/weak_ptr.h"
#include "mojo/public/cpp/application/service_provider_impl.h"
#include "sky/tools/tester/test_harness_impl.h"
namespace mojo{
@@ -40,6 +41,7 @@ class TestRunner {
private:
TestHarnessFactory test_harness_factory_;
mojo::ServiceProviderImpl test_harness_provider_impl_;
TestRunnerClient* client_;
base::WeakPtrFactory<TestRunner> weak_ptr_factory_;
bool enable_pixel_dumping_;

View File

@@ -83,10 +83,9 @@ class SkyTester : public mojo::ApplicationDelegate,
}
// Overridden from mojo::ViewManagerDelegate:
virtual void OnEmbed(
mojo::View* root,
mojo::ServiceProviderImpl* exported_services,
scoped_ptr<mojo::ServiceProvider> remote_service_provider) override {
virtual void OnEmbed(mojo::View* root,
mojo::InterfaceRequest<mojo::ServiceProvider> services,
mojo::ServiceProviderPtr exposed_services) override {
root_ = root;
root_->AddObserver(this);
@@ -101,10 +100,9 @@ class SkyTester : public mojo::ApplicationDelegate,
}
// Overridden from window_manager::WindowManagerDelegate:
virtual void Embed(
const mojo::String& url,
mojo::InterfaceRequest<mojo::ServiceProvider> service_provider) override {
}
virtual void Embed(const mojo::String& url,
mojo::InterfaceRequest<mojo::ServiceProvider> services,
mojo::ServiceProviderPtr exposed_services) override {}
virtual void OnViewManagerDisconnected(
mojo::ViewManager* view_manager) override {