diff options
author | sky <sky@chromium.org> | 2016-02-24 14:24:02 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-24 22:25:34 +0000 |
commit | 758df73af1b6dc37555ce3b8a7c89b39da3f5a03 (patch) | |
tree | 36b9779cf8378b239156101c32c3f43da0f24b84 /mojo/shell/standalone | |
parent | 43c8de64e250e814ea15c4240d5d4273a8272535 (diff) | |
download | chromium_src-758df73af1b6dc37555ce3b8a7c89b39da3f5a03.zip chromium_src-758df73af1b6dc37555ce3b8a7c89b39da3f5a03.tar.gz chromium_src-758df73af1b6dc37555ce3b8a7c89b39da3f5a03.tar.bz2 |
Makes PackageManager take the ApplicationCatalogStore in constructor
And plumbs through the appropriate places.
Also adds a test of all this via backroundshell.
And lastly I converted PackageManager to be in terms of GURLs. This way mojo:foo, mojo://foo and mojo://foo/ are all treated the same.
BUG=577274
TEST=covered by tests
R=ben@chromium.org
Review URL: https://codereview.chromium.org/1733463002
Cr-Commit-Position: refs/heads/master@{#377410}
Diffstat (limited to 'mojo/shell/standalone')
-rw-r--r-- | mojo/shell/standalone/BUILD.gn | 1 | ||||
-rw-r--r-- | mojo/shell/standalone/context.cc | 21 | ||||
-rw-r--r-- | mojo/shell/standalone/context.h | 20 | ||||
-rw-r--r-- | mojo/shell/standalone/desktop/launcher_process.cc | 4 |
4 files changed, 30 insertions, 16 deletions
diff --git a/mojo/shell/standalone/BUILD.gn b/mojo/shell/standalone/BUILD.gn index 46183b1..cabe62f 100644 --- a/mojo/shell/standalone/BUILD.gn +++ b/mojo/shell/standalone/BUILD.gn @@ -37,6 +37,7 @@ source_set("lib") { "//components/tracing:startup_tracing", "//mojo/edk/system", "//mojo/message_pump", + "//mojo/services/package_manager:lib", "//mojo/services/tracing/public/cpp", "//mojo/services/tracing/public/interfaces", "//mojo/shell", diff --git a/mojo/shell/standalone/context.cc b/mojo/shell/standalone/context.cc index 9b23657..72488e5 100644 --- a/mojo/shell/standalone/context.cc +++ b/mojo/shell/standalone/context.cc @@ -28,6 +28,7 @@ #include "components/tracing/tracing_switches.h" #include "mojo/edk/embedder/embedder.h" #include "mojo/public/cpp/bindings/strong_binding.h" +#include "mojo/services/package_manager/package_manager.h" #include "mojo/services/tracing/public/cpp/switches.h" #include "mojo/services/tracing/public/cpp/trace_provider_impl.h" #include "mojo/services/tracing/public/cpp/tracing_impl.h" @@ -96,10 +97,12 @@ void OnInstanceQuit(const GURL& url, const Identity& identity) { } // namespace +Context::InitParams::InitParams() {} +Context::InitParams::~InitParams() {} + Context::Context() : io_thread_(CreateIOThread("io_thread")), - main_entry_time_(base::Time::Now()), - native_runner_delegate_(nullptr) {} + main_entry_time_(base::Time::Now()) {} Context::~Context() { DCHECK(!base::MessageLoop::current()); @@ -112,7 +115,7 @@ void Context::EnsureEmbedderIsInitialized() { setup.Get(); } -void Context::Init(const base::FilePath& shell_file_root) { +void Context::Init(scoped_ptr<InitParams> init_params) { TRACE_EVENT0("mojo_shell", "Context::Init"); const base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); @@ -144,11 +147,17 @@ void Context::Init(const base::FilePath& shell_file_root) { runner_factory.reset( new InProcessNativeRunnerFactory(blocking_pool_.get())); } else { + NativeRunnerDelegate* native_runner_delegate = init_params ? + init_params->native_runner_delegate : nullptr; runner_factory.reset(new OutOfProcessNativeRunnerFactory( - blocking_pool_.get(), native_runner_delegate_)); + blocking_pool_.get(), native_runner_delegate)); } - application_manager_.reset(new ApplicationManager( - std::move(runner_factory), blocking_pool_.get(), true)); + scoped_ptr<package_manager::ApplicationCatalogStore> app_catalog; + if (init_params) + app_catalog = std::move(init_params->app_catalog); + application_manager_.reset(new ApplicationManager(std::move(runner_factory), + blocking_pool_.get(), true, + std::move(app_catalog))); shell::mojom::InterfaceProviderPtr tracing_remote_interfaces; shell::mojom::InterfaceProviderPtr tracing_local_interfaces; diff --git a/mojo/shell/standalone/context.h b/mojo/shell/standalone/context.h index e9af8fb..b4e3768 100644 --- a/mojo/shell/standalone/context.h +++ b/mojo/shell/standalone/context.h @@ -20,6 +20,10 @@ namespace base { class SingleThreadTaskRunner; } +namespace package_manager { +class ApplicationCatalogStore; +} + namespace mojo { namespace shell { class NativeRunnerDelegate; @@ -27,18 +31,22 @@ class NativeRunnerDelegate; // The "global" context for the shell's main process. class Context : public edk::ProcessDelegate { public: + struct InitParams { + InitParams(); + ~InitParams(); + + NativeRunnerDelegate* native_runner_delegate = nullptr; + scoped_ptr<package_manager::ApplicationCatalogStore> app_catalog; + }; + Context(); ~Context() override; static void EnsureEmbedderIsInitialized(); - void set_native_runner_delegate(NativeRunnerDelegate* delegate) { - native_runner_delegate_ = delegate; - } - // This must be called with a message loop set up for the current thread, // which must remain alive until after Shutdown() is called. - void Init(const base::FilePath& shell_file_root); + void Init(scoped_ptr<InitParams> init_params); // If Init() was called and succeeded, this must be called before destruction. void Shutdown(); @@ -67,8 +75,6 @@ class Context : public edk::ProcessDelegate { scoped_ptr<ApplicationManager> application_manager_; base::Time main_entry_time_; - NativeRunnerDelegate* native_runner_delegate_; - DISALLOW_COPY_AND_ASSIGN(Context); }; diff --git a/mojo/shell/standalone/desktop/launcher_process.cc b/mojo/shell/standalone/desktop/launcher_process.cc index efb6fd6..5830918 100644 --- a/mojo/shell/standalone/desktop/launcher_process.cc +++ b/mojo/shell/standalone/desktop/launcher_process.cc @@ -38,10 +38,8 @@ int LauncherProcessMain() { Context shell_context; { base::MessageLoop message_loop; - base::FilePath shell_dir; - PathService::Get(base::DIR_MODULE, &shell_dir); CHECK(base::i18n::InitializeICU()); - shell_context.Init(shell_dir); + shell_context.Init(nullptr); message_loop.PostTask( FROM_HERE, |