| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "mojo/runner/context.h" | 5 #include "mojo/runner/context.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "base/process/process_info.h" | 21 #include "base/process/process_info.h" |
| 22 #include "base/run_loop.h" | 22 #include "base/run_loop.h" |
| 23 #include "base/strings/string_number_conversions.h" | 23 #include "base/strings/string_number_conversions.h" |
| 24 #include "base/strings/string_split.h" | 24 #include "base/strings/string_split.h" |
| 25 #include "base/strings/string_util.h" | 25 #include "base/strings/string_util.h" |
| 26 #include "base/trace_event/trace_event.h" | 26 #include "base/trace_event/trace_event.h" |
| 27 #include "build/build_config.h" | 27 #include "build/build_config.h" |
| 28 #include "components/devtools_service/public/cpp/switches.h" | 28 #include "components/devtools_service/public/cpp/switches.h" |
| 29 #include "components/devtools_service/public/interfaces/devtools_service.mojom.h
" | 29 #include "components/devtools_service/public/interfaces/devtools_service.mojom.h
" |
| 30 #include "components/tracing/tracing_switches.h" | 30 #include "components/tracing/tracing_switches.h" |
| 31 #include "mojo/edk/embedder/embedder.h" |
| 31 #include "mojo/public/cpp/bindings/strong_binding.h" | 32 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 32 #include "mojo/runner/host/in_process_native_runner.h" | 33 #include "mojo/runner/host/in_process_native_runner.h" |
| 33 #include "mojo/runner/host/out_of_process_native_runner.h" | 34 #include "mojo/runner/host/out_of_process_native_runner.h" |
| 34 #include "mojo/runner/register_local_aliases.h" | 35 #include "mojo/runner/register_local_aliases.h" |
| 35 #include "mojo/runner/switches.h" | 36 #include "mojo/runner/switches.h" |
| 36 #include "mojo/runner/tracer.h" | 37 #include "mojo/runner/tracer.h" |
| 37 #include "mojo/services/tracing/public/cpp/switches.h" | 38 #include "mojo/services/tracing/public/cpp/switches.h" |
| 38 #include "mojo/services/tracing/public/cpp/trace_provider_impl.h" | 39 #include "mojo/services/tracing/public/cpp/trace_provider_impl.h" |
| 39 #include "mojo/services/tracing/public/cpp/tracing_impl.h" | 40 #include "mojo/services/tracing/public/cpp/tracing_impl.h" |
| 40 #include "mojo/services/tracing/public/interfaces/tracing.mojom.h" | 41 #include "mojo/services/tracing/public/interfaces/tracing.mojom.h" |
| 41 #include "mojo/shell/application_loader.h" | 42 #include "mojo/shell/application_loader.h" |
| 42 #include "mojo/shell/connect_to_application_params.h" | 43 #include "mojo/shell/connect_to_application_params.h" |
| 43 #include "mojo/shell/package_manager/package_manager_impl.h" | 44 #include "mojo/shell/package_manager/package_manager_impl.h" |
| 44 #include "mojo/shell/public/cpp/application_connection.h" | 45 #include "mojo/shell/public/cpp/application_connection.h" |
| 45 #include "mojo/shell/public/cpp/application_delegate.h" | 46 #include "mojo/shell/public/cpp/application_delegate.h" |
| 46 #include "mojo/shell/public/cpp/application_impl.h" | 47 #include "mojo/shell/public/cpp/application_impl.h" |
| 47 #include "mojo/shell/query_util.h" | 48 #include "mojo/shell/query_util.h" |
| 48 #include "mojo/shell/switches.h" | 49 #include "mojo/shell/switches.h" |
| 49 #include "mojo/util/filename_util.h" | 50 #include "mojo/util/filename_util.h" |
| 50 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" | |
| 51 #include "url/gurl.h" | 51 #include "url/gurl.h" |
| 52 | 52 |
| 53 namespace mojo { | 53 namespace mojo { |
| 54 namespace runner { | 54 namespace runner { |
| 55 namespace { | 55 namespace { |
| 56 | 56 |
| 57 // Used to ensure we only init once. | 57 // Used to ensure we only init once. |
| 58 class Setup { | 58 class Setup { |
| 59 public: | 59 public: |
| 60 Setup() { | 60 Setup() { |
| 61 embedder::PreInitializeParentProcess(); | 61 edk::PreInitializeParentProcess(); |
| 62 embedder::Init(); | 62 edk::Init(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 ~Setup() {} | 65 ~Setup() {} |
| 66 | 66 |
| 67 private: | 67 private: |
| 68 DISALLOW_COPY_AND_ASSIGN(Setup); | 68 DISALLOW_COPY_AND_ASSIGN(Setup); |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 void InitContentHandlers(shell::PackageManagerImpl* manager, | 71 void InitContentHandlers(shell::PackageManagerImpl* manager, |
| 72 const base::CommandLine& command_line) { | 72 const base::CommandLine& command_line) { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 } | 205 } |
| 206 | 206 |
| 207 // ICU data is a thing every part of the system needs. This here warms | 207 // ICU data is a thing every part of the system needs. This here warms |
| 208 // up the copy of ICU in the mojo runner. | 208 // up the copy of ICU in the mojo runner. |
| 209 CHECK(base::i18n::InitializeICU()); | 209 CHECK(base::i18n::InitializeICU()); |
| 210 | 210 |
| 211 EnsureEmbedderIsInitialized(); | 211 EnsureEmbedderIsInitialized(); |
| 212 task_runners_.reset( | 212 task_runners_.reset( |
| 213 new TaskRunners(base::MessageLoop::current()->task_runner())); | 213 new TaskRunners(base::MessageLoop::current()->task_runner())); |
| 214 | 214 |
| 215 // TODO(vtl): This should be MASTER, not NONE. | 215 edk::InitIPCSupport(this, task_runners_->io_runner()); |
| 216 embedder::InitIPCSupport(embedder::ProcessType::NONE, this, | |
| 217 task_runners_->io_runner(), | |
| 218 embedder::ScopedPlatformHandle()); | |
| 219 | 216 |
| 220 package_manager_ = new shell::PackageManagerImpl( | 217 package_manager_ = new shell::PackageManagerImpl( |
| 221 shell_file_root, task_runners_->blocking_pool()); | 218 shell_file_root, task_runners_->blocking_pool()); |
| 222 InitContentHandlers(package_manager_, command_line); | 219 InitContentHandlers(package_manager_, command_line); |
| 223 | 220 |
| 224 RegisterLocalAliases(package_manager_); | 221 RegisterLocalAliases(package_manager_); |
| 225 | 222 |
| 226 scoped_ptr<shell::NativeRunnerFactory> runner_factory; | 223 scoped_ptr<shell::NativeRunnerFactory> runner_factory; |
| 227 if (command_line.HasSwitch(switches::kEnableMultiprocess)) { | 224 if (command_line.HasSwitch(switches::kEnableMultiprocess)) { |
| 228 runner_factory.reset( | 225 runner_factory.reset( |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 // Actions triggered by ApplicationManager's destructor may require a current | 283 // Actions triggered by ApplicationManager's destructor may require a current |
| 287 // message loop, so we should destruct it explicitly now as ~Context() occurs | 284 // message loop, so we should destruct it explicitly now as ~Context() occurs |
| 288 // post message loop shutdown. | 285 // post message loop shutdown. |
| 289 application_manager_.reset(); | 286 application_manager_.reset(); |
| 290 | 287 |
| 291 TRACE_EVENT0("mojo_shell", "Context::Shutdown"); | 288 TRACE_EVENT0("mojo_shell", "Context::Shutdown"); |
| 292 DCHECK_EQ(base::MessageLoop::current()->task_runner(), | 289 DCHECK_EQ(base::MessageLoop::current()->task_runner(), |
| 293 task_runners_->shell_runner()); | 290 task_runners_->shell_runner()); |
| 294 // Post a task in case OnShutdownComplete is called synchronously. | 291 // Post a task in case OnShutdownComplete is called synchronously. |
| 295 base::MessageLoop::current()->PostTask( | 292 base::MessageLoop::current()->PostTask( |
| 296 FROM_HERE, base::Bind(embedder::ShutdownIPCSupport)); | 293 FROM_HERE, base::Bind(edk::ShutdownIPCSupport)); |
| 297 // We'll quit when we get OnShutdownComplete(). | 294 // We'll quit when we get OnShutdownComplete(). |
| 298 base::MessageLoop::current()->Run(); | 295 base::MessageLoop::current()->Run(); |
| 299 } | 296 } |
| 300 | 297 |
| 301 void Context::OnShutdownComplete() { | 298 void Context::OnShutdownComplete() { |
| 302 DCHECK_EQ(base::MessageLoop::current()->task_runner(), | 299 DCHECK_EQ(base::MessageLoop::current()->task_runner(), |
| 303 task_runners_->shell_runner()); | 300 task_runners_->shell_runner()); |
| 304 base::MessageLoop::current()->QuitWhenIdle(); | 301 base::MessageLoop::current()->QuitWhenIdle(); |
| 305 } | 302 } |
| 306 | 303 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 base::MessageLoop::current()->QuitWhenIdle(); | 344 base::MessageLoop::current()->QuitWhenIdle(); |
| 348 } else { | 345 } else { |
| 349 app_complete_callback_.Run(); | 346 app_complete_callback_.Run(); |
| 350 } | 347 } |
| 351 } | 348 } |
| 352 } | 349 } |
| 353 } | 350 } |
| 354 | 351 |
| 355 } // namespace runner | 352 } // namespace runner |
| 356 } // namespace mojo | 353 } // namespace mojo |
| OLD | NEW |