diff options
author | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-27 15:51:00 +0000 |
---|---|---|
committer | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-27 15:51:00 +0000 |
commit | 922f25039d939159501fad266518290b2c05fe2a (patch) | |
tree | 82f23eaa36a8d86f86d86b7f8aa85c487629057d | |
parent | bcbdd98cc4d033b29fa633cbc1c81599ba6d9977 (diff) | |
download | chromium_src-922f25039d939159501fad266518290b2c05fe2a.zip chromium_src-922f25039d939159501fad266518290b2c05fe2a.tar.gz chromium_src-922f25039d939159501fad266518290b2c05fe2a.tar.bz2 |
Change Shell / ShellClient to ServiceProvider
BUG=
R=darin@chromium.org
Review URL: https://codereview.chromium.org/298653010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272983 0039d316-1c4b-4281-b951-d872f2087c98
71 files changed, 364 insertions, 322 deletions
diff --git a/content/browser/mojo/mojo_application_host.cc b/content/browser/mojo/mojo_application_host.cc index 25b63d5..0825647 100644 --- a/content/browser/mojo/mojo_application_host.cc +++ b/content/browser/mojo/mojo_application_host.cc @@ -30,7 +30,7 @@ MojoApplicationHost::~MojoApplicationHost() { } bool MojoApplicationHost::Init() { - DCHECK(!shell_.get()) << "Already initialized!"; + DCHECK(!child_service_provider_.get()) << "Already initialized!"; mojo::embedder::PlatformChannelPair channel_pair; @@ -43,7 +43,8 @@ bool MojoApplicationHost::Init() { // Forward this to the client once we know its process handle. client_handle_ = channel_pair.PassClientHandle(); - shell_.reset(BindToPipe(new ShellImpl(), message_pipe.Pass())); + child_service_provider_.reset( + BindToPipe(new ServiceProviderImpl(), message_pipe.Pass())); return true; } @@ -59,7 +60,7 @@ bool MojoApplicationHost::Activate(IPC::Sender* sender, return did_activate_; } -void MojoApplicationHost::ShellImpl::Connect( +void MojoApplicationHost::ServiceProviderImpl::ConnectToService( const mojo::String& url, mojo::ScopedMessagePipeHandle handle) { // TODO(darin): Provide something meaningful here. diff --git a/content/browser/mojo/mojo_application_host.h b/content/browser/mojo/mojo_application_host.h index d9c61a5..84d350d 100644 --- a/content/browser/mojo/mojo_application_host.h +++ b/content/browser/mojo/mojo_application_host.h @@ -8,7 +8,7 @@ #include "base/process/process_handle.h" #include "mojo/common/channel_init.h" #include "mojo/embedder/scoped_platform_handle.h" -#include "mojo/public/interfaces/shell/shell.mojom.h" +#include "mojo/public/interfaces/service_provider/service_provider.mojom.h" namespace IPC { class Sender; @@ -34,27 +34,29 @@ class MojoApplicationHost { bool did_activate() const { return did_activate_; } - mojo::ShellClient* shell_client() { - DCHECK(shell_.get()); - return shell_->client(); + mojo::ServiceProvider* service_provider() { + DCHECK(child_service_provider_.get()); + return child_service_provider_->client(); } private: - class ShellImpl : public mojo::InterfaceImpl<mojo::Shell> { + class ServiceProviderImpl + : public mojo::InterfaceImpl<mojo::ServiceProvider> { public: virtual void OnConnectionError() OVERRIDE { // TODO(darin): How should we handle this error? } - // mojo::Shell methods: - virtual void Connect(const mojo::String& url, - mojo::ScopedMessagePipeHandle handle) OVERRIDE; + // mojo::ServiceProvider methods: + virtual void ConnectToService( + const mojo::String& url, + mojo::ScopedMessagePipeHandle handle) OVERRIDE; }; mojo::common::ChannelInit channel_init_; mojo::embedder::ScopedPlatformHandle client_handle_; - scoped_ptr<ShellImpl> shell_; + scoped_ptr<ServiceProviderImpl> child_service_provider_; bool did_activate_; diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index db99799..9ed6017 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -2074,8 +2074,8 @@ void RenderProcessHostImpl::ConnectTo( MaybeActivateMojo(); mojo::AllocationScope scope; - mojo_application_host_->shell_client()->AcceptConnection(service_name, - handle.Pass()); + mojo_application_host_->service_provider()->ConnectToService(service_name, + handle.Pass()); } } // namespace content diff --git a/content/child/child_thread.cc b/content/child/child_thread.cc index 1ac5468..0d2e7e0 100644 --- a/content/child/child_thread.cc +++ b/content/child/child_thread.cc @@ -353,7 +353,7 @@ void ChildThread::OnChannelError() { base::MessageLoop::current()->Quit(); } -void ChildThread::AcceptConnection( +void ChildThread::ConnectToService( const mojo::String& service_name, mojo::ScopedMessagePipeHandle message_pipe) { // By default, we don't expect incoming connections. diff --git a/content/child/child_thread.h b/content/child/child_thread.h index 1b04830..1728c71 100644 --- a/content/child/child_thread.h +++ b/content/child/child_thread.h @@ -16,7 +16,7 @@ #include "content/common/content_export.h" #include "content/common/message_router.h" #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. -#include "mojo/public/interfaces/shell/shell.mojom.h" +#include "mojo/public/interfaces/service_provider/service_provider.mojom.h" namespace base { class MessageLoop; @@ -56,9 +56,10 @@ class WebSocketDispatcher; struct RequestInfo; // The main thread of a child process derives from this class. -class CONTENT_EXPORT ChildThread : public IPC::Listener, - public IPC::Sender, - public NON_EXPORTED_BASE(mojo::ShellClient) { +class CONTENT_EXPORT ChildThread + : public IPC::Listener, + public IPC::Sender, + public NON_EXPORTED_BASE(mojo::ServiceProvider) { public: // Creates the thread. ChildThread(); @@ -170,7 +171,7 @@ class CONTENT_EXPORT ChildThread : public IPC::Listener, virtual void OnChannelError() OVERRIDE; // mojo::ShellClient implementation: - virtual void AcceptConnection( + virtual void ConnectToService( const mojo::String& service_name, mojo::ScopedMessagePipeHandle message_pipe) OVERRIDE; diff --git a/content/child/mojo/mojo_application.cc b/content/child/mojo/mojo_application.cc index b3d4935..79eea23 100644 --- a/content/child/mojo/mojo_application.cc +++ b/content/child/mojo/mojo_application.cc @@ -10,8 +10,8 @@ namespace content { -MojoApplication::MojoApplication(mojo::ShellClient* shell_client) - : shell_client_(shell_client) { +MojoApplication::MojoApplication(mojo::ServiceProvider* service_provider) + : service_provider_(service_provider) { } MojoApplication::~MojoApplication() { @@ -38,8 +38,8 @@ void MojoApplication::OnActivate( ChildProcess::current()->io_message_loop_proxy()); DCHECK(message_pipe.is_valid()); - shell_.Bind(message_pipe.Pass()); - shell_.set_client(shell_client_); + host_service_provider_.Bind(message_pipe.Pass()); + host_service_provider_.set_client(service_provider_); } } // namespace content diff --git a/content/child/mojo/mojo_application.h b/content/child/mojo/mojo_application.h index 88646b6..ef05f75 100644 --- a/content/child/mojo/mojo_application.h +++ b/content/child/mojo/mojo_application.h @@ -7,7 +7,7 @@ #include "ipc/ipc_platform_file.h" #include "mojo/common/channel_init.h" -#include "mojo/public/interfaces/shell/shell.mojom.h" +#include "mojo/public/interfaces/service_provider/service_provider.mojom.h" namespace IPC { class Message; @@ -24,19 +24,21 @@ class MojoApplication { public: // The ShellClient pointer must remain valid for the lifetime of the // MojoApplication instance. - explicit MojoApplication(mojo::ShellClient* shell_client); + explicit MojoApplication(mojo::ServiceProvider* service_provider); ~MojoApplication(); bool OnMessageReceived(const IPC::Message& msg); - mojo::Shell* shell() { return shell_.get(); } + mojo::ServiceProvider* host_service_provider() { + return host_service_provider_.get(); + } private: void OnActivate(const IPC::PlatformFileForTransit& file); mojo::common::ChannelInit channel_init_; - mojo::ShellPtr shell_; - mojo::ShellClient* shell_client_; + mojo::ServiceProviderPtr host_service_provider_; + mojo::ServiceProvider* service_provider_; DISALLOW_COPY_AND_ASSIGN(MojoApplication); }; diff --git a/content/content_app.gypi b/content/content_app.gypi index 0a873a4..fcb98e9 100644 --- a/content/content_app.gypi +++ b/content/content_app.gypi @@ -68,7 +68,7 @@ 'dependencies': [ '../mojo/mojo.gyp:mojo_environment_chromium', '../mojo/mojo.gyp:mojo_service_manager', - '../mojo/mojo.gyp:mojo_shell_bindings', + '../mojo/mojo.gyp:mojo_service_provider_bindings', '../mojo/mojo.gyp:mojo_system_impl', ], }], diff --git a/content/content_browser.gypi b/content/content_browser.gypi index 710efd9..45ada0a 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -1456,7 +1456,7 @@ '../cc/cc.gyp:cc', '../mojo/mojo.gyp:mojo_cpp_bindings', '../mojo/mojo.gyp:mojo_js_bindings', - '../mojo/mojo.gyp:mojo_shell_bindings', + '../mojo/mojo.gyp:mojo_service_provider_bindings', '../net/net.gyp:http_server', '../third_party/leveldatabase/leveldatabase.gyp:leveldatabase', '../ui/surface/surface.gyp:surface', diff --git a/content/content_child.gypi b/content/content_child.gypi index 126f658..a187223 100644 --- a/content/content_child.gypi +++ b/content/content_child.gypi @@ -7,7 +7,7 @@ '../base/base.gyp:base', '../components/tracing.gyp:tracing', '../mojo/mojo.gyp:mojo_environment_chromium', - '../mojo/mojo.gyp:mojo_shell_bindings', + '../mojo/mojo.gyp:mojo_service_provider_bindings', '../skia/skia.gyp:skia', '../ui/base/ui_base.gyp:ui_base', '../ui/gfx/gfx.gyp:gfx', diff --git a/content/content_gpu.gypi b/content/content_gpu.gypi index 14ae896..4827493 100644 --- a/content/content_gpu.gypi +++ b/content/content_gpu.gypi @@ -5,7 +5,7 @@ { 'dependencies': [ '../base/base.gyp:base', - '../mojo/mojo.gyp:mojo_shell_bindings', + '../mojo/mojo.gyp:mojo_service_provider_bindings', '../skia/skia.gyp:skia', '../ui/gl/gl.gyp:gl', ], diff --git a/content/content_plugin.gypi b/content/content_plugin.gypi index a8fa444..c6baab9 100644 --- a/content/content_plugin.gypi +++ b/content/content_plugin.gypi @@ -6,7 +6,7 @@ 'conditions': [ ['enable_plugins==1 and OS!="linux"', { 'dependencies': [ - '../mojo/mojo.gyp:mojo_shell_bindings', + '../mojo/mojo.gyp:mojo_service_provider_bindings', '../skia/skia.gyp:skia', '../third_party/WebKit/public/blink.gyp:blink', '../third_party/npapi/npapi.gyp:npapi', diff --git a/content/content_ppapi_plugin.gypi b/content/content_ppapi_plugin.gypi index 0757a7d..f79e1bf 100644 --- a/content/content_ppapi_plugin.gypi +++ b/content/content_ppapi_plugin.gypi @@ -7,7 +7,7 @@ ['enable_plugins==1', { 'dependencies': [ '../base/base.gyp:base', - '../mojo/mojo.gyp:mojo_shell_bindings', + '../mojo/mojo.gyp:mojo_service_provider_bindings', '../ppapi/ppapi_internal.gyp:ppapi_ipc', '../ui/base/ui_base.gyp:ui_base', '../ui/gfx/gfx.gyp:gfx', diff --git a/content/content_renderer.gypi b/content/content_renderer.gypi index 294468b..cc549dd 100644 --- a/content/content_renderer.gypi +++ b/content/content_renderer.gypi @@ -10,7 +10,7 @@ '../media/media.gyp:media', '../mojo/mojo.gyp:mojo_environment_chromium', '../mojo/mojo.gyp:mojo_js_bindings_lib', - '../mojo/mojo.gyp:mojo_shell_bindings', + '../mojo/mojo.gyp:mojo_service_provider_bindings', '../net/net.gyp:net', '../skia/skia.gyp:skia', '../third_party/WebKit/public/blink.gyp:blink', @@ -699,7 +699,7 @@ 'renderer/media/webrtc/webrtc_video_track_adapter.cc', 'renderer/media/webrtc/webrtc_video_track_adapter.h', 'renderer/media/webrtc/media_stream_remote_video_source.cc', - 'renderer/media/webrtc/media_stream_remote_video_source.h', + 'renderer/media/webrtc/media_stream_remote_video_source.h', 'renderer/media/webrtc/media_stream_track_metrics.cc', 'renderer/media/webrtc/media_stream_track_metrics.h', 'renderer/media/webrtc/peer_connection_dependency_factory.cc', diff --git a/content/content_utility.gypi b/content/content_utility.gypi index 513c240..2b46f7d 100644 --- a/content/content_utility.gypi +++ b/content/content_utility.gypi @@ -6,7 +6,7 @@ 'dependencies': [ '../base/base.gyp:base', '../courgette/courgette.gyp:courgette_lib', - '../mojo/mojo.gyp:mojo_shell_bindings', + '../mojo/mojo.gyp:mojo_service_provider_bindings', ], 'sources': [ 'public/utility/content_utility_client.cc', diff --git a/content/content_worker.gypi b/content/content_worker.gypi index 5264a2c..a04b662 100644 --- a/content/content_worker.gypi +++ b/content/content_worker.gypi @@ -5,7 +5,7 @@ { 'dependencies': [ '../base/base.gyp:base', - '../mojo/mojo.gyp:mojo_shell_bindings', + '../mojo/mojo.gyp:mojo_service_provider_bindings', '../skia/skia.gyp:skia', '../third_party/WebKit/public/blink.gyp:blink', ], diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc index 3978505..0ba3585 100644 --- a/content/renderer/render_thread_impl.cc +++ b/content/renderer/render_thread_impl.cc @@ -1178,7 +1178,7 @@ scoped_ptr<gfx::GpuMemoryBuffer> RenderThreadImpl::AllocateGpuMemoryBuffer( .PassAs<gfx::GpuMemoryBuffer>(); } -void RenderThreadImpl::AcceptConnection( +void RenderThreadImpl::ConnectToService( const mojo::String& service_name, mojo::ScopedMessagePipeHandle message_pipe) { // TODO(darin): Invent some kind of registration system to use here. diff --git a/content/renderer/render_thread_impl.h b/content/renderer/render_thread_impl.h index e74f4c1..d6c3a89 100644 --- a/content/renderer/render_thread_impl.h +++ b/content/renderer/render_thread_impl.h @@ -416,8 +416,8 @@ class CONTENT_EXPORT RenderThreadImpl : public RenderThread, unsigned internalformat, unsigned usage) OVERRIDE; - // mojo::ShellClient implementation: - virtual void AcceptConnection( + // mojo::ServiceProvider implementation: + virtual void ConnectToService( const mojo::String& service_name, mojo::ScopedMessagePipeHandle message_pipe) OVERRIDE; diff --git a/mojo/apps/js/main.js b/mojo/apps/js/main.js index a3b3dd2..a216126 100644 --- a/mojo/apps/js/main.js +++ b/mojo/apps/js/main.js @@ -11,7 +11,7 @@ define([ 'mojo/apps/js/bindings/gl', 'mojo/apps/js/bindings/threading', 'mojo/services/native_viewport/native_viewport.mojom', - 'mojo/public/interfaces/shell/shell.mojom', + 'mojo/public/interfaces/service_provider/service_provider.mojom', ], function(console, monotonicClock, timer, @@ -20,7 +20,7 @@ define([ gljs, threading, nativeViewport, - shell) { + service_provider) { const VERTEX_SHADER_SOURCE = [ 'uniform mat4 u_mvpMatrix;', @@ -276,11 +276,12 @@ define([ return cubeIndices.length; } - function SampleApp(shell) { - this.shell_ = shell; + function SampleApp(service_provider) { + this.service_provider_ = service_provider; var pipe = new core.createMessagePipe(); - this.shell_.connect('mojo:mojo_native_viewport_service', pipe.handle1); + this.service_provider_.connect('mojo:mojo_native_viewport_service', + pipe.handle1); new connection.Connection(pipe.handle0, NativeViewportClientImpl, nativeViewport.NativeViewportProxy); } @@ -288,7 +289,8 @@ define([ // have a 'client' object that contains both the sending and receiving bits of // the client side of the interface. Since JS is loosely typed, we do not need // a separate base class to inherit from to receive callbacks. - SampleApp.prototype = Object.create(shell.ShellClientStub.prototype); + SampleApp.prototype = + Object.create(service_provider.ServiceProviderStub.prototype); function NativeViewportClientImpl(remote) { @@ -390,6 +392,7 @@ define([ return function(handle) { - new connection.Connection(handle, SampleApp, shell.ShellProxy); + new connection.Connection( + handle, SampleApp, service_provider.ServiceProviderProxy); }; }); diff --git a/mojo/dbus/dbus_external_service.cc b/mojo/dbus/dbus_external_service.cc index 92cd6f3..3b1fddf 100644 --- a/mojo/dbus/dbus_external_service.cc +++ b/mojo/dbus/dbus_external_service.cc @@ -15,9 +15,9 @@ #include "dbus/message.h" #include "dbus/object_path.h" #include "mojo/common/channel_init.h" +#include "mojo/public/cpp/application/application.h" #include "mojo/public/cpp/bindings/error_handler.h" -#include "mojo/public/cpp/shell/application.h" -#include "mojo/public/interfaces/shell/shell.mojom.h" +#include "mojo/public/interfaces/service_provider/service_provider.mojom.h" #include "mojo/shell/external_service.mojom.h" namespace mojo { diff --git a/mojo/dbus/dbus_external_service.h b/mojo/dbus/dbus_external_service.h index ea72222..54af5e9 100644 --- a/mojo/dbus/dbus_external_service.h +++ b/mojo/dbus/dbus_external_service.h @@ -8,8 +8,8 @@ #include "dbus/message.h" #include "dbus/object_path.h" #include "mojo/common/channel_init.h" -#include "mojo/public/cpp/shell/application.h" -#include "mojo/public/interfaces/shell/shell.mojom.h" +#include "mojo/public/cpp/application/application.h" +#include "mojo/public/interfaces/service_provider/service_provider.mojom.h" #include "mojo/shell/external_service.mojom.h" namespace mojo { @@ -72,8 +72,9 @@ class DBusExternalService : public DBusExternalServiceBase { virtual void OnConnectionError() OVERRIDE { service_->Disconnect(); } - virtual void Activate(ScopedMessagePipeHandle shell_handle) OVERRIDE { - app_.reset(new Application(shell_handle.Pass())); + virtual void Activate(ScopedMessagePipeHandle service_provider_handle) + OVERRIDE { + app_.reset(new Application(service_provider_handle.Pass())); app_->AddService<ServiceImpl>(); } private: diff --git a/mojo/examples/aura_demo/aura_demo.cc b/mojo/examples/aura_demo/aura_demo.cc index 9927eeb..7e4ec8c 100644 --- a/mojo/examples/aura_demo/aura_demo.cc +++ b/mojo/examples/aura_demo/aura_demo.cc @@ -10,11 +10,11 @@ #include "base/message_loop/message_loop.h" #include "mojo/aura/screen_mojo.h" #include "mojo/aura/window_tree_host_mojo.h" +#include "mojo/public/cpp/application/application.h" #include "mojo/public/cpp/bindings/allocation_scope.h" #include "mojo/public/cpp/gles2/gles2.h" -#include "mojo/public/cpp/shell/application.h" #include "mojo/public/cpp/system/core.h" -#include "mojo/public/interfaces/shell/shell.mojom.h" +#include "mojo/public/interfaces/service_provider/service_provider.mojom.h" #include "mojo/services/native_viewport/native_viewport.mojom.h" #include "ui/aura/client/default_capture_client.h" #include "ui/aura/client/window_tree_client.h" @@ -113,7 +113,8 @@ class DemoWindowTreeClient : public aura::client::WindowTreeClient { class AuraDemo : public Application { public: - explicit AuraDemo(MojoHandle shell_handle) : Application(shell_handle) { + explicit AuraDemo(MojoHandle service_provider_handle) + : Application(service_provider_handle) { screen_.reset(ScreenMojo::Create()); gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); @@ -176,7 +177,7 @@ class AuraDemo : public Application { } // namespace mojo extern "C" AURA_DEMO_EXPORT MojoResult CDECL MojoMain( - MojoHandle shell_handle) { + MojoHandle service_provider_handle) { base::CommandLine::Init(0, NULL); base::AtExitManager at_exit; base::MessageLoop loop; @@ -186,7 +187,7 @@ extern "C" AURA_DEMO_EXPORT MojoResult CDECL MojoMain( // MessageLoop is not of TYPE_UI. I think we need a way to build // Aura that doesn't define platform-specific stuff. aura::Env::CreateInstance(true); - mojo::examples::AuraDemo app(shell_handle); + mojo::examples::AuraDemo app(service_provider_handle); loop.Run(); return MOJO_RESULT_OK; diff --git a/mojo/examples/compositor_app/compositor_app.cc b/mojo/examples/compositor_app/compositor_app.cc index f927cc2..c225fae 100644 --- a/mojo/examples/compositor_app/compositor_app.cc +++ b/mojo/examples/compositor_app/compositor_app.cc @@ -9,11 +9,11 @@ #include "base/message_loop/message_loop.h" #include "mojo/examples/compositor_app/compositor_host.h" #include "mojo/geometry/geometry_type_converters.h" +#include "mojo/public/cpp/application/application.h" #include "mojo/public/cpp/bindings/allocation_scope.h" #include "mojo/public/cpp/gles2/gles2.h" -#include "mojo/public/cpp/shell/application.h" #include "mojo/public/cpp/system/core.h" -#include "mojo/public/interfaces/shell/shell.mojom.h" +#include "mojo/public/interfaces/service_provider/service_provider.mojom.h" #include "mojo/services/native_viewport/native_viewport.mojom.h" #include "ui/gfx/rect.h" @@ -32,7 +32,8 @@ namespace examples { class SampleApp : public Application, public NativeViewportClient { public: - explicit SampleApp(MojoHandle shell_handle) : Application(shell_handle) { + explicit SampleApp(MojoHandle service_provider_handle) + : Application(service_provider_handle) { AllocationScope scope; ConnectTo("mojo:mojo_native_viewport_service", &viewport_); @@ -71,11 +72,11 @@ class SampleApp : public Application, public NativeViewportClient { } // namespace mojo extern "C" SAMPLE_APP_EXPORT MojoResult CDECL MojoMain( - MojoHandle shell_handle) { + MojoHandle service_provider_handle) { base::MessageLoop loop; mojo::GLES2Initializer gles2; - mojo::examples::SampleApp app(shell_handle); + mojo::examples::SampleApp app(service_provider_handle); loop.Run(); return MOJO_RESULT_OK; } diff --git a/mojo/examples/dbus_echo/dbus_echo_app.cc b/mojo/examples/dbus_echo/dbus_echo_app.cc index 13bf8e0..f9b9433 100644 --- a/mojo/examples/dbus_echo/dbus_echo_app.cc +++ b/mojo/examples/dbus_echo/dbus_echo_app.cc @@ -7,13 +7,13 @@ #include "base/bind.h" #include "base/logging.h" +#include "mojo/public/cpp/application/application.h" #include "mojo/public/cpp/bindings/allocation_scope.h" #include "mojo/public/cpp/environment/environment.h" -#include "mojo/public/cpp/shell/application.h" #include "mojo/public/cpp/system/core.h" #include "mojo/public/cpp/system/macros.h" #include "mojo/public/cpp/utility/run_loop.h" -#include "mojo/public/interfaces/shell/shell.mojom.h" +#include "mojo/public/interfaces/service_provider/service_provider.mojom.h" #include "mojo/services/dbus_echo/echo.mojom.h" #if defined(WIN32) @@ -31,7 +31,8 @@ namespace examples { class DBusEchoApp : public Application { public: - explicit DBusEchoApp(MojoHandle shell_handle) : Application(shell_handle) { + explicit DBusEchoApp(MojoHandle service_provider_handle) + : Application(service_provider_handle) { ConnectTo("dbus:org.chromium.EchoService/org/chromium/MojoImpl", &echo_service_); @@ -55,11 +56,11 @@ class DBusEchoApp : public Application { } // namespace mojo extern "C" DBUS_ECHO_APP_EXPORT MojoResult CDECL MojoMain( - MojoHandle shell_handle) { + MojoHandle service_provider_handle) { mojo::Environment env; mojo::RunLoop loop; - mojo::examples::DBusEchoApp app(shell_handle); + mojo::examples::DBusEchoApp app(service_provider_handle); loop.Run(); return MOJO_RESULT_OK; } diff --git a/mojo/examples/launcher/launcher.cc b/mojo/examples/launcher/launcher.cc index 400689f..bc8ccfd 100644 --- a/mojo/examples/launcher/launcher.cc +++ b/mojo/examples/launcher/launcher.cc @@ -15,11 +15,11 @@ #include "mojo/aura/screen_mojo.h" #include "mojo/aura/window_tree_host_mojo.h" #include "mojo/examples/launcher/launcher.mojom.h" +#include "mojo/public/cpp/application/application.h" #include "mojo/public/cpp/bindings/allocation_scope.h" #include "mojo/public/cpp/gles2/gles2.h" -#include "mojo/public/cpp/shell/application.h" #include "mojo/public/cpp/system/core.h" -#include "mojo/public/interfaces/shell/shell.mojom.h" +#include "mojo/public/interfaces/service_provider/service_provider.mojom.h" #include "mojo/services/native_viewport/native_viewport.mojom.h" #include "ui/aura/client/aura_constants.h" #include "ui/aura/client/default_capture_client.h" @@ -266,7 +266,7 @@ class LauncherImpl : public InterfaceImpl<Launcher>, } // namespace mojo extern "C" LAUNCHER_EXPORT MojoResult CDECL MojoMain( - MojoHandle shell_handle) { + MojoHandle service_provider_handle) { base::CommandLine::Init(0, NULL); base::AtExitManager at_exit; base::i18n::InitializeICU(); @@ -285,7 +285,7 @@ extern "C" LAUNCHER_EXPORT MojoResult CDECL MojoMain( // Aura that doesn't define platform-specific stuff. aura::Env::CreateInstance(true); - mojo::Application app(shell_handle); + mojo::Application app(service_provider_handle); app.AddService<mojo::examples::LauncherImpl>(&app); loop.Run(); diff --git a/mojo/examples/pepper_container_app/pepper_container_app.cc b/mojo/examples/pepper_container_app/pepper_container_app.cc index d2aab41..e678613 100644 --- a/mojo/examples/pepper_container_app/pepper_container_app.cc +++ b/mojo/examples/pepper_container_app/pepper_container_app.cc @@ -11,12 +11,12 @@ #include "mojo/examples/pepper_container_app/plugin_instance.h" #include "mojo/examples/pepper_container_app/plugin_module.h" #include "mojo/examples/pepper_container_app/type_converters.h" +#include "mojo/public/cpp/application/application.h" #include "mojo/public/cpp/bindings/allocation_scope.h" #include "mojo/public/cpp/environment/environment.h" #include "mojo/public/cpp/gles2/gles2.h" -#include "mojo/public/cpp/shell/application.h" #include "mojo/public/cpp/system/core.h" -#include "mojo/public/interfaces/shell/shell.mojom.h" +#include "mojo/public/interfaces/service_provider/service_provider.mojom.h" #include "mojo/services/native_viewport/native_viewport.mojom.h" #include "ppapi/c/pp_rect.h" #include "ppapi/shared_impl/proxy_lock.h" @@ -38,8 +38,8 @@ class PepperContainerApp: public Application, public NativeViewportClient, public MojoPpapiGlobals::Delegate { public: - explicit PepperContainerApp(MojoHandle shell_handle) - : Application(shell_handle), + explicit PepperContainerApp(MojoHandle service_provider_handle) + : Application(service_provider_handle), ppapi_globals_(this), plugin_module_(new PluginModule) { mojo::AllocationScope scope; @@ -120,11 +120,11 @@ class PepperContainerApp: public Application, } // namespace mojo extern "C" PEPPER_CONTAINER_APP_EXPORT MojoResult CDECL MojoMain( - MojoHandle shell_handle) { + MojoHandle service_provider_handle) { mojo::Environment env; mojo::GLES2Initializer gles2; base::MessageLoop run_loop; - mojo::examples::PepperContainerApp app(shell_handle); + mojo::examples::PepperContainerApp app(service_provider_handle); run_loop.Run(); return MOJO_RESULT_OK; diff --git a/mojo/examples/sample_app/sample_app.cc b/mojo/examples/sample_app/sample_app.cc index 6524215..74b9d99 100644 --- a/mojo/examples/sample_app/sample_app.cc +++ b/mojo/examples/sample_app/sample_app.cc @@ -6,14 +6,14 @@ #include <string> #include "mojo/examples/sample_app/gles2_client_impl.h" +#include "mojo/public/cpp/application/application.h" #include "mojo/public/cpp/bindings/allocation_scope.h" #include "mojo/public/cpp/environment/environment.h" #include "mojo/public/cpp/gles2/gles2.h" -#include "mojo/public/cpp/shell/application.h" #include "mojo/public/cpp/system/core.h" #include "mojo/public/cpp/system/macros.h" #include "mojo/public/cpp/utility/run_loop.h" -#include "mojo/public/interfaces/shell/shell.mojom.h" +#include "mojo/public/interfaces/service_provider/service_provider.mojom.h" #include "mojo/services/native_viewport/native_viewport.mojom.h" #if defined(WIN32) @@ -31,7 +31,8 @@ namespace examples { class SampleApp : public Application, public NativeViewportClient { public: - explicit SampleApp(MojoHandle shell_handle) : Application(shell_handle) { + explicit SampleApp(MojoHandle service_provider_handle) + : Application(service_provider_handle) { ConnectTo("mojo:mojo_native_viewport_service", &viewport_); viewport_.set_client(this); @@ -86,12 +87,12 @@ class SampleApp : public Application, public NativeViewportClient { } // namespace mojo extern "C" SAMPLE_APP_EXPORT MojoResult CDECL MojoMain( - MojoHandle shell_handle) { + MojoHandle service_provider_handle) { mojo::Environment env; mojo::RunLoop loop; mojo::GLES2Initializer gles2; - mojo::examples::SampleApp app(shell_handle); + mojo::examples::SampleApp app(service_provider_handle); loop.Run(); return MOJO_RESULT_OK; } diff --git a/mojo/examples/sample_view_manager_app/sample_view_manager_app.cc b/mojo/examples/sample_view_manager_app/sample_view_manager_app.cc index 10d16a8..0188fb2 100644 --- a/mojo/examples/sample_view_manager_app/sample_view_manager_app.cc +++ b/mojo/examples/sample_view_manager_app/sample_view_manager_app.cc @@ -6,8 +6,8 @@ #include "base/bind.h" #include "base/command_line.h" #include "base/message_loop/message_loop.h" +#include "mojo/public/cpp/application/application.h" #include "mojo/public/cpp/environment/environment.h" -#include "mojo/public/cpp/shell/application.h" #include "mojo/public/cpp/system/core.h" #include "mojo/public/cpp/system/macros.h" #include "mojo/public/cpp/utility/run_loop.h" @@ -31,9 +31,9 @@ namespace examples { class SampleApp : public Application { public: - explicit SampleApp(MojoHandle shell_handle) - : Application(shell_handle) { - view_manager_.reset(new view_manager::ViewManager(shell())); + explicit SampleApp(MojoHandle service_provider_handle) + : Application(service_provider_handle) { + view_manager_.reset(new view_manager::ViewManager(service_provider())); view_manager_->Init(); view_manager::ViewTreeNode* node1 = view_manager::ViewTreeNode::Create(view_manager_.get()); @@ -67,10 +67,10 @@ class SampleApp : public Application { } // namespace mojo extern "C" SAMPLE_APP_EXPORT MojoResult CDECL MojoMain( - MojoHandle shell_handle) { + MojoHandle service_provider_handle) { base::MessageLoop loop; - mojo::examples::SampleApp app(shell_handle); + mojo::examples::SampleApp app(service_provider_handle); loop.Run(); return MOJO_RESULT_OK; } diff --git a/mojo/mojo.gyp b/mojo/mojo.gyp index 3893b6b..5bbe9bf 100644 --- a/mojo/mojo.gyp +++ b/mojo/mojo.gyp @@ -422,7 +422,7 @@ '../url/url.gyp:url_lib', 'mojo_common_lib', 'mojo_environment_chromium', - 'mojo_shell_bindings', + 'mojo_service_provider_bindings', 'mojo_system_impl', ], 'sources': [ @@ -435,7 +435,7 @@ ], 'export_dependent_settings': [ '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations', - 'mojo_shell_bindings', + 'mojo_service_provider_bindings', ], }, { @@ -484,7 +484,7 @@ 'mojo_external_service_bindings', 'mojo_gles2_impl', 'mojo_service_manager', - 'mojo_shell_bindings', + 'mojo_service_provider_bindings', 'mojo_system_impl', 'mojo_native_viewport_service', 'mojo_spy', @@ -549,7 +549,7 @@ # These are only necessary as long as we hard code use of ViewManager. '../skia/skia.gyp:skia', 'mojo_gles2', - 'mojo_shell_client', + 'mojo_application', 'mojo_view_manager', 'mojo_view_manager_bindings', ], @@ -606,7 +606,7 @@ 'mojo_environment_chromium', 'mojo_run_all_unittests', 'mojo_service_manager', - 'mojo_shell_client', + 'mojo_application', ], 'variables': { 'mojom_base_output_dir': 'mojo', @@ -730,7 +730,7 @@ 'mojo_common_lib', 'mojo_environment_chromium', 'mojo_jni_headers', - 'mojo_shell_bindings', + 'mojo_service_provider_bindings', 'mojo_shell_lib', ], 'sources': [ @@ -810,7 +810,7 @@ 'mojo_common_lib', 'mojo_environment_chromium', 'mojo_jni_headers', - 'mojo_shell_bindings', + 'mojo_service_provider_bindings', 'mojo_shell_lib', ], 'sources': [ @@ -849,7 +849,7 @@ '../dbus/dbus.gyp:dbus', 'mojo_common_lib', 'mojo_external_service_bindings', - 'mojo_shell_client', + 'mojo_application', 'mojo_system_impl', ], 'sources': [ diff --git a/mojo/mojo_examples.gypi b/mojo/mojo_examples.gypi index 10c7ba28..da07826 100644 --- a/mojo/mojo_examples.gypi +++ b/mojo/mojo_examples.gypi @@ -16,7 +16,7 @@ 'mojo_geometry_bindings', 'mojo_gles2', 'mojo_native_viewport_bindings', - 'mojo_shell_client', + 'mojo_application', 'mojo_system', 'mojo_utility', ], @@ -50,7 +50,7 @@ 'mojo_geometry_lib', 'mojo_gles2', 'mojo_native_viewport_bindings', - 'mojo_shell_client', + 'mojo_application', 'mojo_system_impl', ], 'sources': [ @@ -80,7 +80,7 @@ 'mojo_geometry_bindings', 'mojo_gles2', 'mojo_native_viewport_bindings', - 'mojo_shell_client', + 'mojo_application', 'mojo_system_impl', ], 'defines': [ @@ -180,7 +180,7 @@ 'mojo_geometry_bindings', 'mojo_geometry_lib', 'mojo_gles2', - 'mojo_shell_client', + 'mojo_application', 'mojo_system_impl' ], 'sources': [ @@ -233,7 +233,7 @@ 'mojo_geometry_lib', 'mojo_gles2', 'mojo_launcher_bindings', - 'mojo_shell_client', + 'mojo_application', 'mojo_system_impl', ], 'sources': [ @@ -261,7 +261,7 @@ 'mojo_geometry_bindings', 'mojo_gles2', 'mojo_view_manager_lib', - 'mojo_shell_client', + 'mojo_application', 'mojo_system_impl', 'mojo_utility', ], @@ -281,7 +281,7 @@ 'mojo_cpp_bindings', 'mojo_environment_standalone', 'mojo_echo_bindings', - 'mojo_shell_client', + 'mojo_application', 'mojo_system', 'mojo_utility', ], diff --git a/mojo/mojo_public.gypi b/mojo/mojo_public.gypi index 4bee9a3..2f36963 100644 --- a/mojo/mojo_public.gypi +++ b/mojo/mojo_public.gypi @@ -364,10 +364,10 @@ ], }, { - 'target_name': 'mojo_shell_bindings', + 'target_name': 'mojo_service_provider_bindings', 'type': 'static_library', 'sources': [ - 'public/interfaces/shell/shell.mojom', + 'public/interfaces/service_provider/service_provider.mojom', ], 'variables': { 'mojom_base_output_dir': 'mojo', @@ -381,20 +381,20 @@ ], }, { - 'target_name': 'mojo_shell_client', + 'target_name': 'mojo_application', 'type': 'static_library', 'sources': [ - 'public/cpp/shell/application.h', - 'public/cpp/shell/connect.h', - 'public/cpp/shell/lib/application.cc', - 'public/cpp/shell/lib/service_connector.cc', - 'public/cpp/shell/lib/service_connector.h', + 'public/cpp/application/application.h', + 'public/cpp/application/connect.h', + 'public/cpp/application/lib/application.cc', + 'public/cpp/application/lib/service_connector.cc', + 'public/cpp/application/lib/service_connector.h', ], 'dependencies': [ - 'mojo_shell_bindings', + 'mojo_service_provider_bindings', ], 'export_dependent_settings': [ - 'mojo_shell_bindings', + 'mojo_service_provider_bindings', ], }, ], diff --git a/mojo/mojo_services.gypi b/mojo/mojo_services.gypi index f8cc58d..b053605 100644 --- a/mojo/mojo_services.gypi +++ b/mojo/mojo_services.gypi @@ -91,7 +91,7 @@ 'mojo_geometry_lib', 'mojo_gles2_service', 'mojo_native_viewport_bindings', - 'mojo_shell_client', + 'mojo_application', 'mojo_system_impl', ], 'defines': [ @@ -155,7 +155,7 @@ '../ui/gfx/gfx.gyp:gfx_geometry', 'mojo_geometry_bindings', 'mojo_geometry_lib', - 'mojo_shell_bindings', + 'mojo_service_provider_bindings', 'mojo_view_manager_bindings', 'mojo_view_manager_common', ], @@ -236,7 +236,7 @@ 'mojo_gles2', 'mojo_launcher_bindings', 'mojo_native_viewport_bindings', - 'mojo_shell_client', + 'mojo_application', 'mojo_system_impl', 'mojo_view_manager_bindings', 'mojo_view_manager_common', @@ -289,7 +289,7 @@ 'mojo_environment_chromium', 'mojo_geometry_bindings', 'mojo_geometry_lib', - 'mojo_shell_client', + 'mojo_application', 'mojo_shell_test_support', 'mojo_system_impl', 'mojo_view_manager_bindings', @@ -322,7 +322,7 @@ 'mojo_dbus_service', 'mojo_echo_bindings', 'mojo_environment_chromium', - 'mojo_shell_client', + 'mojo_application', 'mojo_system_impl', ], 'sources': [ diff --git a/mojo/public/cpp/shell/DEPS b/mojo/public/cpp/application/DEPS index 7432ab1..a0e2b06 100644 --- a/mojo/public/cpp/shell/DEPS +++ b/mojo/public/cpp/application/DEPS @@ -1,4 +1,4 @@ include_rules = [ "+mojo/public/cpp/bindings", - "+mojo/public/interfaces/shell", + "+mojo/public/interfaces/service_provider", ] diff --git a/mojo/public/cpp/shell/application.h b/mojo/public/cpp/application/application.h index 3e016d1..58e9d05 100644 --- a/mojo/public/cpp/shell/application.h +++ b/mojo/public/cpp/application/application.h @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef MOJO_PUBLIC_SHELL_APPLICATION_H_ -#define MOJO_PUBLIC_SHELL_APPLICATION_H_ +#ifndef MOJO_PUBLIC_APPLICATION_APPLICATION_H_ +#define MOJO_PUBLIC_APPLICATION_APPLICATION_H_ #include <vector> -#include "mojo/public/cpp/shell/connect.h" -#include "mojo/public/cpp/shell/lib/service_connector.h" +#include "mojo/public/cpp/application/connect.h" +#include "mojo/public/cpp/application/lib/service_connector.h" #include "mojo/public/cpp/system/core.h" -#include "mojo/public/interfaces/shell/shell.mojom.h" +#include "mojo/public/interfaces/service_provider/service_provider.mojom.h" namespace mojo { -// Utility class for creating ShellClients that vend service instances. +// Utility class for creating ServiceProviders that vend service instances. // To use define a class that implements your specific server api, e.g. FooImpl // to implement a service named Foo. // That class must subclass an InterfaceImpl specialization. @@ -40,7 +40,7 @@ namespace mojo { // // Create an Application instance that collects any service implementations. // -// Application app(shell_handle); +// Application app(service_provider_handle); // app.AddService<FooImpl>(); // // BarContext context; @@ -49,8 +49,8 @@ namespace mojo { // class Application : public internal::ServiceConnectorBase::Owner { public: - explicit Application(ScopedMessagePipeHandle shell_handle); - explicit Application(MojoHandle shell_handle); + explicit Application(ScopedMessagePipeHandle service_provider_handle); + explicit Application(MojoHandle service_provider_handle); virtual ~Application(); template <typename Impl, typename Context> @@ -64,15 +64,16 @@ class Application : public internal::ServiceConnectorBase::Owner { } template <typename Interface> - void ConnectTo(const std::string& url, InterfacePtr<Interface>* ptr) { - mojo::ConnectTo(shell(), url, ptr); + void ConnectTo(const std::string& url, + InterfacePtr<Interface>* ptr) { + mojo::ConnectToService(service_provider(), url, ptr); } protected: - // ShellClient methods. + // ServiceProvider methods. // Override this to dispatch to correct service when there's more than one. // TODO(davemoore): Augment this with name registration. - virtual void AcceptConnection(const mojo::String& url, + virtual void ConnectToService(const mojo::String& url, ScopedMessagePipeHandle client_handle) MOJO_OVERRIDE; @@ -90,4 +91,4 @@ class Application : public internal::ServiceConnectorBase::Owner { } // namespace mojo -#endif // MOJO_PUBLIC_SHELL_APPLICATION_H_ +#endif // MOJO_PUBLIC_APPLICATION_APPLICATION_H_ diff --git a/mojo/public/cpp/application/connect.h b/mojo/public/cpp/application/connect.h new file mode 100644 index 0000000..1f81dea --- /dev/null +++ b/mojo/public/cpp/application/connect.h @@ -0,0 +1,26 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef MOJO_PUBLIC_CPP_APPLICATION_CONNECT_H_ +#define MOJO_PUBLIC_CPP_APPLICATION_CONNECT_H_ + +#include "mojo/public/cpp/bindings/allocation_scope.h" +#include "mojo/public/interfaces/service_provider/service_provider.mojom.h" + +namespace mojo { + +template <typename Interface> +inline void ConnectToService(ServiceProvider* service_provider, + const std::string& url, + InterfacePtr<Interface>* ptr) { + MessagePipe pipe; + ptr->Bind(pipe.handle0.Pass()); + + AllocationScope scope; + service_provider->ConnectToService(url, pipe.handle1.Pass()); +} + +} // namespace mojo + +#endif // MOJO_PUBLIC_CPP_APPLICATION_CONNECT_H_ diff --git a/mojo/public/cpp/shell/lib/application.cc b/mojo/public/cpp/application/lib/application.cc index 161e4e0..72ce5802 100644 --- a/mojo/public/cpp/shell/lib/application.cc +++ b/mojo/public/cpp/application/lib/application.cc @@ -2,17 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "mojo/public/cpp/shell/application.h" +#include "mojo/public/cpp/application/application.h" namespace mojo { -Application::Application(ScopedMessagePipeHandle shell_handle) - : internal::ServiceConnectorBase::Owner(shell_handle.Pass()) { +Application::Application(ScopedMessagePipeHandle service_provider_handle) + : internal::ServiceConnectorBase::Owner(service_provider_handle.Pass()) { } -Application::Application(MojoHandle shell_handle) +Application::Application(MojoHandle service_provider_handle) : internal::ServiceConnectorBase::Owner( - mojo::MakeScopedHandle(MessagePipeHandle(shell_handle)).Pass()) {} + mojo::MakeScopedHandle( + MessagePipeHandle(service_provider_handle)).Pass()) {} Application::~Application() { for (ServiceConnectorList::iterator it = service_connectors_.begin(); @@ -38,16 +39,16 @@ void Application::RemoveServiceConnector( } } if (service_connectors_.empty()) - shell_.reset(); + service_provider_.reset(); } -void Application::AcceptConnection(const mojo::String& url, +void Application::ConnectToService(const mojo::String& url, ScopedMessagePipeHandle client_handle) { // TODO(davemoore): This method must be overridden by an Application subclass // to dispatch to the right ServiceConnector. We need to figure out an // approach to registration to make this better. assert(1 == service_connectors_.size()); - return service_connectors_.front()->AcceptConnection(url.To<std::string>(), + return service_connectors_.front()->ConnectToService(url.To<std::string>(), client_handle.Pass()); } diff --git a/mojo/public/cpp/shell/lib/service_connector.cc b/mojo/public/cpp/application/lib/service_connector.cc index bdd1f3f..10bda99 100644 --- a/mojo/public/cpp/shell/lib/service_connector.cc +++ b/mojo/public/cpp/application/lib/service_connector.cc @@ -2,14 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "mojo/public/cpp/shell/lib/service_connector.h" +#include "mojo/public/cpp/application/lib/service_connector.h" namespace mojo { namespace internal { -ServiceConnectorBase::Owner::Owner(ScopedMessagePipeHandle shell_handle) { - shell_.Bind(shell_handle.Pass()); - shell_.set_client(this); +ServiceConnectorBase::Owner::Owner( + ScopedMessagePipeHandle service_provider_handle) { + service_provider_.Bind(service_provider_handle.Pass()); + service_provider_.set_client(this); } ServiceConnectorBase::Owner::~Owner() {} diff --git a/mojo/public/cpp/shell/lib/service_connector.h b/mojo/public/cpp/application/lib/service_connector.h index 421cb72..8dda334 100644 --- a/mojo/public/cpp/shell/lib/service_connector.h +++ b/mojo/public/cpp/application/lib/service_connector.h @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef MOJO_PUBLIC_CPP_SHELL_LIB_SERVICE_CONNECTOR_H_ -#define MOJO_PUBLIC_CPP_SHELL_LIB_SERVICE_CONNECTOR_H_ +#ifndef MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_CONNECTOR_H_ +#define MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_CONNECTOR_H_ #include <assert.h> #include <vector> #include "mojo/public/cpp/bindings/allocation_scope.h" -#include "mojo/public/interfaces/shell/shell.mojom.h" +#include "mojo/public/interfaces/service_provider/service_provider.mojom.h" namespace mojo { namespace internal { @@ -61,11 +61,11 @@ struct ServiceConstructor<ServiceImpl, void> { class ServiceConnectorBase { public: - class Owner : public ShellClient { + class Owner : public ServiceProvider { public: - Owner(ScopedMessagePipeHandle shell_handle); + Owner(ScopedMessagePipeHandle service_provider_handle); virtual ~Owner(); - Shell* shell() { return shell_.get(); } + ServiceProvider* service_provider() { return service_provider_.get(); } virtual void AddServiceConnector( internal::ServiceConnectorBase* service_connector) = 0; virtual void RemoveServiceConnector( @@ -76,12 +76,12 @@ class ServiceConnectorBase { Owner* owner) { service_connector->owner_ = owner; } - ShellPtr shell_; + ServiceProviderPtr service_provider_; }; ServiceConnectorBase() : owner_(NULL) {} virtual ~ServiceConnectorBase(); - Shell* shell() { return owner_->shell(); } - virtual void AcceptConnection(const std::string& url, + ServiceProvider* service_provider() { return owner_->service_provider(); } + virtual void ConnectToService(const std::string& url, ScopedMessagePipeHandle client_handle) = 0; protected: @@ -103,7 +103,7 @@ class ServiceConnector : public internal::ServiceConnectorBase { assert(connections_.empty()); // No one should have added more! } - virtual void AcceptConnection(const std::string& url, + virtual void ConnectToService(const std::string& url, ScopedMessagePipeHandle handle) MOJO_OVERRIDE { ServiceConnection<ServiceImpl, Context>* impl = ServiceConstructor<ServiceImpl, Context>::New(context_); @@ -138,4 +138,4 @@ class ServiceConnector : public internal::ServiceConnectorBase { } // namespace internal } // namespace mojo -#endif // MOJO_PUBLIC_CPP_SHELL_LIB_SERVICE_CONNECTOR_H_ +#endif // MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_CONNECTOR_H_ diff --git a/mojo/public/cpp/shell/connect.h b/mojo/public/cpp/shell/connect.h deleted file mode 100644 index caee589..0000000 --- a/mojo/public/cpp/shell/connect.h +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef MOJO_PUBLIC_CPP_SHELL_CONNECT_H_ -#define MOJO_PUBLIC_CPP_SHELL_CONNECT_H_ - -#include "mojo/public/cpp/bindings/allocation_scope.h" -#include "mojo/public/interfaces/shell/shell.mojom.h" - -namespace mojo { - -template <typename Interface> -inline void ConnectTo(Shell* shell, const std::string& url, - InterfacePtr<Interface>* ptr) { - MessagePipe pipe; - ptr->Bind(pipe.handle0.Pass()); - - AllocationScope scope; - shell->Connect(url, pipe.handle1.Pass()); -} - -} // namespace mojo - -#endif // MOJO_PUBLIC_CPP_SHELL_CONNECT_H_ diff --git a/mojo/public/interfaces/shell/shell.mojom b/mojo/public/interfaces/service_provider/service_provider.mojom index e5f6c39..85484eb 100644 --- a/mojo/public/interfaces/shell/shell.mojom +++ b/mojo/public/interfaces/service_provider/service_provider.mojom @@ -4,15 +4,13 @@ module mojo { -[Client=ShellClient] -interface Shell { +// ServiceProviders can forward requests to their clients. The relationship +// is symetrical. +[Client=ServiceProvider] +interface ServiceProvider { // Loads url. mojo:{service} will result in the user of the value of the // --origin flag to the shell being used. - Connect(string url, handle<message_pipe> client_handle); -}; - -interface ShellClient { - AcceptConnection(string url, handle<message_pipe> client_handle); + ConnectToService(string url, handle<message_pipe> client_handle); }; } diff --git a/mojo/service_manager/background_service_loader.cc b/mojo/service_manager/background_service_loader.cc index 16004ca..96a2c43 100644 --- a/mojo/service_manager/background_service_loader.cc +++ b/mojo/service_manager/background_service_loader.cc @@ -16,8 +16,8 @@ class BackgroundServiceLoader::BackgroundLoader { void LoadService(ServiceManager* manager, const GURL& url, - ScopedMessagePipeHandle shell_handle) { - loader_->LoadService(manager, url, shell_handle.Pass()); + ScopedMessagePipeHandle service_provider_handle) { + loader_->LoadService(manager, url, service_provider_handle.Pass()); } void OnServiceError(ServiceManager* manager, const GURL& url) { @@ -80,10 +80,11 @@ void BackgroundServiceLoader::OnServiceError(ServiceManager* manager, void BackgroundServiceLoader::LoadServiceOnBackgroundThread( ServiceManager* manager, const GURL& url, - ScopedMessagePipeHandle* shell_handle) { + ScopedMessagePipeHandle* service_provider_handle) { if (!background_loader_) background_loader_ = new BackgroundLoader(loader_.get()); - background_loader_->LoadService(manager, url, shell_handle->Pass()); + background_loader_->LoadService( + manager, url, service_provider_handle->Pass()); } void BackgroundServiceLoader::OnServiceErrorOnBackgroundThread( diff --git a/mojo/service_manager/background_service_loader.h b/mojo/service_manager/background_service_loader.h index 9b4d757..59dbc0f 100644 --- a/mojo/service_manager/background_service_loader.h +++ b/mojo/service_manager/background_service_loader.h @@ -38,9 +38,10 @@ class MOJO_SERVICE_MANAGER_EXPORT BackgroundServiceLoader // to |background_loader_| to do the actual loading. // TODO: having this code take a |manager| is fragile (as ServiceManager isn't // thread safe). - void LoadServiceOnBackgroundThread(ServiceManager* manager, - const GURL& url, - ScopedMessagePipeHandle* shell_handle); + void LoadServiceOnBackgroundThread( + ServiceManager* manager, + const GURL& url, + ScopedMessagePipeHandle* service_provider_handle); void OnServiceErrorOnBackgroundThread(ServiceManager* manager, const GURL& url); void ShutdownOnBackgroundThread(); diff --git a/mojo/service_manager/service_loader.h b/mojo/service_manager/service_loader.h index 4053957..32c15cc 100644 --- a/mojo/service_manager/service_loader.h +++ b/mojo/service_manager/service_loader.h @@ -5,7 +5,7 @@ #ifndef MOJO_SERVICE_MANAGER_SERVICE_LOADER_H_ #define MOJO_SERVICE_MANAGER_SERVICE_LOADER_H_ -#include "mojo/public/interfaces/shell/shell.mojom.h" +#include "mojo/public/cpp/system/core.h" #include "mojo/service_manager/service_manager_export.h" #include "url/gurl.h" diff --git a/mojo/service_manager/service_manager.cc b/mojo/service_manager/service_manager.cc index 7aa3844..3aa955e 100644 --- a/mojo/service_manager/service_manager.cc +++ b/mojo/service_manager/service_manager.cc @@ -20,7 +20,7 @@ namespace { bool has_created_instance = false; } -class ServiceManager::ServiceFactory : public InterfaceImpl<Shell> { +class ServiceManager::ServiceFactory : public InterfaceImpl<ServiceProvider> { public: ServiceFactory(ServiceManager* manager, const GURL& url) : manager_(manager), @@ -33,14 +33,14 @@ class ServiceManager::ServiceFactory : public InterfaceImpl<Shell> { void ConnectToClient(ScopedMessagePipeHandle handle) { if (handle.is_valid()) { AllocationScope scope; - client()->AcceptConnection(url_.spec(), handle.Pass()); + client()->ConnectToService(url_.spec(), handle.Pass()); } } - // Shell implementation: - virtual void Connect(const String& url, - ScopedMessagePipeHandle client_pipe) OVERRIDE { - manager_->Connect(GURL(url.To<std::string>()), client_pipe.Pass()); + // ServiceProvider implementation: + virtual void ConnectToService(const String& url, + ScopedMessagePipeHandle client_pipe) OVERRIDE { + manager_->ConnectToService(GURL(url.To<std::string>()), client_pipe.Pass()); } const GURL& url() const { return url_; } @@ -56,26 +56,27 @@ class ServiceManager::ServiceFactory : public InterfaceImpl<Shell> { DISALLOW_COPY_AND_ASSIGN(ServiceFactory); }; -class ServiceManager::TestAPI::TestShellConnection - : public InterfaceImpl<Shell> { +class ServiceManager::TestAPI::TestServiceProviderConnection + : public InterfaceImpl<ServiceProvider> { public: - explicit TestShellConnection(ServiceManager* manager) : manager_(manager) {} - virtual ~TestShellConnection() {} + explicit TestServiceProviderConnection(ServiceManager* manager) + : manager_(manager) {} + virtual ~TestServiceProviderConnection() {} virtual void OnConnectionError() OVERRIDE { // TODO(darin): How should we handle this error? } - // Shell: - virtual void Connect(const String& url, - ScopedMessagePipeHandle client_pipe) OVERRIDE { - manager_->Connect(GURL(url.To<std::string>()), client_pipe.Pass()); + // ServiceProvider: + virtual void ConnectToService(const String& url, + ScopedMessagePipeHandle client_pipe) OVERRIDE { + manager_->ConnectToService(GURL(url.To<std::string>()), client_pipe.Pass()); } private: ServiceManager* manager_; - DISALLOW_COPY_AND_ASSIGN(TestShellConnection); + DISALLOW_COPY_AND_ASSIGN(TestServiceProviderConnection); }; // static @@ -89,10 +90,11 @@ bool ServiceManager::TestAPI::HasCreatedInstance() { return has_created_instance; } -ScopedMessagePipeHandle ServiceManager::TestAPI::GetShellHandle() { +ScopedMessagePipeHandle ServiceManager::TestAPI::GetServiceProviderHandle() { MessagePipe pipe; - shell_.reset( - BindToPipe(new TestShellConnection(manager_), pipe.handle0.Pass())); + service_provider_.reset( + BindToPipe(new TestServiceProviderConnection(manager_), + pipe.handle0.Pass())); return pipe.handle1.Pass(); } @@ -119,8 +121,8 @@ ServiceManager* ServiceManager::GetInstance() { return &instance.Get(); } -void ServiceManager::Connect(const GURL& url, - ScopedMessagePipeHandle client_handle) { +void ServiceManager::ConnectToService(const GURL& url, + ScopedMessagePipeHandle client_handle) { URLToServiceFactoryMap::const_iterator service_it = url_to_service_factory_.find(url); ServiceFactory* service_factory; diff --git a/mojo/service_manager/service_manager.h b/mojo/service_manager/service_manager.h index 81e129a..395a1d3 100644 --- a/mojo/service_manager/service_manager.h +++ b/mojo/service_manager/service_manager.h @@ -10,7 +10,7 @@ #include "base/basictypes.h" #include "base/gtest_prod_util.h" #include "base/memory/scoped_ptr.h" -#include "mojo/public/interfaces/shell/shell.mojom.h" +#include "mojo/public/interfaces/service_provider/service_provider.mojom.h" #include "mojo/service_manager/service_loader.h" #include "mojo/service_manager/service_manager_export.h" #include "url/gurl.h" @@ -25,8 +25,8 @@ class MOJO_SERVICE_MANAGER_EXPORT ServiceManager { explicit TestAPI(ServiceManager* manager); ~TestAPI(); - // Returns a handle to a unique shell instance. - ScopedMessagePipeHandle GetShellHandle(); + // Returns a handle to a unique ServiceProvider instance. + ScopedMessagePipeHandle GetServiceProviderHandle(); // Returns true if the shared instance has been created. static bool HasCreatedInstance(); @@ -34,10 +34,10 @@ class MOJO_SERVICE_MANAGER_EXPORT ServiceManager { bool HasFactoryForURL(const GURL& url) const; private: - class TestShellConnection; + class TestServiceProviderConnection; ServiceManager* manager_; - scoped_ptr<TestShellConnection> shell_; + scoped_ptr<TestServiceProviderConnection> service_provider_; DISALLOW_COPY_AND_ASSIGN(TestAPI); }; @@ -58,7 +58,7 @@ class MOJO_SERVICE_MANAGER_EXPORT ServiceManager { static ServiceManager* GetInstance(); // Loads a service if necessary and establishes a new client connection. - void Connect(const GURL& url, ScopedMessagePipeHandle client_handle); + void ConnectToService(const GURL& url, ScopedMessagePipeHandle client_handle); // Sets the default Loader to be used if not overridden by SetLoaderForURL() // or SetLoaderForScheme(). diff --git a/mojo/service_manager/service_manager_unittest.cc b/mojo/service_manager/service_manager_unittest.cc index fd763b5..0f18cbc 100644 --- a/mojo/service_manager/service_manager_unittest.cc +++ b/mojo/service_manager/service_manager_unittest.cc @@ -3,10 +3,11 @@ // found in the LICENSE file. #include "base/message_loop/message_loop.h" +#include "mojo/public/cpp/application/application.h" +#include "mojo/public/cpp/application/application.h" #include "mojo/public/cpp/bindings/allocation_scope.h" #include "mojo/public/cpp/environment/environment.h" -#include "mojo/public/cpp/shell/application.h" -#include "mojo/public/interfaces/shell/shell.mojom.h" +#include "mojo/public/interfaces/service_provider/service_provider.mojom.h" #include "mojo/service_manager/service_loader.h" #include "mojo/service_manager/service_manager.h" #include "mojo/service_manager/test.mojom.h" @@ -93,11 +94,12 @@ class TestServiceLoader : public ServiceLoader { int num_loads() const { return num_loads_; } private: - virtual void LoadService(ServiceManager* manager, - const GURL& url, - ScopedMessagePipeHandle shell_handle) OVERRIDE { + virtual void LoadService( + ServiceManager* manager, + const GURL& url, + ScopedMessagePipeHandle service_provider_handle) OVERRIDE { ++num_loads_; - test_app_.reset(new Application(shell_handle.Pass())); + test_app_.reset(new Application(service_provider_handle.Pass())); test_app_->AddService<TestServiceImpl>(context_); } @@ -166,7 +168,7 @@ class ServiceManagerTest : public testing::Test { service_manager_->set_default_loader( scoped_ptr<ServiceLoader>(default_loader)); - service_manager_->Connect(test_url, pipe.handle1.Pass()); + service_manager_->ConnectToService(test_url, pipe.handle1.Pass()); } virtual void TearDown() OVERRIDE { @@ -241,21 +243,21 @@ TEST_F(ServiceManagerTest, SetLoaders) { // test::test1 should go to url_loader. MessagePipe pipe1; - sm.Connect(GURL("test:test1"), pipe1.handle0.Pass()); + sm.ConnectToService(GURL("test:test1"), pipe1.handle0.Pass()); EXPECT_EQ(1, url_loader->num_loads()); EXPECT_EQ(0, scheme_loader->num_loads()); EXPECT_EQ(0, default_loader->num_loads()); // test::test2 should go to scheme loader. MessagePipe pipe2; - sm.Connect(GURL("test:test2"), pipe2.handle0.Pass()); + sm.ConnectToService(GURL("test:test2"), pipe2.handle0.Pass()); EXPECT_EQ(1, url_loader->num_loads()); EXPECT_EQ(1, scheme_loader->num_loads()); EXPECT_EQ(0, default_loader->num_loads()); // http::test1 should go to default loader. MessagePipe pipe3; - sm.Connect(GURL("http:test1"), pipe3.handle0.Pass()); + sm.ConnectToService(GURL("http:test1"), pipe3.handle0.Pass()); EXPECT_EQ(1, url_loader->num_loads()); EXPECT_EQ(1, scheme_loader->num_loads()); EXPECT_EQ(1, default_loader->num_loads()); @@ -270,7 +272,7 @@ TEST_F(ServiceManagerTest, Interceptor) { std::string url("test:test3"); MessagePipe pipe1; - sm.Connect(GURL(url), pipe1.handle0.Pass()); + sm.ConnectToService(GURL(url), pipe1.handle0.Pass()); EXPECT_EQ(1, interceptor.call_count()); EXPECT_EQ(url, interceptor.url_spec()); EXPECT_EQ(1, default_loader->num_loads()); diff --git a/mojo/services/native_viewport/native_viewport_service.cc b/mojo/services/native_viewport/native_viewport_service.cc index 30e37b7..b9c5a82 100644 --- a/mojo/services/native_viewport/native_viewport_service.cc +++ b/mojo/services/native_viewport/native_viewport_service.cc @@ -9,7 +9,7 @@ #include "base/time/time.h" #include "mojo/geometry/geometry_type_converters.h" #include "mojo/public/cpp/bindings/allocation_scope.h" -#include "mojo/public/interfaces/shell/shell.mojom.h" +#include "mojo/public/interfaces/service_provider/service_provider.mojom.h" #include "mojo/services/gles2/command_buffer_impl.h" #include "mojo/services/native_viewport/native_viewport.h" #include "mojo/services/native_viewport/native_viewport.mojom.h" @@ -186,9 +186,11 @@ class NativeViewportImpl MOJO_NATIVE_VIEWPORT_EXPORT mojo::Application* - CreateNativeViewportService(mojo::shell::Context* context, - mojo::ScopedMessagePipeHandle shell_handle) { - mojo::Application* app = new mojo::Application(shell_handle.Pass()); + CreateNativeViewportService( + mojo::shell::Context* context, + mojo::ScopedMessagePipeHandle service_provider_handle) { + mojo::Application* app = new mojo::Application( + service_provider_handle.Pass()); app->AddService<mojo::services::NativeViewportImpl>(context); return app; } diff --git a/mojo/services/native_viewport/native_viewport_service.h b/mojo/services/native_viewport/native_viewport_service.h index d2a71eb..99b455c 100644 --- a/mojo/services/native_viewport/native_viewport_service.h +++ b/mojo/services/native_viewport/native_viewport_service.h @@ -6,12 +6,13 @@ #define MOJO_SERVICES_NATIVE_VIEWPORT_SERVICE_H_ #include "base/memory/scoped_vector.h" -#include "mojo/public/cpp/shell/application.h" +#include "mojo/public/cpp/application/application.h" #include "mojo/services/native_viewport/native_viewport_export.h" #include "mojo/shell/context.h" MOJO_NATIVE_VIEWPORT_EXPORT mojo::Application* - CreateNativeViewportService(mojo::shell::Context* context, - mojo::ScopedMessagePipeHandle shell_handle); + CreateNativeViewportService( + mojo::shell::Context* context, + mojo::ScopedMessagePipeHandle service_provider_handle); #endif // MOJO_SERVICES_NATIVE_VIEWPORT_SERVICE_H_ diff --git a/mojo/services/public/cpp/view_manager/lib/view_manager.cc b/mojo/services/public/cpp/view_manager/lib/view_manager.cc index af7f1ed..93d99e8 100644 --- a/mojo/services/public/cpp/view_manager/lib/view_manager.cc +++ b/mojo/services/public/cpp/view_manager/lib/view_manager.cc @@ -11,8 +11,8 @@ namespace mojo { namespace view_manager { -ViewManager::ViewManager(Shell* shell) - : shell_(shell) {} +ViewManager::ViewManager(ServiceProvider* service_provider) + : service_provider_(service_provider) {} ViewManager::~ViewManager() { while (!nodes_.empty()) { diff --git a/mojo/services/public/cpp/view_manager/lib/view_manager_private.h b/mojo/services/public/cpp/view_manager/lib/view_manager_private.h index 1af8b9c..edd55cc 100644 --- a/mojo/services/public/cpp/view_manager/lib/view_manager_private.h +++ b/mojo/services/public/cpp/view_manager/lib/view_manager_private.h @@ -22,7 +22,7 @@ class ViewManagerPrivate { ViewManagerSynchronizer* synchronizer() { return manager_->synchronizer_.get(); } - Shell* shell() { return manager_->shell_; } + ServiceProvider* service_provider() { return manager_->service_provider_; } void set_root(ViewTreeNode* root) { manager_->tree_ = root; } diff --git a/mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.cc b/mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.cc index a901380..11d1b01 100644 --- a/mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.cc +++ b/mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.cc @@ -6,8 +6,8 @@ #include "base/bind.h" #include "base/run_loop.h" -#include "mojo/public/cpp/shell/connect.h" -#include "mojo/public/interfaces/shell/shell.mojom.h" +#include "mojo/public/cpp/application/connect.h" +#include "mojo/public/interfaces/service_provider/service_provider.mojom.h" #include "mojo/services/public/cpp/view_manager/lib/view_manager_private.h" #include "mojo/services/public/cpp/view_manager/lib/view_private.h" #include "mojo/services/public/cpp/view_manager/lib/view_tree_node_private.h" @@ -411,8 +411,10 @@ ViewManagerSynchronizer::ViewManagerSynchronizer(ViewManager* view_manager) next_server_change_id_(0), sync_factory_(this), init_loop_(NULL) { - ConnectTo(ViewManagerPrivate(view_manager_).shell(), "mojo:mojo_view_manager", - &service_); + ConnectToService( + ViewManagerPrivate(view_manager_).service_provider(), + "mojo:mojo_view_manager", + &service_); service_.set_client(this); // Start a runloop. This loop is quit when the server tells us about the diff --git a/mojo/services/public/cpp/view_manager/tests/view_manager_unittest.cc b/mojo/services/public/cpp/view_manager/tests/view_manager_unittest.cc index d28dca2..d1cbb2f 100644 --- a/mojo/services/public/cpp/view_manager/tests/view_manager_unittest.cc +++ b/mojo/services/public/cpp/view_manager/tests/view_manager_unittest.cc @@ -246,8 +246,8 @@ class ViewManagerTest : public testing::Test { // Overridden from testing::Test: virtual void SetUp() OVERRIDE { test_helper_.Init(); - view_manager_1_.reset(new ViewManager(test_helper_.shell())); - view_manager_2_.reset(new ViewManager(test_helper_.shell())); + view_manager_1_.reset(new ViewManager(test_helper_.service_provider())); + view_manager_2_.reset(new ViewManager(test_helper_.service_provider())); view_manager_1_->Init(); view_manager_2_->Init(); } diff --git a/mojo/services/public/cpp/view_manager/view_manager.h b/mojo/services/public/cpp/view_manager/view_manager.h index 6f82b2f..8380581 100644 --- a/mojo/services/public/cpp/view_manager/view_manager.h +++ b/mojo/services/public/cpp/view_manager/view_manager.h @@ -13,7 +13,7 @@ #include "mojo/services/public/cpp/view_manager/view_tree_node.h" namespace mojo { -class Shell; +class ServiceProvider; namespace view_manager { class View; @@ -27,7 +27,7 @@ class ViewTreeNode; // TODO: displays class ViewManager { public: - explicit ViewManager(Shell* shell); + explicit ViewManager(ServiceProvider* service_provider); ~ViewManager(); // Connects to the View Manager service. This method must be called before @@ -51,7 +51,7 @@ class ViewManager { typedef std::map<TransportNodeId, ViewTreeNode*> IdToNodeMap; typedef std::map<TransportViewId, View*> IdToViewMap; - Shell* shell_; + ServiceProvider* service_provider_; scoped_ptr<ViewManagerSynchronizer> synchronizer_; ViewTreeNode* tree_; diff --git a/mojo/services/view_manager/main.cc b/mojo/services/view_manager/main.cc index 3b1f6e6..95c74ef 100644 --- a/mojo/services/view_manager/main.cc +++ b/mojo/services/view_manager/main.cc @@ -5,7 +5,7 @@ #include "base/at_exit.h" #include "base/command_line.h" #include "base/message_loop/message_loop.h" -#include "mojo/public/cpp/shell/application.h" +#include "mojo/public/cpp/application/application.h" #include "mojo/services/view_manager/root_node_manager.h" #include "mojo/services/view_manager/view_manager_connection.h" @@ -20,12 +20,13 @@ #endif extern "C" VIEW_MANAGER_EXPORT MojoResult CDECL MojoMain( - MojoHandle shell_handle) { + MojoHandle service_provider_handle) { base::CommandLine::Init(0, NULL); base::AtExitManager at_exit; base::MessageLoop loop; - mojo::Application app(shell_handle); - mojo::view_manager::service::RootNodeManager root_node_manager(app.shell()); + mojo::Application app(service_provider_handle); + mojo::view_manager::service::RootNodeManager root_node_manager( + app.service_provider()); app.AddService<mojo::view_manager::service::ViewManagerConnection>( &root_node_manager); loop.Run(); diff --git a/mojo/services/view_manager/root_node_manager.cc b/mojo/services/view_manager/root_node_manager.cc index 710839b..eed3efb 100644 --- a/mojo/services/view_manager/root_node_manager.cc +++ b/mojo/services/view_manager/root_node_manager.cc @@ -34,12 +34,12 @@ RootNodeManager::Context::Context() { RootNodeManager::Context::~Context() { } -RootNodeManager::RootNodeManager(Shell* shell) +RootNodeManager::RootNodeManager(ServiceProvider* service_provider) : next_connection_id_(1), next_server_change_id_(1), change_source_(kRootConnection), is_processing_delete_node_(false), - root_view_manager_(shell, this), + root_view_manager_(service_provider, this), root_(this, RootNodeId()) { } diff --git a/mojo/services/view_manager/root_node_manager.h b/mojo/services/view_manager/root_node_manager.h index 1163ca1..3aed8bd 100644 --- a/mojo/services/view_manager/root_node_manager.h +++ b/mojo/services/view_manager/root_node_manager.h @@ -16,7 +16,7 @@ namespace mojo { -class Shell; +class ServiceProvider; namespace view_manager { namespace service { @@ -52,7 +52,7 @@ class MOJO_VIEW_MANAGER_EXPORT RootNodeManager : public NodeDelegate { DISALLOW_COPY_AND_ASSIGN(ScopedChange); }; - explicit RootNodeManager(Shell* shell); + explicit RootNodeManager(ServiceProvider* service_provider); virtual ~RootNodeManager(); // Returns the id for the next ViewManagerConnection. diff --git a/mojo/services/view_manager/root_view_manager.cc b/mojo/services/view_manager/root_view_manager.cc index 6302bed..9476c64 100644 --- a/mojo/services/view_manager/root_view_manager.cc +++ b/mojo/services/view_manager/root_view_manager.cc @@ -7,8 +7,8 @@ #include "base/auto_reset.h" #include "mojo/aura/screen_mojo.h" #include "mojo/aura/window_tree_host_mojo.h" -#include "mojo/public/cpp/shell/connect.h" -#include "mojo/public/interfaces/shell/shell.mojom.h" +#include "mojo/public/cpp/application/connect.h" +#include "mojo/public/interfaces/service_provider/service_provider.mojom.h" #include "mojo/services/view_manager/root_node_manager.h" #include "ui/aura/client/default_capture_client.h" #include "ui/aura/client/window_tree_client.h" @@ -47,14 +47,17 @@ class WindowTreeClientImpl : public aura::client::WindowTreeClient { DISALLOW_COPY_AND_ASSIGN(WindowTreeClientImpl); }; -RootViewManager::RootViewManager(Shell* shell, RootNodeManager* root_node) - : shell_(shell), +RootViewManager::RootViewManager(ServiceProvider* service_provider, + RootNodeManager* root_node) + : service_provider_(service_provider), root_node_manager_(root_node), in_setup_(false) { screen_.reset(ScreenMojo::Create()); gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); NativeViewportPtr viewport; - ConnectTo(shell, "mojo:mojo_native_viewport_service", &viewport); + ConnectToService(service_provider, + "mojo:mojo_native_viewport_service", + &viewport); window_tree_host_.reset(new WindowTreeHostMojo( viewport.Pass(), gfx::Rect(800, 600), diff --git a/mojo/services/view_manager/root_view_manager.h b/mojo/services/view_manager/root_view_manager.h index 55f1bfd..4e67ac9f 100644 --- a/mojo/services/view_manager/root_view_manager.h +++ b/mojo/services/view_manager/root_view_manager.h @@ -25,7 +25,7 @@ class Screen; namespace mojo { -class Shell; +class ServiceProvider; namespace view_manager { namespace service { @@ -35,7 +35,8 @@ class RootNodeManager; // RootViewManager binds the root node to an actual display. class MOJO_VIEW_MANAGER_EXPORT RootViewManager { public: - RootViewManager(Shell* shell, RootNodeManager* root_node); + RootViewManager(ServiceProvider* service_provider, + RootNodeManager* root_node); virtual ~RootViewManager(); // See description above field for details. @@ -44,7 +45,7 @@ class MOJO_VIEW_MANAGER_EXPORT RootViewManager { private: void OnCompositorCreated(); - Shell* shell_; + ServiceProvider* service_provider_; RootNodeManager* root_node_manager_; GLES2Initializer gles_initializer_; diff --git a/mojo/services/view_manager/view_manager_connection_unittest.cc b/mojo/services/view_manager/view_manager_connection_unittest.cc index 63c20ac..5945f30 100644 --- a/mojo/services/view_manager/view_manager_connection_unittest.cc +++ b/mojo/services/view_manager/view_manager_connection_unittest.cc @@ -12,9 +12,9 @@ #include "base/strings/stringprintf.h" #include "mojo/common/common_type_converters.h" #include "mojo/geometry/geometry_type_converters.h" +#include "mojo/public/cpp/application/connect.h" #include "mojo/public/cpp/bindings/allocation_scope.h" #include "mojo/public/cpp/environment/environment.h" -#include "mojo/public/cpp/shell/connect.h" #include "mojo/services/public/cpp/view_manager/util.h" #include "mojo/services/public/cpp/view_manager/view_manager_types.h" #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" @@ -376,7 +376,9 @@ class ViewManagerConnectionTest : public testing::Test { virtual void SetUp() OVERRIDE { test_helper_.Init(); - ConnectTo(test_helper_.shell(), "mojo:mojo_view_manager", &view_manager_); + ConnectToService(test_helper_.service_provider(), + "mojo:mojo_view_manager", + &view_manager_); view_manager_.set_client(&client_); client_.WaitForId(); @@ -386,7 +388,9 @@ class ViewManagerConnectionTest : public testing::Test { protected: // Creates a second connection to the viewmanager. void EstablishSecondConnection() { - ConnectTo(test_helper_.shell(), "mojo:mojo_view_manager", &view_manager2_); + ConnectToService(test_helper_.service_provider(), + "mojo:mojo_view_manager", + &view_manager2_); view_manager2_.set_client(&client2_); client2_.WaitForId(); diff --git a/mojo/shell/android/mojo_main.cc b/mojo/shell/android/mojo_main.cc index 8abf733..47f7f52 100644 --- a/mojo/shell/android/mojo_main.cc +++ b/mojo/shell/android/mojo_main.cc @@ -13,8 +13,8 @@ #include "base/macros.h" #include "base/message_loop/message_loop.h" #include "jni/MojoMain_jni.h" +#include "mojo/public/cpp/application/application.h" #include "mojo/public/cpp/environment/environment.h" -#include "mojo/public/cpp/shell/application.h" #include "mojo/service_manager/service_loader.h" #include "mojo/service_manager/service_manager.h" #include "mojo/shell/context.h" diff --git a/mojo/shell/context.cc b/mojo/shell/context.cc index d2dc6fa..5d471d4 100644 --- a/mojo/shell/context.cc +++ b/mojo/shell/context.cc @@ -10,7 +10,7 @@ #include "base/memory/scoped_vector.h" #include "mojo/embedder/embedder.h" #include "mojo/gles2/gles2_support_impl.h" -#include "mojo/public/cpp/shell/application.h" +#include "mojo/public/cpp/application/application.h" #include "mojo/service_manager/background_service_loader.h" #include "mojo/service_manager/service_loader.h" #include "mojo/service_manager/service_manager.h" diff --git a/mojo/shell/dbus_service_loader_linux.cc b/mojo/shell/dbus_service_loader_linux.cc index f2ecbcf..99cf1a9 100644 --- a/mojo/shell/dbus_service_loader_linux.cc +++ b/mojo/shell/dbus_service_loader_linux.cc @@ -37,12 +37,12 @@ class DBusServiceLoader::LoadContext { LoadContext(DBusServiceLoader* loader, const scoped_refptr<dbus::Bus>& bus, const GURL& url, - ScopedMessagePipeHandle shell_handle) + ScopedMessagePipeHandle service_provider_handle) : loader_(loader), bus_(bus), service_dbus_proxy_(NULL), url_(url), - shell_handle_(shell_handle.Pass()), + service_provider_handle_(service_provider_handle.Pass()), keep_alive_(loader->context_) { base::PostTaskAndReplyWithResult( loader_->context_->task_runners()->io_runner(), @@ -108,7 +108,8 @@ class DBusServiceLoader::LoadContext { mojo::AllocationScope scope; external_service_->Activate( mojo::ScopedMessagePipeHandle( - mojo::MessagePipeHandle(shell_handle_.release().value()))); + mojo::MessagePipeHandle( + service_provider_handle_.release().value()))); } // Should the ExternalService disappear completely, destroy connection state. @@ -132,7 +133,7 @@ class DBusServiceLoader::LoadContext { scoped_refptr<dbus::Bus> bus_; dbus::ObjectProxy* service_dbus_proxy_; // Owned by bus_; const GURL url_; - ScopedMessagePipeHandle shell_handle_; + ScopedMessagePipeHandle service_provider_handle_; KeepAlive keep_alive_; scoped_ptr<common::ChannelInit> channel_init_; ExternalServicePtr external_service_; diff --git a/mojo/shell/dbus_service_loader_linux.h b/mojo/shell/dbus_service_loader_linux.h index c23dcde..5bc24ca 100644 --- a/mojo/shell/dbus_service_loader_linux.h +++ b/mojo/shell/dbus_service_loader_linux.h @@ -10,7 +10,6 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" #include "mojo/public/cpp/system/core.h" -#include "mojo/public/interfaces/shell/shell.mojom.h" #include "mojo/service_manager/service_loader.h" #include "mojo/shell/keep_alive.h" #include "url/gurl.h" diff --git a/mojo/shell/dynamic_service_loader.h b/mojo/shell/dynamic_service_loader.h index f2e480f..0683c10 100644 --- a/mojo/shell/dynamic_service_loader.h +++ b/mojo/shell/dynamic_service_loader.h @@ -9,7 +9,6 @@ #include "base/macros.h" #include "mojo/public/cpp/system/core.h" -#include "mojo/public/interfaces/shell/shell.mojom.h" #include "mojo/service_manager/service_loader.h" #include "mojo/shell/dynamic_service_runner.h" #include "mojo/shell/keep_alive.h" diff --git a/mojo/shell/dynamic_service_runner.h b/mojo/shell/dynamic_service_runner.h index 8234a67..1409fb0e 100644 --- a/mojo/shell/dynamic_service_runner.h +++ b/mojo/shell/dynamic_service_runner.h @@ -8,7 +8,7 @@ #include "base/callback_forward.h" #include "base/macros.h" #include "base/memory/scoped_ptr.h" -#include "mojo/public/interfaces/shell/shell.mojom.h" +#include "mojo/public/cpp/system/core.h" namespace base { class FilePath; diff --git a/mojo/shell/external_service.mojom b/mojo/shell/external_service.mojom index 2b42365..e08f71f 100644 --- a/mojo/shell/external_service.mojom +++ b/mojo/shell/external_service.mojom @@ -5,7 +5,7 @@ module mojo { interface ExternalService { - Activate(handle<message_pipe> shell_handle); + Activate(handle<message_pipe> service_provider_handle); }; } diff --git a/mojo/shell/run.cc b/mojo/shell/run.cc index 8451485..a91a123 100644 --- a/mojo/shell/run.cc +++ b/mojo/shell/run.cc @@ -36,7 +36,7 @@ void Run(Context* context) { return; } ScopedMessagePipeHandle no_handle; - context->service_manager()->Connect(GURL(*it), no_handle.Pass()); + context->service_manager()->ConnectToService(GURL(*it), no_handle.Pass()); } } diff --git a/mojo/shell/shell_test_helper.cc b/mojo/shell/shell_test_helper.cc index a33810d..a198e15 100644 --- a/mojo/shell/shell_test_helper.cc +++ b/mojo/shell/shell_test_helper.cc @@ -19,7 +19,7 @@ namespace shell { struct ShellTestHelper::State { scoped_ptr<Context> context; scoped_ptr<ServiceManager::TestAPI> test_api; - ScopedMessagePipeHandle shell_handle; + ScopedMessagePipeHandle service_provider_handle; }; namespace { @@ -28,28 +28,28 @@ void StartShellOnShellThread(ShellTestHelper::State* state) { state->context.reset(new Context); state->test_api.reset( new ServiceManager::TestAPI(state->context->service_manager())); - state->shell_handle = state->test_api->GetShellHandle(); + state->service_provider_handle = state->test_api->GetServiceProviderHandle(); } } // namespace -class ShellTestHelper::TestShellClient : public ShellClient { +class ShellTestHelper::TestServiceProvider : public ServiceProvider { public: - TestShellClient() {} - virtual ~TestShellClient() {} + TestServiceProvider() {} + virtual ~TestServiceProvider() {} - // ShellClient: - virtual void AcceptConnection( + // ServiceProvider: + virtual void ConnectToService( const mojo::String& url, ScopedMessagePipeHandle client_handle) OVERRIDE { } private: - DISALLOW_COPY_AND_ASSIGN(TestShellClient); + DISALLOW_COPY_AND_ASSIGN(TestServiceProvider); }; ShellTestHelper::ShellTestHelper() - : shell_thread_("shell_test_helper"), + : service_provider_thread_("shell_test_helper"), state_(NULL) { base::CommandLine::Init(0, NULL); mojo::shell::InitializeLogging(); @@ -59,7 +59,7 @@ ShellTestHelper::~ShellTestHelper() { if (state_) { // |state_| contains data created on the background thread. Destroy it // there so that there aren't any race conditions. - shell_thread_.message_loop()->DeleteSoon(FROM_HERE, state_); + service_provider_thread_.message_loop()->DeleteSoon(FROM_HERE, state_); state_ = NULL; } } @@ -67,20 +67,23 @@ ShellTestHelper::~ShellTestHelper() { void ShellTestHelper::Init() { DCHECK(!state_); state_ = new State; - shell_thread_.Start(); - shell_thread_.message_loop()->message_loop_proxy()->PostTaskAndReply( + service_provider_thread_.Start(); + base::MessageLoopProxy* message_loop_proxy = + service_provider_thread_.message_loop()->message_loop_proxy(); + message_loop_proxy->PostTaskAndReply( FROM_HERE, base::Bind(&StartShellOnShellThread, state_), - base::Bind(&ShellTestHelper::OnShellStarted, base::Unretained(this))); + base::Bind(&ShellTestHelper::OnServiceProviderStarted, + base::Unretained(this))); run_loop_.reset(new base::RunLoop); run_loop_->Run(); } -void ShellTestHelper::OnShellStarted() { +void ShellTestHelper::OnServiceProviderStarted() { DCHECK(state_); - shell_client_.reset(new TestShellClient); - shell_.Bind(state_->shell_handle.Pass()); - shell_.set_client(shell_client_.get()); + local_service_provider_.reset(new TestServiceProvider); + service_provider_.Bind(state_->service_provider_handle.Pass()); + service_provider_.set_client(local_service_provider_.get()); run_loop_->Quit(); } diff --git a/mojo/shell/shell_test_helper.h b/mojo/shell/shell_test_helper.h index 5d0df6e..ab495cb 100644 --- a/mojo/shell/shell_test_helper.h +++ b/mojo/shell/shell_test_helper.h @@ -10,7 +10,7 @@ #include "base/run_loop.h" #include "base/threading/thread.h" #include "mojo/public/cpp/environment/environment.h" -#include "mojo/public/interfaces/shell/shell.mojom.h" +#include "mojo/public/interfaces/service_provider/service_provider.mojom.h" namespace base { class MessageLoopProxy; @@ -20,9 +20,10 @@ class RunLoop; namespace mojo { namespace shell { -// ShellTestHelper is useful for tests to establish a connection to the Shell. -// ShellTestHelper does this by spawning a thread and connecting. Invoke Init() -// to do this. Once done, shell() returns the handle to the Shell. +// ShellTestHelper is useful for tests to establish a connection to the +// ServiceProvider. ShellTestHelper does this by spawning a thread and +// connecting. Invoke Init() to do this. Once done, service_provider() +// returns the handle to the ServiceProvider. class ShellTestHelper { public: struct State; @@ -32,18 +33,19 @@ class ShellTestHelper { void Init(); - // Returns a handle to the Shell. ShellTestHelper owns the shell. - Shell* shell() { return shell_.get(); } + // Returns a handle to the ServiceProvider. ShellTestHelper owns the + // ServiceProvider. + ServiceProvider* service_provider() { return service_provider_.get(); } private: - class TestShellClient; + class TestServiceProvider; // Invoked once connection has been established. - void OnShellStarted(); + void OnServiceProviderStarted(); Environment environment_; - base::Thread shell_thread_; + base::Thread service_provider_thread_; // If non-null we're in Init() and waiting for connection. scoped_ptr<base::RunLoop> run_loop_; @@ -52,9 +54,9 @@ class ShellTestHelper { State* state_; // Client interface for the shell. - scoped_ptr<TestShellClient> shell_client_; + scoped_ptr<TestServiceProvider> local_service_provider_; - ShellPtr shell_; + ServiceProviderPtr service_provider_; DISALLOW_COPY_AND_ASSIGN(ShellTestHelper); }; diff --git a/mojo/shell/view_manager_loader.cc b/mojo/shell/view_manager_loader.cc index c590dd7..3b4adcf 100644 --- a/mojo/shell/view_manager_loader.cc +++ b/mojo/shell/view_manager_loader.cc @@ -4,7 +4,7 @@ #include "mojo/shell/view_manager_loader.h" -#include "mojo/public/cpp/shell/application.h" +#include "mojo/public/cpp/application/application.h" #include "mojo/services/view_manager/root_node_manager.h" #include "mojo/services/view_manager/view_manager_connection.h" @@ -17,13 +17,14 @@ ViewManagerLoader::ViewManagerLoader() { ViewManagerLoader::~ViewManagerLoader() { } -void ViewManagerLoader::LoadService(ServiceManager* manager, - const GURL& url, - ScopedMessagePipeHandle shell_handle) { - scoped_ptr<Application> app(new Application(shell_handle.Pass())); +void ViewManagerLoader::LoadService( + ServiceManager* manager, + const GURL& url, + ScopedMessagePipeHandle service_provider_handle) { + scoped_ptr<Application> app(new Application(service_provider_handle.Pass())); if (!root_node_manager_.get()) { root_node_manager_.reset( - new view_manager::service::RootNodeManager(app->shell())); + new view_manager::service::RootNodeManager(app->service_provider())); } app->AddService<view_manager::service::ViewManagerConnection>( root_node_manager_.get()); diff --git a/mojo/shell/view_manager_loader.h b/mojo/shell/view_manager_loader.h index f4927c5..e978b76 100644 --- a/mojo/shell/view_manager_loader.h +++ b/mojo/shell/view_manager_loader.h @@ -28,9 +28,10 @@ class ViewManagerLoader : public ServiceLoader { private: // ServiceLoader overrides: - virtual void LoadService(ServiceManager* manager, - const GURL& url, - ScopedMessagePipeHandle shell_handle) OVERRIDE; + virtual void LoadService( + ServiceManager* manager, + const GURL& url, + ScopedMessagePipeHandle service_provider_handle) OVERRIDE; virtual void OnServiceError(ServiceManager* manager, const GURL& url) OVERRIDE; |