| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 16 #include "base/process/process_info.h" | 16 #include "base/process/process_info.h" |
| 17 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
| 18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/strings/string_split.h" | 19 #include "base/strings/string_split.h" |
| 20 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
| 21 #include "base/trace_event/trace_event.h" | 21 #include "base/trace_event/trace_event.h" |
| 22 #include "build/build_config.h" | 22 #include "build/build_config.h" |
| 23 #include "components/devtools_service/public/cpp/switches.h" | 23 #include "components/devtools_service/public/cpp/switches.h" |
| 24 #include "components/devtools_service/public/interfaces/devtools_service.mojom.h
" | 24 #include "components/devtools_service/public/interfaces/devtools_service.mojom.h
" |
| 25 #include "mojo/application/public/cpp/application_connection.h" | 25 #include "mojo/application/public/cpp/application_connection.h" |
| 26 #include "mojo/application/public/cpp/application_delegate.h" | 26 #include "mojo/application/public/cpp/application_delegate.h" |
| 27 #include "mojo/application/public/cpp/application_impl.h" | 27 #include "mojo/application/public/cpp/application_impl.h" |
| 28 #include "mojo/common/trace_controller_impl.h" | 28 #include "mojo/common/trace_controller_impl.h" |
| 29 #include "mojo/common/tracing_impl.h" | 29 #include "mojo/common/tracing_impl.h" |
| 30 #include "mojo/edk/embedder/embedder.h" | |
| 31 #include "mojo/edk/embedder/simple_platform_support.h" | |
| 32 #include "mojo/package_manager/package_manager_impl.h" | 30 #include "mojo/package_manager/package_manager_impl.h" |
| 33 #include "mojo/runner/in_process_native_runner.h" | 31 #include "mojo/runner/in_process_native_runner.h" |
| 34 #include "mojo/runner/out_of_process_native_runner.h" | 32 #include "mojo/runner/out_of_process_native_runner.h" |
| 35 #include "mojo/runner/switches.h" | 33 #include "mojo/runner/switches.h" |
| 36 #include "mojo/services/tracing/public/cpp/switches.h" | 34 #include "mojo/services/tracing/public/cpp/switches.h" |
| 37 #include "mojo/services/tracing/public/interfaces/tracing.mojom.h" | 35 #include "mojo/services/tracing/public/interfaces/tracing.mojom.h" |
| 38 #include "mojo/shell/application_loader.h" | 36 #include "mojo/shell/application_loader.h" |
| 39 #include "mojo/shell/connect_to_application_params.h" | 37 #include "mojo/shell/connect_to_application_params.h" |
| 40 #include "mojo/shell/query_util.h" | 38 #include "mojo/shell/query_util.h" |
| 41 #include "mojo/shell/switches.h" | 39 #include "mojo/shell/switches.h" |
| 42 #include "mojo/util/filename_util.h" | 40 #include "mojo/util/filename_util.h" |
| 41 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" |
| 43 #include "url/gurl.h" | 42 #include "url/gurl.h" |
| 44 | 43 |
| 45 namespace mojo { | 44 namespace mojo { |
| 46 namespace runner { | 45 namespace runner { |
| 47 namespace { | 46 namespace { |
| 48 | 47 |
| 49 // Used to ensure we only init once. | 48 // Used to ensure we only init once. |
| 50 class Setup { | 49 class Setup { |
| 51 public: | 50 public: |
| 52 Setup() { | 51 Setup() { |
| 53 embedder::Init(make_scoped_ptr(new embedder::SimplePlatformSupport())); | 52 embedder::Init(); |
| 54 } | 53 } |
| 55 | 54 |
| 56 ~Setup() {} | 55 ~Setup() {} |
| 57 | 56 |
| 58 private: | 57 private: |
| 59 DISALLOW_COPY_AND_ASSIGN(Setup); | 58 DISALLOW_COPY_AND_ASSIGN(Setup); |
| 60 }; | 59 }; |
| 61 | 60 |
| 62 void InitContentHandlers(package_manager::PackageManagerImpl* manager, | 61 void InitContentHandlers(package_manager::PackageManagerImpl* manager, |
| 63 const base::CommandLine& command_line) { | 62 const base::CommandLine& command_line) { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 } | 182 } |
| 184 | 183 |
| 185 bool Context::Init() { | 184 bool Context::Init() { |
| 186 TRACE_EVENT0("mojo_shell", "Context::Init"); | 185 TRACE_EVENT0("mojo_shell", "Context::Init"); |
| 187 const base::CommandLine& command_line = | 186 const base::CommandLine& command_line = |
| 188 *base::CommandLine::ForCurrentProcess(); | 187 *base::CommandLine::ForCurrentProcess(); |
| 189 | 188 |
| 190 EnsureEmbedderIsInitialized(); | 189 EnsureEmbedderIsInitialized(); |
| 191 task_runners_.reset( | 190 task_runners_.reset( |
| 192 new TaskRunners(base::MessageLoop::current()->task_runner())); | 191 new TaskRunners(base::MessageLoop::current()->task_runner())); |
| 193 | |
| 194 // TODO(vtl): This should be MASTER, not NONE. | 192 // TODO(vtl): This should be MASTER, not NONE. |
| 195 embedder::InitIPCSupport( | 193 embedder::InitIPCSupport( |
| 196 embedder::ProcessType::NONE, task_runners_->shell_runner(), this, | 194 embedder::ProcessType::NONE, task_runners_->shell_runner(), this, |
| 197 task_runners_->io_runner(), embedder::ScopedPlatformHandle()); | 195 task_runners_->io_runner(), embedder::ScopedPlatformHandle()); |
| 198 | 196 |
| 199 package_manager_ = new package_manager::PackageManagerImpl( | 197 package_manager_ = new package_manager::PackageManagerImpl( |
| 200 shell_file_root_, task_runners_->blocking_pool()); | 198 shell_file_root_, task_runners_->blocking_pool()); |
| 201 InitContentHandlers(package_manager_, command_line); | 199 InitContentHandlers(package_manager_, command_line); |
| 202 | 200 |
| 203 scoped_ptr<shell::NativeRunnerFactory> runner_factory; | 201 scoped_ptr<shell::NativeRunnerFactory> runner_factory; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 base::MessageLoop::current()->Quit(); | 304 base::MessageLoop::current()->Quit(); |
| 307 } else { | 305 } else { |
| 308 app_complete_callback_.Run(); | 306 app_complete_callback_.Run(); |
| 309 } | 307 } |
| 310 } | 308 } |
| 311 } | 309 } |
| 312 } | 310 } |
| 313 | 311 |
| 314 } // namespace runner | 312 } // namespace runner |
| 315 } // namespace mojo | 313 } // namespace mojo |
| OLD | NEW |