diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-11 14:44:25 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-11 14:44:25 +0000 |
commit | 76b8e58c5b8cf693f61ec1aa981df99c12e00506 (patch) | |
tree | 116afbb6d8ab0c2bf20afdfa5c8d796e3656b38a /mojo/shell | |
parent | 033f12364a6adb6992787a8c4e737df26b1ce356 (diff) | |
download | chromium_src-76b8e58c5b8cf693f61ec1aa981df99c12e00506.zip chromium_src-76b8e58c5b8cf693f61ec1aa981df99c12e00506.tar.gz chromium_src-76b8e58c5b8cf693f61ec1aa981df99c12e00506.tar.bz2 |
Mojo: Introduce InterfaceHandle<S>, Interface<S> and InterfacePipe<S,P>
Teach the C++ bindings generator produce code with a typed variant of ScopedMessagePipeHandle when possible. Require that RemotePtr<S> be initialized from such.
InterfaceHandle<S> is the typed variant of MessagePipeHandle.
Interface<S>::ScopedHandle is the typed variant of ScopedMessagePipeHandle.
In addition, generate typedefs for InterfaceHandle<S> and Interface<S>::ScopedHandle for convenience. For example, from shell.mojom we generate {Scoped}ShellHandle and {Scoped}ShellClientHandle.
BUG=336722
Review URL: https://codereview.chromium.org/152793005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@250407 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/shell')
-rw-r--r-- | mojo/shell/android/mojo_main.cc | 2 | ||||
-rw-r--r-- | mojo/shell/dynamic_service_loader.cc | 7 | ||||
-rw-r--r-- | mojo/shell/dynamic_service_loader.h | 3 | ||||
-rw-r--r-- | mojo/shell/service_connector.cc | 6 | ||||
-rw-r--r-- | mojo/shell/service_connector.h | 3 | ||||
-rw-r--r-- | mojo/shell/service_connector_unittest.cc | 11 |
6 files changed, 18 insertions, 14 deletions
diff --git a/mojo/shell/android/mojo_main.cc b/mojo/shell/android/mojo_main.cc index fe18c24..127471e 100644 --- a/mojo/shell/android/mojo_main.cc +++ b/mojo/shell/android/mojo_main.cc @@ -41,7 +41,7 @@ class NativeViewportServiceLoader : public shell::ServiceConnector::Loader { private: virtual void Load(const GURL& url, - ScopedMessagePipeHandle service_handle) + ScopedShellHandle service_handle) MOJO_OVERRIDE { service_.reset(CreateNativeViewportService(g_context.Get().get(), service_handle.Pass())); diff --git a/mojo/shell/dynamic_service_loader.cc b/mojo/shell/dynamic_service_loader.cc index f1e3de9..4c62dd9 100644 --- a/mojo/shell/dynamic_service_loader.cc +++ b/mojo/shell/dynamic_service_loader.cc @@ -12,6 +12,7 @@ #include "mojo/shell/context.h" #include "mojo/shell/keep_alive.h" #include "mojo/shell/switches.h" +#include "mojom/shell.h" typedef MojoResult (*MojoMainFunction)(MojoHandle pipe); @@ -40,7 +41,7 @@ class DynamicServiceLoader::LoadContext public: LoadContext(DynamicServiceLoader* loader, const GURL& url, - ScopedMessagePipeHandle service_handle) + ScopedShellHandle service_handle) : thread_(this, "app_thread"), loader_(loader), url_(url), @@ -118,7 +119,7 @@ class DynamicServiceLoader::LoadContext GURL url_; base::FilePath app_path_; scoped_ptr<mojo::shell::Loader::Job> request_; - ScopedMessagePipeHandle service_handle_; + ScopedShellHandle service_handle_; KeepAlive keep_alive_; }; @@ -131,7 +132,7 @@ DynamicServiceLoader::~DynamicServiceLoader() { } void DynamicServiceLoader::Load(const GURL& url, - ScopedMessagePipeHandle service_handle) { + ScopedShellHandle service_handle) { DCHECK(url_to_load_context_.find(url) == url_to_load_context_.end()); url_to_load_context_[url] = new LoadContext(this, url, service_handle.Pass()); } diff --git a/mojo/shell/dynamic_service_loader.h b/mojo/shell/dynamic_service_loader.h index 10bbba9..ce210d9 100644 --- a/mojo/shell/dynamic_service_loader.h +++ b/mojo/shell/dynamic_service_loader.h @@ -11,6 +11,7 @@ #include "mojo/public/system/core_cpp.h" #include "mojo/shell/keep_alive.h" #include "mojo/shell/service_connector.h" +#include "mojom/shell.h" #include "url/gurl.h" namespace mojo { @@ -30,7 +31,7 @@ class DynamicServiceLoader : public ServiceConnector::Loader { // value specified to the --origin command line argument will be used as the // host / port. virtual void Load(const GURL& url, - ScopedMessagePipeHandle service_handle) MOJO_OVERRIDE; + ScopedShellHandle service_handle) MOJO_OVERRIDE; private: class LoadContext; diff --git a/mojo/shell/service_connector.cc b/mojo/shell/service_connector.cc index 7251c85..2c2f0d0 100644 --- a/mojo/shell/service_connector.cc +++ b/mojo/shell/service_connector.cc @@ -17,9 +17,9 @@ class ServiceConnector::ServiceFactory : public Shell, public ErrorHandler { ServiceFactory(ServiceConnector* connector, const GURL& url) : connector_(connector), url_(url) { - MessagePipe pipe; - shell_client_.reset(pipe.handle0.Pass(), this, this); - connector_->GetLoaderForURL(url)->Load(url, pipe.handle1.Pass()); + InterfacePipe<Shell> pipe; + shell_client_.reset(pipe.handle_to_peer.Pass(), this, this); + connector_->GetLoaderForURL(url)->Load(url, pipe.handle_to_self.Pass()); } virtual ~ServiceFactory() {} diff --git a/mojo/shell/service_connector.h b/mojo/shell/service_connector.h index 65a646e..41587ef 100644 --- a/mojo/shell/service_connector.h +++ b/mojo/shell/service_connector.h @@ -10,6 +10,7 @@ #include "base/basictypes.h" #include "base/callback.h" #include "mojo/public/system/core_cpp.h" +#include "mojom/shell.h" #include "url/gurl.h" namespace mojo { @@ -23,7 +24,7 @@ class ServiceConnector { public: virtual ~Loader(); virtual void Load(const GURL& url, - ScopedMessagePipeHandle service_handle) = 0; + ScopedShellHandle service_handle) = 0; protected: Loader(); }; diff --git a/mojo/shell/service_connector_unittest.cc b/mojo/shell/service_connector_unittest.cc index 2af4f10..f007fed 100644 --- a/mojo/shell/service_connector_unittest.cc +++ b/mojo/shell/service_connector_unittest.cc @@ -48,7 +48,7 @@ class TestServiceImpl : class TestClientImpl : public TestClient { public: - explicit TestClientImpl(ScopedMessagePipeHandle service_handle) + explicit TestClientImpl(ScopedTestServiceHandle service_handle) : service_(service_handle.Pass(), this), quit_after_ack_(false) { } @@ -84,9 +84,10 @@ class ServiceConnectorTest : public testing::Test, GURL test_url(kTestURLString); service_connector_.reset(new ServiceConnector); service_connector_->SetLoaderForURL(this, test_url); - MessagePipe pipe; - test_client_.reset(new TestClientImpl(pipe.handle0.Pass())); - service_connector_->Connect(test_url, pipe.handle1.Pass()); + + InterfacePipe<TestService, AnyInterface> pipe; + test_client_.reset(new TestClientImpl(pipe.handle_to_self.Pass())); + service_connector_->Connect(test_url, pipe.handle_to_peer.Pass()); } virtual void TearDown() OVERRIDE { @@ -96,7 +97,7 @@ class ServiceConnectorTest : public testing::Test, } virtual void Load(const GURL& url, - ScopedMessagePipeHandle shell_handle) OVERRIDE { + ScopedShellHandle shell_handle) OVERRIDE { test_app_.reset(new ServiceFactory<TestServiceImpl, TestContext>( shell_handle.Pass(), &context_)); } |