diff options
Diffstat (limited to 'mojo/shell')
-rw-r--r-- | mojo/shell/android/mojo_main.cc | 1 | ||||
-rw-r--r-- | mojo/shell/context.cc | 8 | ||||
-rw-r--r-- | mojo/shell/dbus_service_loader_linux.cc | 4 | ||||
-rw-r--r-- | mojo/shell/dbus_service_loader_linux.h | 2 | ||||
-rw-r--r-- | mojo/shell/dynamic_service_loader.cc | 10 | ||||
-rw-r--r-- | mojo/shell/profile_service_loader.cc | 18 | ||||
-rw-r--r-- | mojo/shell/profile_service_loader.h | 13 | ||||
-rw-r--r-- | mojo/shell/run.cc | 19 | ||||
-rw-r--r-- | mojo/shell/shell_test_base.cc | 12 | ||||
-rw-r--r-- | mojo/shell/shell_test_base.h | 6 | ||||
-rw-r--r-- | mojo/shell/shell_test_base_unittest.cc | 18 | ||||
-rw-r--r-- | mojo/shell/shell_test_helper.cc | 19 | ||||
-rw-r--r-- | mojo/shell/shell_test_helper.h | 15 | ||||
-rw-r--r-- | mojo/shell/view_manager_loader.cc | 16 | ||||
-rw-r--r-- | mojo/shell/view_manager_loader.h | 9 |
15 files changed, 87 insertions, 83 deletions
diff --git a/mojo/shell/android/mojo_main.cc b/mojo/shell/android/mojo_main.cc index c265632..9a574b8 100644 --- a/mojo/shell/android/mojo_main.cc +++ b/mojo/shell/android/mojo_main.cc @@ -13,7 +13,6 @@ #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/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 8fc8aaf..b4fe829 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/application/application.h" +#include "mojo/public/cpp/application/application_impl.h" #include "mojo/service_manager/background_service_loader.h" #include "mojo/service_manager/service_loader.h" #include "mojo/service_manager/service_manager.h" @@ -67,8 +67,8 @@ class Context::NativeViewportServiceLoader : public ServiceLoader { private: virtual void LoadService(ServiceManager* manager, const GURL& url, - ScopedMessagePipeHandle service_handle) OVERRIDE { - app_.reset(::CreateNativeViewportService(context_, service_handle.Pass())); + ScopedMessagePipeHandle shell_handle) OVERRIDE { + app_.reset(::CreateNativeViewportService(context_, shell_handle.Pass())); } virtual void OnServiceError(ServiceManager* manager, @@ -76,7 +76,7 @@ class Context::NativeViewportServiceLoader : public ServiceLoader { } Context* context_; - scoped_ptr<Application> app_; + scoped_ptr<ApplicationImpl> app_; DISALLOW_COPY_AND_ASSIGN(NativeViewportServiceLoader); }; diff --git a/mojo/shell/dbus_service_loader_linux.cc b/mojo/shell/dbus_service_loader_linux.cc index bd4255c..dfad95f 100644 --- a/mojo/shell/dbus_service_loader_linux.cc +++ b/mojo/shell/dbus_service_loader_linux.cc @@ -152,11 +152,11 @@ DBusServiceLoader::~DBusServiceLoader() { void DBusServiceLoader::LoadService(ServiceManager* manager, const GURL& url, - ScopedMessagePipeHandle service_handle) { + ScopedMessagePipeHandle shell_handle) { DCHECK(url.SchemeIs("dbus")); DCHECK(url_to_load_context_.find(url) == url_to_load_context_.end()); url_to_load_context_[url] = - new LoadContext(this, bus_, url, service_handle.Pass()); + new LoadContext(this, bus_, url, shell_handle.Pass()); } void DBusServiceLoader::OnServiceError(ServiceManager* manager, diff --git a/mojo/shell/dbus_service_loader_linux.h b/mojo/shell/dbus_service_loader_linux.h index 5bc24ca..a24af5f 100644 --- a/mojo/shell/dbus_service_loader_linux.h +++ b/mojo/shell/dbus_service_loader_linux.h @@ -63,7 +63,7 @@ class DBusServiceLoader : public ServiceLoader { // "/org/chromium/MojoImpl". virtual void LoadService(ServiceManager* manager, const GURL& url, - ScopedMessagePipeHandle service_handle) OVERRIDE; + ScopedMessagePipeHandle shell_handle) OVERRIDE; virtual void OnServiceError(ServiceManager* manager, const GURL& url) OVERRIDE; diff --git a/mojo/shell/dynamic_service_loader.cc b/mojo/shell/dynamic_service_loader.cc index 9def450..994e318 100644 --- a/mojo/shell/dynamic_service_loader.cc +++ b/mojo/shell/dynamic_service_loader.cc @@ -152,7 +152,7 @@ DynamicServiceLoader::~DynamicServiceLoader() { void DynamicServiceLoader::LoadService(ServiceManager* manager, const GURL& url, - ScopedMessagePipeHandle service_handle) { + ScopedMessagePipeHandle shell_handle) { scoped_ptr<DynamicServiceRunner> runner = runner_factory_->Create(context_); GURL resolved_url; @@ -167,13 +167,13 @@ void DynamicServiceLoader::LoadService(ServiceManager* manager, loader = new LocalLoader(runner.Pass()); } else { if (!network_service_.get()) { - context_->service_manager()->ConnectTo(GURL("mojo:mojo_network_service"), - &network_service_, - GURL()); + context_->service_manager()->ConnectToService( + GURL("mojo:mojo_network_service"), + &network_service_); } loader = new NetworkLoader(runner.Pass(), network_service_.get()); } - loader->Start(resolved_url, service_handle.Pass(), context_); + loader->Start(resolved_url, shell_handle.Pass(), context_); } void DynamicServiceLoader::OnServiceError(ServiceManager* manager, diff --git a/mojo/shell/profile_service_loader.cc b/mojo/shell/profile_service_loader.cc index 217fa4f..741d2f2 100644 --- a/mojo/shell/profile_service_loader.cc +++ b/mojo/shell/profile_service_loader.cc @@ -4,7 +4,9 @@ #include "mojo/shell/profile_service_loader.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/profile/profile_service_impl.h" namespace mojo { @@ -19,13 +21,11 @@ ProfileServiceLoader::~ProfileServiceLoader() { void ProfileServiceLoader::LoadService( ServiceManager* manager, const GURL& url, - ScopedMessagePipeHandle service_provider_handle) { + ScopedMessagePipeHandle shell_handle) { uintptr_t key = reinterpret_cast<uintptr_t>(manager); if (apps_.find(key) == apps_.end()) { - scoped_ptr<Application> app( - new Application(service_provider_handle.Pass())); - app->AddService<ProfileServiceImpl>( - app->service_provider()); + scoped_ptr<ApplicationImpl> app( + new ApplicationImpl(this, shell_handle.Pass())); apps_.add(key, app.Pass()); } } @@ -35,5 +35,11 @@ void ProfileServiceLoader::OnServiceError(ServiceManager* manager, apps_.erase(reinterpret_cast<uintptr_t>(manager)); } +bool ProfileServiceLoader::ConfigureIncomingConnection( + ApplicationConnection* connection) { + connection->AddService<ProfileServiceImpl>(); + return true; +} + } // namespace shell } // namespace mojo diff --git a/mojo/shell/profile_service_loader.h b/mojo/shell/profile_service_loader.h index d6d38c7..bbb5d82 100644 --- a/mojo/shell/profile_service_loader.h +++ b/mojo/shell/profile_service_loader.h @@ -9,16 +9,17 @@ #include "base/containers/scoped_ptr_hash_map.h" #include "base/memory/scoped_ptr.h" +#include "mojo/public/cpp/application/application_delegate.h" #include "mojo/service_manager/service_loader.h" namespace mojo { -class Application; +class ApplicationImpl; namespace shell { // ServiceLoader responsible for creating connections to the ProfileService. -class ProfileServiceLoader : public ServiceLoader { +class ProfileServiceLoader : public ServiceLoader, public ApplicationDelegate { public: ProfileServiceLoader(); virtual ~ProfileServiceLoader(); @@ -28,11 +29,15 @@ class ProfileServiceLoader : public ServiceLoader { virtual void LoadService( ServiceManager* manager, const GURL& url, - ScopedMessagePipeHandle service_provider_handle) OVERRIDE; + ScopedMessagePipeHandle shell_handle) OVERRIDE; virtual void OnServiceError(ServiceManager* manager, const GURL& url) OVERRIDE; - base::ScopedPtrHashMap<uintptr_t, Application> apps_; + // ApplicationDelegate overrides. + virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) + MOJO_OVERRIDE; + + base::ScopedPtrHashMap<uintptr_t, ApplicationImpl> apps_; DISALLOW_COPY_AND_ASSIGN(ProfileServiceLoader); }; diff --git a/mojo/shell/run.cc b/mojo/shell/run.cc index 3d68404..7cd1200 100644 --- a/mojo/shell/run.cc +++ b/mojo/shell/run.cc @@ -12,6 +12,15 @@ namespace mojo { namespace shell { +class StubServiceProvider : public InterfaceImpl<ServiceProvider> { + private: + virtual void ConnectToService(const mojo::String& service_name, + ScopedMessagePipeHandle client_handle) + MOJO_OVERRIDE { + } +}; + + void Run(Context* context, const std::vector<GURL>& app_urls) { KeepAlive keep_alive(context); @@ -23,9 +32,13 @@ void Run(Context* context, const std::vector<GURL>& app_urls) { for (std::vector<GURL>::const_iterator it = app_urls.begin(); it != app_urls.end(); ++it) { - ScopedMessagePipeHandle no_handle; - context->service_manager()->ConnectToService( - *it, std::string(), no_handle.Pass(), GURL()); + // TODO(davemoore): These leak...need refs to them. + StubServiceProvider* stub_sp = new StubServiceProvider; + ServiceProviderPtr spp; + BindToProxy(stub_sp, &spp); + + context->service_manager()->ConnectToApplication( + *it, GURL(), spp.Pass()); } } diff --git a/mojo/shell/shell_test_base.cc b/mojo/shell/shell_test_base.cc index e83f746..53747be 100644 --- a/mojo/shell/shell_test_base.cc +++ b/mojo/shell/shell_test_base.cc @@ -23,10 +23,12 @@ ShellTestBase::ShellTestBase() { ShellTestBase::~ShellTestBase() { } -void ShellTestBase::LaunchServiceInProcess( +ScopedMessagePipeHandle ShellTestBase::LaunchServiceInProcess( const GURL& service_url, - const std::string& service_name, - ScopedMessagePipeHandle client_handle) { + const std::string& service_name) { + base::FilePath base_dir; + CHECK(PathService::Get(base::DIR_EXE, &base_dir)); + // On android, the library is bundled with the app. #if defined(OS_ANDROID) // On Android, the library is bundled with the app. base::FilePath service_dir; @@ -39,8 +41,8 @@ void ShellTestBase::LaunchServiceInProcess( shell_context_.mojo_url_resolver()->set_origin( net::FilePathToFileURL(service_dir).spec()); - shell_context_.service_manager()->ConnectToService( - service_url, service_name, client_handle.Pass(), GURL()); + return shell_context_.service_manager()->ConnectToServiceByName( + service_url, service_name).Pass(); } } // namespace test diff --git a/mojo/shell/shell_test_base.h b/mojo/shell/shell_test_base.h index 57e2cf7..69cc2c6 100644 --- a/mojo/shell/shell_test_base.h +++ b/mojo/shell/shell_test_base.h @@ -26,9 +26,9 @@ class ShellTestBase : public testing::Test { // Launches the given service in-process; |service_url| should typically be a // mojo: URL (the origin will be set to an "appropriate" file: URL). - void LaunchServiceInProcess(const GURL& service_url, - const std::string& service_name, - ScopedMessagePipeHandle client_handle); + ScopedMessagePipeHandle LaunchServiceInProcess( + const GURL& service_url, + const std::string& service_name); base::MessageLoop* message_loop() { return &message_loop_; } Context* shell_context() { return &shell_context_; } diff --git a/mojo/shell/shell_test_base_unittest.cc b/mojo/shell/shell_test_base_unittest.cc index 3a0d132..4b861f9 100644 --- a/mojo/shell/shell_test_base_unittest.cc +++ b/mojo/shell/shell_test_base_unittest.cc @@ -45,11 +45,10 @@ TEST_F(ShellTestBaseTest, LaunchServiceInProcess) { InterfacePtr<mojo::test::ITestService> test_service; { - MessagePipe mp; - test_service.Bind(mp.handle0.Pass()); - LaunchServiceInProcess(GURL("mojo:mojo_test_service"), - mojo::test::ITestService::Name_, - mp.handle1.Pass()); + ScopedMessagePipeHandle service_handle = + LaunchServiceInProcess(GURL("mojo:mojo_test_service"), + mojo::test::ITestService::Name_); + test_service.Bind(service_handle.Pass()); } bool was_run = false; @@ -73,11 +72,10 @@ TEST_F(ShellTestBaseTest, LaunchServiceInProcessInvalidService) { InterfacePtr<mojo::test::ITestService> test_service; { - MessagePipe mp; - test_service.Bind(mp.handle0.Pass()); - LaunchServiceInProcess(GURL("mojo:non_existent_service"), - mojo::test::ITestService::Name_, - mp.handle1.Pass()); + ScopedMessagePipeHandle service_handle = + LaunchServiceInProcess(GURL("mojo:non_existent_service"), + mojo::test::ITestService::Name_); + test_service.Bind(service_handle.Pass()); } bool was_run = false; diff --git a/mojo/shell/shell_test_helper.cc b/mojo/shell/shell_test_helper.cc index cec75ce..5bf83ab 100644 --- a/mojo/shell/shell_test_helper.cc +++ b/mojo/shell/shell_test_helper.cc @@ -11,22 +11,6 @@ namespace mojo { namespace shell { -class ShellTestHelper::TestServiceProvider : public ServiceProvider { - public: - TestServiceProvider() {} - virtual ~TestServiceProvider() {} - - // ServiceProvider: - virtual void ConnectToService( - const mojo::String& service_url, - const mojo::String& service_name, - ScopedMessagePipeHandle client_handle, - const mojo::String& requestor_url) OVERRIDE {} - - private: - DISALLOW_COPY_AND_ASSIGN(TestServiceProvider); -}; - ShellTestHelper::ShellTestHelper() { base::CommandLine::Init(0, NULL); mojo::shell::InitializeLogging(); @@ -38,9 +22,6 @@ ShellTestHelper::~ShellTestHelper() { void ShellTestHelper::Init() { context_.reset(new Context); test_api_.reset(new ServiceManager::TestAPI(context_->service_manager())); - local_service_provider_.reset(new TestServiceProvider); - service_provider_.Bind(test_api_->GetServiceProviderHandle().Pass()); - service_provider_.set_client(local_service_provider_.get()); } void ShellTestHelper::SetLoaderForURL(scoped_ptr<ServiceLoader> loader, diff --git a/mojo/shell/shell_test_helper.h b/mojo/shell/shell_test_helper.h index ef8af89..6d8953c 100644 --- a/mojo/shell/shell_test_helper.h +++ b/mojo/shell/shell_test_helper.h @@ -30,28 +30,17 @@ class ShellTestHelper { void Init(); - // Returns a handle to the ServiceProvider. ShellTestHelper owns the + // Returns a handle to the ServiceManager. ShellTestHelper owns the // ServiceProvider. - ServiceProvider* service_provider() { return service_provider_.get(); } + ServiceManager* service_manager() { return context_->service_manager(); } // Sets a ServiceLoader for the specified URL. |loader| is ultimately used on // the thread this class spawns. void SetLoaderForURL(scoped_ptr<ServiceLoader> loader, const GURL& url); private: - class TestServiceProvider; - scoped_ptr<Context> context_; - scoped_ptr<ServiceManager::TestAPI> test_api_; - - // ScopedMessagePipeHandle service_provider_handle_; - - // Client interface for the shell. - scoped_ptr<TestServiceProvider> local_service_provider_; - - 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 278ab81..e41a874 100644 --- a/mojo/shell/view_manager_loader.cc +++ b/mojo/shell/view_manager_loader.cc @@ -4,7 +4,8 @@ #include "mojo/shell/view_manager_loader.h" -#include "mojo/public/cpp/application/application.h" +#include "mojo/public/cpp/application/application_connection.h" +#include "mojo/public/cpp/application/application_impl.h" #include "mojo/services/view_manager/view_manager_init_service_impl.h" namespace mojo { @@ -19,12 +20,11 @@ ViewManagerLoader::~ViewManagerLoader() { void ViewManagerLoader::LoadService( ServiceManager* manager, const GURL& url, - ScopedMessagePipeHandle service_provider_handle) { + ScopedMessagePipeHandle shell_handle) { // TODO(sky): this needs some sort of authentication as well as making sure // we only ever have one active at a time. - scoped_ptr<Application> app(new Application(service_provider_handle.Pass())); - app->AddService<view_manager::service::ViewManagerInitServiceImpl>( - app->service_provider()); + scoped_ptr<ApplicationImpl> app( + new ApplicationImpl(this, shell_handle.Pass())); apps_.push_back(app.release()); } @@ -32,5 +32,11 @@ void ViewManagerLoader::OnServiceError(ServiceManager* manager, const GURL& url) { } +bool ViewManagerLoader::ConfigureIncomingConnection( + mojo::ApplicationConnection* connection) { + connection->AddService<view_manager::service::ViewManagerInitServiceImpl>(); + return true; +} + } // namespace shell } // namespace mojo diff --git a/mojo/shell/view_manager_loader.h b/mojo/shell/view_manager_loader.h index 8bebc57..85454e2 100644 --- a/mojo/shell/view_manager_loader.h +++ b/mojo/shell/view_manager_loader.h @@ -7,6 +7,7 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" +#include "mojo/public/cpp/application/application_delegate.h" #include "mojo/service_manager/service_loader.h" namespace mojo { @@ -16,7 +17,7 @@ class Application; namespace shell { // ServiceLoader responsible for creating connections to the ViewManager. -class ViewManagerLoader : public ServiceLoader { +class ViewManagerLoader : public ServiceLoader, public ApplicationDelegate { public: ViewManagerLoader(); virtual ~ViewManagerLoader(); @@ -26,10 +27,14 @@ class ViewManagerLoader : public ServiceLoader { virtual void LoadService( ServiceManager* manager, const GURL& url, - ScopedMessagePipeHandle service_provider_handle) OVERRIDE; + ScopedMessagePipeHandle shell_handle) OVERRIDE; virtual void OnServiceError(ServiceManager* manager, const GURL& url) OVERRIDE; + // ApplicationDelegate overrides. + virtual bool ConfigureIncomingConnection( + mojo::ApplicationConnection* connection) MOJO_OVERRIDE; + ScopedVector<Application> apps_; DISALLOW_COPY_AND_ASSIGN(ViewManagerLoader); |