diff options
author | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-25 21:57:02 +0000 |
---|---|---|
committer | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-25 21:57:02 +0000 |
commit | 8fc44a9f0c97c5f2e61fc8125a4822a057c67446 (patch) | |
tree | 0e3745a55a87d85cc5463b4a157aadccd0713c45 /mojo/services | |
parent | cf0c55a04cc3cb7e996d823eaf574e70d305a303 (diff) | |
download | chromium_src-8fc44a9f0c97c5f2e61fc8125a4822a057c67446.zip chromium_src-8fc44a9f0c97c5f2e61fc8125a4822a057c67446.tar.gz chromium_src-8fc44a9f0c97c5f2e61fc8125a4822a057c67446.tar.bz2 |
Split ServiceProvider into 3
BUG=
R=darin@chromium.org, qsr@chromium.org
Review URL: https://codereview.chromium.org/347333002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@279830 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/services')
25 files changed, 177 insertions, 93 deletions
diff --git a/mojo/services/dbus_echo/dbus_echo_service.cc b/mojo/services/dbus_echo/dbus_echo_service.cc index ae8029f..5243c42 100644 --- a/mojo/services/dbus_echo/dbus_echo_service.cc +++ b/mojo/services/dbus_echo/dbus_echo_service.cc @@ -18,7 +18,7 @@ namespace { class EchoServiceImpl : public mojo::InterfaceImpl<mojo::EchoService> { public: - EchoServiceImpl() {} + explicit EchoServiceImpl(mojo::ApplicationConnection* connection) {} virtual ~EchoServiceImpl() {} protected: diff --git a/mojo/services/launcher/launcher.cc b/mojo/services/launcher/launcher.cc index 4a453e0..60c3303 100644 --- a/mojo/services/launcher/launcher.cc +++ b/mojo/services/launcher/launcher.cc @@ -5,7 +5,9 @@ #include "base/compiler_specific.h" #include "base/message_loop/message_loop.h" #include "base/strings/string_tokenizer.h" -#include "mojo/public/cpp/application/application.h" +#include "mojo/public/cpp/application/application_connection.h" +#include "mojo/public/cpp/application/application_delegate.h" +#include "mojo/public/cpp/application/application_impl.h" #include "mojo/services/public/cpp/view_manager/types.h" #include "mojo/services/public/interfaces/launcher/launcher.mojom.h" #include "mojo/services/public/interfaces/network/network_service.mojom.h" @@ -26,7 +28,8 @@ class LauncherApp; class LauncherConnection : public InterfaceImpl<Launcher> { public: - explicit LauncherConnection(LauncherApp* app) : app_(app) {} + LauncherConnection(ApplicationConnection* connection, LauncherApp* app) + : app_(app) {} virtual ~LauncherConnection() {} private: @@ -91,7 +94,7 @@ class LaunchInstance : public URLLoaderClient { DISALLOW_COPY_AND_ASSIGN(LaunchInstance); }; -class LauncherApp : public Application { +class LauncherApp : public ApplicationDelegate { public: LauncherApp() { handler_map_["text/html"] = "mojo:mojo_html_viewer"; @@ -113,10 +116,15 @@ class LauncherApp : public Application { private: typedef std::map<std::string, std::string> HandlerMap; - // Overridden from Application: - virtual void Initialize() OVERRIDE { - AddService<LauncherConnection>(this); - ConnectTo("mojo:mojo_network_service", &network_service_); + // Overridden from ApplicationDelegate: + virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE { + app->ConnectToService("mojo:mojo_network_service", &network_service_); + } + + virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) + MOJO_OVERRIDE { + connection->AddService<LauncherConnection>(this); + return true; } HandlerMap handler_map_; @@ -177,7 +185,7 @@ void LaunchInstance::OnReceivedResponse(URLResponsePtr response) { } // namespace launcher // static -Application* Application::Create() { +ApplicationDelegate* ApplicationDelegate::Create() { return new launcher::LauncherApp; } diff --git a/mojo/services/native_viewport/native_viewport_service.cc b/mojo/services/native_viewport/native_viewport_service.cc index 886c4dc..9b63c48 100644 --- a/mojo/services/native_viewport/native_viewport_service.cc +++ b/mojo/services/native_viewport/native_viewport_service.cc @@ -8,6 +8,7 @@ #include "base/memory/weak_ptr.h" #include "base/message_loop/message_loop.h" #include "base/time/time.h" +#include "mojo/public/cpp/application/application_delegate.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" @@ -32,7 +33,8 @@ class NativeViewportImpl : public InterfaceImpl<mojo::NativeViewport>, public NativeViewportDelegate { public: - NativeViewportImpl(shell::Context* context) + NativeViewportImpl(ApplicationConnection* connection, + shell::Context* context) : context_(context), widget_(gfx::kNullAcceleratedWidget), waiting_for_event_ack_(false), @@ -150,16 +152,31 @@ class NativeViewportImpl base::WeakPtrFactory<NativeViewportImpl> weak_factory_; }; +class NVSDelegate : public ApplicationDelegate { + public: + NVSDelegate(shell::Context* context) : context_(context) {} + virtual ~NVSDelegate() {} + + virtual bool ConfigureIncomingConnection( + mojo::ApplicationConnection* connection) MOJO_OVERRIDE { + connection->AddService<NativeViewportImpl>(context_); + return true; + } + + private: + mojo::shell::Context* context_; +}; + + } // namespace services } // namespace mojo -MOJO_NATIVE_VIEWPORT_EXPORT mojo::Application* +MOJO_NATIVE_VIEWPORT_EXPORT mojo::ApplicationImpl* 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); + mojo::ApplicationImpl* app = new mojo::ApplicationImpl( + new mojo::services::NVSDelegate(context), service_provider_handle.Pass()); return app; } diff --git a/mojo/services/native_viewport/native_viewport_service.h b/mojo/services/native_viewport/native_viewport_service.h index 99b455c..1e6cde8 100644 --- a/mojo/services/native_viewport/native_viewport_service.h +++ b/mojo/services/native_viewport/native_viewport_service.h @@ -6,11 +6,11 @@ #define MOJO_SERVICES_NATIVE_VIEWPORT_SERVICE_H_ #include "base/memory/scoped_vector.h" -#include "mojo/public/cpp/application/application.h" +#include "mojo/public/cpp/application/application_impl.h" #include "mojo/services/native_viewport/native_viewport_export.h" #include "mojo/shell/context.h" -MOJO_NATIVE_VIEWPORT_EXPORT mojo::Application* +MOJO_NATIVE_VIEWPORT_EXPORT mojo::ApplicationImpl* CreateNativeViewportService( mojo::shell::Context* context, mojo::ScopedMessagePipeHandle service_provider_handle); diff --git a/mojo/services/network/main.cc b/mojo/services/network/main.cc index 99b62c5..72943ff 100644 --- a/mojo/services/network/main.cc +++ b/mojo/services/network/main.cc @@ -8,7 +8,9 @@ #include "base/files/file_path.h" #include "base/message_loop/message_loop.h" #include "base/run_loop.h" -#include "mojo/public/cpp/application/application.h" +#include "mojo/public/cpp/application/application_connection.h" +#include "mojo/public/cpp/application/application_delegate.h" +#include "mojo/public/cpp/application/application_impl.h" #include "mojo/public/cpp/application/connect.h" #include "mojo/public/cpp/bindings/interface_ptr.h" #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" @@ -41,13 +43,14 @@ scoped_ptr<mojo::NetworkContext> CreateContext( // when http://crbug.com/386485 is implemented. // Temporarly bind the handle to a service provider to retrieve a profile // service. + mojo::InterfacePtr<mojo::Shell> shell; + shell.Bind(handle->Pass()); mojo::InterfacePtr<mojo::ServiceProvider> service_provider; - service_provider.Bind(handle->Pass()); + shell->ConnectToApplication("mojo:profile_service", Get(&service_provider)); mojo::InterfacePtr<mojo::ProfileService> profile_service; - ConnectToService( - service_provider.get(), "mojo:profile_service", &profile_service); + ConnectToService(service_provider.get(), &profile_service); // Unbind the handle to prevent any message to be read. - *handle = service_provider.PassMessagePipe(); + *handle = shell.PassMessagePipe(); // Use a nested message loop to synchronously call a method on the profile // service. @@ -66,22 +69,36 @@ scoped_ptr<mojo::NetworkContext> CreateContext( } // namespace +class Delegate : public mojo::ApplicationDelegate { + public: + Delegate(scoped_ptr<mojo::NetworkContext> context) + : context_(context.Pass()) {} + + virtual bool ConfigureIncomingConnection( + mojo::ApplicationConnection* connection) MOJO_OVERRIDE { + connection->AddService<mojo::NetworkServiceImpl>(context_.get()); + return true; + } + + private: + scoped_ptr<mojo::NetworkContext> context_; +}; + extern "C" APPLICATION_EXPORT MojoResult CDECL MojoMain( - MojoHandle service_provider_handle) { + MojoHandle shell_handle) { base::CommandLine::Init(0, NULL); base::AtExitManager at_exit; // The IO message loop allows us to use net::URLRequest on this thread. base::MessageLoopForIO loop; - mojo::ScopedMessagePipeHandle scoped_service_provider_handle = - mojo::MakeScopedHandle(mojo::MessagePipeHandle(service_provider_handle)); + mojo::ScopedMessagePipeHandle scoped_shell_handle = + mojo::MakeScopedHandle(mojo::MessagePipeHandle(shell_handle)); scoped_ptr<mojo::NetworkContext> context = - CreateContext(&scoped_service_provider_handle); + CreateContext(&scoped_shell_handle); - mojo::Application app; - app.BindServiceProvider(scoped_service_provider_handle.Pass()); - app.AddService<mojo::NetworkServiceImpl>(context.get()); + Delegate delegate(context.Pass()); + mojo::ApplicationImpl app(&delegate, scoped_shell_handle.Pass()); loop.Run(); return MOJO_RESULT_OK; diff --git a/mojo/services/network/network_service_impl.cc b/mojo/services/network/network_service_impl.cc index a216738..e7da48e 100644 --- a/mojo/services/network/network_service_impl.cc +++ b/mojo/services/network/network_service_impl.cc @@ -8,15 +8,15 @@ namespace mojo { -NetworkServiceImpl::NetworkServiceImpl(NetworkContext* context) +NetworkServiceImpl::NetworkServiceImpl(ApplicationConnection* connection, + NetworkContext* context) : context_(context) { } NetworkServiceImpl::~NetworkServiceImpl() { } -void NetworkServiceImpl::CreateURLLoader( - InterfaceRequest<URLLoader> loader) { +void NetworkServiceImpl::CreateURLLoader(InterfaceRequest<URLLoader> loader) { BindToRequest(new URLLoaderImpl(context_), &loader); } diff --git a/mojo/services/network/network_service_impl.h b/mojo/services/network/network_service_impl.h index 32d1713..668569b 100644 --- a/mojo/services/network/network_service_impl.h +++ b/mojo/services/network/network_service_impl.h @@ -10,11 +10,13 @@ #include "mojo/services/public/interfaces/network/network_service.mojom.h" namespace mojo { +class ApplicationConnection; class NetworkContext; class NetworkServiceImpl : public InterfaceImpl<NetworkService> { public: - explicit NetworkServiceImpl(NetworkContext* context); + NetworkServiceImpl(ApplicationConnection* connection, + NetworkContext* context); virtual ~NetworkServiceImpl(); // NetworkService methods: diff --git a/mojo/services/profile/profile_service_impl.cc b/mojo/services/profile/profile_service_impl.cc index 2fe52ac..6af6a6b 100644 --- a/mojo/services/profile/profile_service_impl.cc +++ b/mojo/services/profile/profile_service_impl.cc @@ -23,7 +23,7 @@ int BaseKeyForMojoKey(mojo::ProfileService::PathKey key) { namespace mojo { -ProfileServiceImpl::ProfileServiceImpl(void* context) { +ProfileServiceImpl::ProfileServiceImpl(ApplicationConnection* connection) { } ProfileServiceImpl::~ProfileServiceImpl() { diff --git a/mojo/services/profile/profile_service_impl.h b/mojo/services/profile/profile_service_impl.h index 7a0d03b..b10f18a 100644 --- a/mojo/services/profile/profile_service_impl.h +++ b/mojo/services/profile/profile_service_impl.h @@ -11,9 +11,11 @@ namespace mojo { +class ApplicationConnection; + class ProfileServiceImpl : public InterfaceImpl<ProfileService> { public: - ProfileServiceImpl(void* context); + ProfileServiceImpl(ApplicationConnection* connection); virtual ~ProfileServiceImpl(); // |ProfileService| methods: diff --git a/mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.cc b/mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.cc index 7575060..d82c8ec 100644 --- a/mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.cc +++ b/mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.cc @@ -6,7 +6,7 @@ #include "base/bind.h" #include "base/message_loop/message_loop.h" -#include "mojo/public/cpp/application/application.h" +#include "mojo/public/cpp/application/application_connection.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/node_private.h" @@ -522,7 +522,8 @@ class SetVisibleTransaction : public ViewManagerTransaction { DISALLOW_COPY_AND_ASSIGN(SetVisibleTransaction); }; -ViewManagerClientImpl::ViewManagerClientImpl(ViewManagerDelegate* delegate) +ViewManagerClientImpl::ViewManagerClientImpl(ApplicationConnection* connection, + ViewManagerDelegate* delegate) : connected_(false), connection_id_(0), next_id_(1), @@ -644,7 +645,8 @@ void ViewManagerClientImpl::SetVisible(Id node_id, bool visible) { void ViewManagerClientImpl::Embed(const String& url, Id node_id) { DCHECK(connected_); - pending_transactions_.push_back(new EmbedTransaction(url, node_id, this)); + pending_transactions_.push_back( + new EmbedTransaction(url, node_id, this)); Sync(); } @@ -890,9 +892,10 @@ void ViewManagerClientImpl::RemoveRoot(Node* root) { // ViewManager, public: // static -void ViewManager::Create(Application* application, - ViewManagerDelegate* delegate) { - application->AddService<ViewManagerClientImpl>(delegate); +void ViewManager::ConfigureIncomingConnection( + ApplicationConnection* connection, + ViewManagerDelegate* delegate) { + connection->AddService<ViewManagerClientImpl>(delegate); } } // namespace view_manager diff --git a/mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.h b/mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.h index 425c0ef..e1b14f29 100644 --- a/mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.h +++ b/mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.h @@ -18,6 +18,7 @@ class SkBitmap; namespace mojo { +class ApplicationConnection; namespace view_manager { class ViewEventDispatcher; @@ -28,7 +29,8 @@ class ViewManagerTransaction; class ViewManagerClientImpl : public ViewManager, public InterfaceImpl<ViewManagerClient> { public: - explicit ViewManagerClientImpl(ViewManagerDelegate* delegate); + explicit ViewManagerClientImpl(ApplicationConnection* connection, + ViewManagerDelegate* delegate); virtual ~ViewManagerClientImpl(); bool connected() const { return connected_; } 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 eb98fc7..c9316ea 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 @@ -7,7 +7,9 @@ #include "base/auto_reset.h" #include "base/bind.h" #include "base/logging.h" -#include "mojo/public/cpp/application/application.h" +#include "mojo/public/cpp/application/application_connection.h" +#include "mojo/public/cpp/application/application_delegate.h" +#include "mojo/public/cpp/application/application_impl.h" #include "mojo/service_manager/service_manager.h" #include "mojo/services/public/cpp/view_manager/lib/node_private.h" #include "mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.h" @@ -46,6 +48,7 @@ void WaitForAllChangesToBeAcked(ViewManagerClientImpl* client) { } class ConnectServiceLoader : public ServiceLoader, + public ApplicationDelegate, public ViewManagerDelegate { public: typedef base::Callback<void(ViewManager*, Node*)> LoadedCallback; @@ -60,21 +63,28 @@ class ConnectServiceLoader : public ServiceLoader, virtual void LoadService(ServiceManager* manager, const GURL& url, ScopedMessagePipeHandle shell_handle) OVERRIDE { - scoped_ptr<Application> app(new Application(shell_handle.Pass())); - ViewManager::Create(app.get(), this); + scoped_ptr<ApplicationImpl> app(new ApplicationImpl(this, + shell_handle.Pass())); apps_.push_back(app.release()); } + virtual void OnServiceError(ServiceManager* manager, const GURL& url) OVERRIDE { } + virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) + OVERRIDE { + ViewManager::ConfigureIncomingConnection(connection, this); + return true; + } + // Overridden from ViewManagerDelegate: virtual void OnRootAdded(ViewManager* view_manager, Node* root) OVERRIDE { callback_.Run(view_manager, root); } - ScopedVector<Application> apps_; + ScopedVector<ApplicationImpl> apps_; LoadedCallback callback_; DISALLOW_COPY_AND_ASSIGN(ConnectServiceLoader); @@ -373,9 +383,8 @@ class ViewManagerTest : public testing::Test { scoped_ptr<ServiceLoader>(new ConnectServiceLoader(ready_callback)), GURL(kEmbeddedApp1URL)); - ConnectToService(test_helper_.service_provider(), - "mojo:mojo_view_manager", - &view_manager_init_); + test_helper_.service_manager()->ConnectToService( + GURL("mojo:mojo_view_manager"), &view_manager_init_); ASSERT_TRUE(EmbedRoot(view_manager_init_.get(), kWindowManagerURL)); } diff --git a/mojo/services/public/cpp/view_manager/view_manager.h b/mojo/services/public/cpp/view_manager/view_manager.h index 9b46387..3c55e307 100644 --- a/mojo/services/public/cpp/view_manager/view_manager.h +++ b/mojo/services/public/cpp/view_manager/view_manager.h @@ -12,7 +12,7 @@ #include "mojo/services/public/interfaces/input_events/input_events.mojom.h" namespace mojo { -class Application; +class ApplicationConnection; namespace view_manager { class Node; @@ -23,7 +23,8 @@ class ViewManagerDelegate; class ViewManager { public: // Delegate is owned by the caller. - static void Create(Application* application, ViewManagerDelegate* delegate); + static void ConfigureIncomingConnection(ApplicationConnection* connection, + ViewManagerDelegate* delegate); // Sets the event dispatcher. Can only be called by the app rendering to the // root Node of the hierarchy. diff --git a/mojo/services/test_service/test_service_application.cc b/mojo/services/test_service/test_service_application.cc index 3737823..5b64973 100644 --- a/mojo/services/test_service/test_service_application.cc +++ b/mojo/services/test_service/test_service_application.cc @@ -6,6 +6,7 @@ #include <assert.h> +#include "mojo/public/cpp/application/application_connection.h" #include "mojo/public/cpp/utility/run_loop.h" #include "mojo/services/test_service/test_service_impl.h" @@ -18,8 +19,10 @@ TestServiceApplication::TestServiceApplication() : ref_count_(0) { TestServiceApplication::~TestServiceApplication() { } -void TestServiceApplication::Initialize() { - AddService<TestServiceImpl>(this); +bool TestServiceApplication::ConfigureIncomingConnection( + ApplicationConnection* connection) { + connection->AddService<TestServiceImpl>(this); + return true; } void TestServiceApplication::AddRef() { @@ -37,7 +40,7 @@ void TestServiceApplication::ReleaseRef() { } // namespace test // static -Application* Application::Create() { +ApplicationDelegate* ApplicationDelegate::Create() { return new mojo::test::TestServiceApplication(); } diff --git a/mojo/services/test_service/test_service_application.h b/mojo/services/test_service/test_service_application.h index 9f042c1..8892f30 100644 --- a/mojo/services/test_service/test_service_application.h +++ b/mojo/services/test_service/test_service_application.h @@ -5,18 +5,20 @@ #ifndef MOJO_SERVICES_TEST_SERVICE_TEST_SERVICE_APPLICATION_H_ #define MOJO_SERVICES_TEST_SERVICE_TEST_SERVICE_APPLICATION_H_ -#include "mojo/public/cpp/application/application.h" +#include "mojo/public/cpp/application/application_delegate.h" #include "mojo/public/cpp/system/macros.h" namespace mojo { +class ApplicationConnection; namespace test { -class TestServiceApplication : public Application { +class TestServiceApplication : public ApplicationDelegate { public: TestServiceApplication(); virtual ~TestServiceApplication(); - virtual void Initialize() MOJO_OVERRIDE; + virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) + MOJO_OVERRIDE; void AddRef(); void ReleaseRef(); diff --git a/mojo/services/test_service/test_service_impl.cc b/mojo/services/test_service/test_service_impl.cc index a38d619..ec65200 100644 --- a/mojo/services/test_service/test_service_impl.cc +++ b/mojo/services/test_service/test_service_impl.cc @@ -9,7 +9,8 @@ namespace mojo { namespace test { -TestServiceImpl::TestServiceImpl(TestServiceApplication* application) +TestServiceImpl::TestServiceImpl(ApplicationConnection* connection, + TestServiceApplication* application) : application_(application) { } diff --git a/mojo/services/test_service/test_service_impl.h b/mojo/services/test_service/test_service_impl.h index df2d4a1..c8e272a 100644 --- a/mojo/services/test_service/test_service_impl.h +++ b/mojo/services/test_service/test_service_impl.h @@ -9,13 +9,15 @@ #include "mojo/services/test_service/test_service.mojom.h" namespace mojo { +class ApplicationConnection; namespace test { class TestServiceApplication; class TestServiceImpl : public InterfaceImpl<ITestService> { public: - explicit TestServiceImpl(TestServiceApplication* application); + explicit TestServiceImpl(ApplicationConnection* connection, + TestServiceApplication* application); virtual ~TestServiceImpl(); // |ITestService| methods: diff --git a/mojo/services/view_manager/main.cc b/mojo/services/view_manager/main.cc index de0a768..d511505 100644 --- a/mojo/services/view_manager/main.cc +++ b/mojo/services/view_manager/main.cc @@ -2,22 +2,25 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "mojo/public/cpp/application/application.h" +#include "mojo/public/cpp/application/application_connection.h" +#include "mojo/public/cpp/application/application_delegate.h" #include "mojo/services/view_manager/view_manager_init_service_impl.h" namespace mojo { namespace view_manager { namespace service { -class ViewManagerApp : public Application { +class ViewManagerApp : public ApplicationDelegate { public: ViewManagerApp() {} virtual ~ViewManagerApp() {} - virtual void Initialize() MOJO_OVERRIDE { + virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) + MOJO_OVERRIDE { // TODO(sky): this needs some sort of authentication as well as making sure // we only ever have one active at a time. - AddService<ViewManagerInitServiceImpl>(service_provider()); + connection->AddService<ViewManagerInitServiceImpl>(); + return true; } private: @@ -28,7 +31,7 @@ class ViewManagerApp : public Application { } // namespace view_manager // static -Application* Application::Create() { +ApplicationDelegate* ApplicationDelegate::Create() { return new mojo::view_manager::service::ViewManagerApp(); } diff --git a/mojo/services/view_manager/root_node_manager.cc b/mojo/services/view_manager/root_node_manager.cc index 10a699c..45df25d 100644 --- a/mojo/services/view_manager/root_node_manager.cc +++ b/mojo/services/view_manager/root_node_manager.cc @@ -5,6 +5,7 @@ #include "mojo/services/view_manager/root_node_manager.h" #include "base/logging.h" +#include "mojo/public/cpp/application/application_connection.h" #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" #include "mojo/services/public/cpp/input_events/input_events_type_converters.h" #include "mojo/services/view_manager/view.h" @@ -41,12 +42,12 @@ RootNodeManager::Context::~Context() { aura::Env::DeleteInstance(); } -RootNodeManager::RootNodeManager(ServiceProvider* service_provider, +RootNodeManager::RootNodeManager(ApplicationConnection* app_connection, RootViewManagerDelegate* view_manager_delegate) - : service_provider_(service_provider), + : app_connection_(app_connection), next_connection_id_(1), next_server_change_id_(1), - root_view_manager_(service_provider, this, view_manager_delegate), + root_view_manager_(app_connection, this, view_manager_delegate), root_(this, RootNodeId()), current_change_(NULL) { } @@ -235,11 +236,12 @@ ViewManagerServiceImpl* RootNodeManager::EmbedImpl( const String& url, const Array<Id>& node_ids) { MessagePipe pipe; - service_provider_->ConnectToService( - url, + + ServiceProvider* service_provider = + app_connection_->ConnectToApplication(url)->GetServiceProvider(); + service_provider->ConnectToService( ViewManagerServiceImpl::Client::Name_, - pipe.handle1.Pass(), - String()); + pipe.handle1.Pass()); std::string creator_url; ConnectionMap::const_iterator it = connection_map_.find(creator_id); diff --git a/mojo/services/view_manager/root_node_manager.h b/mojo/services/view_manager/root_node_manager.h index b5098fd..86afa83 100644 --- a/mojo/services/view_manager/root_node_manager.h +++ b/mojo/services/view_manager/root_node_manager.h @@ -23,7 +23,7 @@ class Event; namespace mojo { -class ServiceProvider; +class ApplicationConnection; namespace view_manager { namespace service { @@ -81,7 +81,7 @@ class MOJO_VIEW_MANAGER_EXPORT RootNodeManager DISALLOW_COPY_AND_ASSIGN(ScopedChange); }; - RootNodeManager(ServiceProvider* service_provider, + RootNodeManager(ApplicationConnection* app_connection, RootViewManagerDelegate* view_manager_delegate); virtual ~RootNodeManager(); @@ -198,7 +198,7 @@ class MOJO_VIEW_MANAGER_EXPORT RootNodeManager Context context_; - ServiceProvider* service_provider_; + ApplicationConnection* app_connection_; // ID to use for next ViewManagerServiceImpl. ConnectionSpecificId next_connection_id_; diff --git a/mojo/services/view_manager/root_view_manager.cc b/mojo/services/view_manager/root_view_manager.cc index 3f432de..6e7baf0 100644 --- a/mojo/services/view_manager/root_view_manager.cc +++ b/mojo/services/view_manager/root_view_manager.cc @@ -6,7 +6,7 @@ #include "base/auto_reset.h" #include "base/scoped_observer.h" -#include "mojo/public/cpp/application/connect.h" +#include "mojo/public/cpp/application/application_connection.h" #include "mojo/services/view_manager/root_node_manager.h" #include "mojo/services/view_manager/root_view_manager_delegate.h" #include "mojo/services/view_manager/screen_impl.h" @@ -116,7 +116,7 @@ class WindowTreeClientImpl : public aura::client::WindowTreeClient { DISALLOW_COPY_AND_ASSIGN(WindowTreeClientImpl); }; -RootViewManager::RootViewManager(ServiceProvider* service_provider, +RootViewManager::RootViewManager(ApplicationConnection* app_connection, RootNodeManager* root_node, RootViewManagerDelegate* delegate) : delegate_(delegate), @@ -125,9 +125,8 @@ RootViewManager::RootViewManager(ServiceProvider* service_provider, screen_.reset(ScreenImpl::Create()); gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); NativeViewportPtr viewport; - ConnectToService(service_provider, - "mojo:mojo_native_viewport_service", - &viewport); + app_connection->ConnectToService( + "mojo:mojo_native_viewport_service", &viewport); window_tree_host_.reset(new WindowTreeHostImpl( 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 cfec229..8eb3eb5 100644 --- a/mojo/services/view_manager/root_view_manager.h +++ b/mojo/services/view_manager/root_view_manager.h @@ -26,7 +26,7 @@ class Screen; namespace mojo { -class ServiceProvider; +class ApplicationConnection; namespace view_manager { namespace service { @@ -37,7 +37,7 @@ class RootViewManagerDelegate; // RootViewManager binds the root node to an actual display. class MOJO_VIEW_MANAGER_EXPORT RootViewManager { public: - RootViewManager(ServiceProvider* service_provider, + RootViewManager(ApplicationConnection* app_connection, RootNodeManager* root_node, RootViewManagerDelegate* delegate); virtual ~RootViewManager(); diff --git a/mojo/services/view_manager/view_manager_init_service_impl.cc b/mojo/services/view_manager/view_manager_init_service_impl.cc index be2ce15..28c7beb 100644 --- a/mojo/services/view_manager/view_manager_init_service_impl.cc +++ b/mojo/services/view_manager/view_manager_init_service_impl.cc @@ -9,6 +9,7 @@ #include "mojo/services/view_manager/view_manager_service_impl.h" namespace mojo { +class ApplicationConnection; namespace view_manager { namespace service { @@ -17,9 +18,8 @@ ViewManagerInitServiceImpl::ConnectParams::ConnectParams() {} ViewManagerInitServiceImpl::ConnectParams::~ConnectParams() {} ViewManagerInitServiceImpl::ViewManagerInitServiceImpl( - ServiceProvider* service_provider) - : service_provider_(service_provider), - root_node_manager_(service_provider, this), + ApplicationConnection* connection) + : root_node_manager_(connection, this), is_tree_host_ready_(false) { } diff --git a/mojo/services/view_manager/view_manager_init_service_impl.h b/mojo/services/view_manager/view_manager_init_service_impl.h index 59d438e..b3a0964 100644 --- a/mojo/services/view_manager/view_manager_init_service_impl.h +++ b/mojo/services/view_manager/view_manager_init_service_impl.h @@ -16,6 +16,7 @@ namespace mojo { +class ApplicationConnection; class ServiceProvider; namespace view_manager { @@ -34,7 +35,7 @@ class MOJO_VIEW_MANAGER_EXPORT ViewManagerInitServiceImpl : public InterfaceImpl<ViewManagerInitService>, public RootViewManagerDelegate { public: - explicit ViewManagerInitServiceImpl(ServiceProvider* service_provider); + explicit ViewManagerInitServiceImpl(ApplicationConnection* connection); virtual ~ViewManagerInitServiceImpl(); private: diff --git a/mojo/services/view_manager/view_manager_unittest.cc b/mojo/services/view_manager/view_manager_unittest.cc index 1e48459..52bcf9e 100644 --- a/mojo/services/view_manager/view_manager_unittest.cc +++ b/mojo/services/view_manager/view_manager_unittest.cc @@ -14,7 +14,9 @@ #include "base/run_loop.h" #include "base/strings/stringprintf.h" #include "mojo/common/common_type_converters.h" -#include "mojo/public/cpp/application/application.h" +#include "mojo/public/cpp/application/application_connection.h" +#include "mojo/public/cpp/application/application_delegate.h" +#include "mojo/public/cpp/application/application_impl.h" #include "mojo/public/cpp/application/connect.h" #include "mojo/public/cpp/bindings/lib/router.h" #include "mojo/service_manager/service_manager.h" @@ -284,7 +286,8 @@ bool ViewManagerProxy::in_embed_ = false; class TestViewManagerClientConnection : public InterfaceImpl<ViewManagerClient> { public: - TestViewManagerClientConnection() : connection_(&tracker_) { + TestViewManagerClientConnection(ApplicationConnection* app_connection) : + connection_(&tracker_) { tracker_.set_delegate(&connection_); } @@ -361,7 +364,7 @@ class TestViewManagerClientConnection // Used with ViewManagerService::Embed(). Creates a // TestViewManagerClientConnection, which creates and owns the ViewManagerProxy. -class EmbedServiceLoader : public ServiceLoader { +class EmbedServiceLoader : public ServiceLoader, ApplicationDelegate { public: EmbedServiceLoader() {} virtual ~EmbedServiceLoader() {} @@ -370,16 +373,23 @@ class EmbedServiceLoader : public ServiceLoader { virtual void LoadService(ServiceManager* manager, const GURL& url, ScopedMessagePipeHandle shell_handle) OVERRIDE { - scoped_ptr<Application> app(new Application(shell_handle.Pass())); - app->AddService<TestViewManagerClientConnection>(); + scoped_ptr<ApplicationImpl> app(new ApplicationImpl(this, + shell_handle.Pass())); apps_.push_back(app.release()); } virtual void OnServiceError(ServiceManager* manager, const GURL& url) OVERRIDE { } + // ApplicationDelegate + virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) + OVERRIDE { + connection->AddService<TestViewManagerClientConnection>(); + return true; + } + private: - ScopedVector<Application> apps_; + ScopedVector<ApplicationImpl> apps_; DISALLOW_COPY_AND_ASSIGN(EmbedServiceLoader); }; @@ -432,9 +442,9 @@ class ViewManagerTest : public testing::Test { scoped_ptr<ServiceLoader>(new EmbedServiceLoader()), GURL(kTestServiceURL)); - ConnectToService(test_helper_.service_provider(), - "mojo:mojo_view_manager", - &view_manager_init_); + test_helper_.service_manager()->ConnectToService( + GURL("mojo:mojo_view_manager"), + &view_manager_init_); ASSERT_TRUE(EmbedRoot(view_manager_init_.get(), kTestServiceURL)); connection_ = ViewManagerProxy::WaitForInstance(); |