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 "services/service_manager/standalone/context.h" | 5 #include "services/service_manager/standalone/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 20 matching lines...) Expand all Loading... |
31 #include "base/trace_event/trace_event.h" | 31 #include "base/trace_event/trace_event.h" |
32 #include "build/build_config.h" | 32 #include "build/build_config.h" |
33 #include "components/tracing/common/tracing_switches.h" | 33 #include "components/tracing/common/tracing_switches.h" |
34 #include "mojo/edk/embedder/embedder.h" | 34 #include "mojo/edk/embedder/embedder.h" |
35 #include "mojo/public/cpp/bindings/strong_binding.h" | 35 #include "mojo/public/cpp/bindings/strong_binding.h" |
36 #include "services/catalog/catalog.h" | 36 #include "services/catalog/catalog.h" |
37 #include "services/catalog/store.h" | 37 #include "services/catalog/store.h" |
38 #include "services/service_manager/connect_params.h" | 38 #include "services/service_manager/connect_params.h" |
39 #include "services/service_manager/connect_util.h" | 39 #include "services/service_manager/connect_util.h" |
40 #include "services/service_manager/runner/common/switches.h" | 40 #include "services/service_manager/runner/common/switches.h" |
41 #include "services/service_manager/runner/host/out_of_process_native_runner.h" | 41 #include "services/service_manager/runner/host/service_process_launcher.h" |
42 #include "services/service_manager/standalone/tracer.h" | 42 #include "services/service_manager/standalone/tracer.h" |
43 #include "services/service_manager/switches.h" | 43 #include "services/service_manager/switches.h" |
44 #include "services/tracing/public/cpp/provider.h" | 44 #include "services/tracing/public/cpp/provider.h" |
45 #include "services/tracing/public/cpp/switches.h" | 45 #include "services/tracing/public/cpp/switches.h" |
46 #include "services/tracing/public/interfaces/constants.mojom.h" | 46 #include "services/tracing/public/interfaces/constants.mojom.h" |
47 #include "services/tracing/public/interfaces/tracing.mojom.h" | 47 #include "services/tracing/public/interfaces/tracing.mojom.h" |
48 | 48 |
49 #if defined(OS_MACOSX) | 49 #if defined(OS_MACOSX) |
50 #include "services/service_manager/public/cpp/standalone_service/mach_broker.h" | 50 #include "services/service_manager/public/cpp/standalone_service/mach_broker.h" |
51 #endif | 51 #endif |
(...skipping 14 matching lines...) Expand all Loading... |
66 class Setup { | 66 class Setup { |
67 public: | 67 public: |
68 Setup() { mojo::edk::Init(); } | 68 Setup() { mojo::edk::Init(); } |
69 | 69 |
70 ~Setup() {} | 70 ~Setup() {} |
71 | 71 |
72 private: | 72 private: |
73 DISALLOW_COPY_AND_ASSIGN(Setup); | 73 DISALLOW_COPY_AND_ASSIGN(Setup); |
74 }; | 74 }; |
75 | 75 |
| 76 class ServiceProcessLauncherFactoryImpl : public ServiceProcessLauncherFactory { |
| 77 public: |
| 78 ServiceProcessLauncherFactoryImpl(base::TaskRunner* launch_process_runner, |
| 79 ServiceProcessLauncher::Delegate* delegate) |
| 80 : launch_process_runner_(launch_process_runner), |
| 81 delegate_(delegate) { |
| 82 } |
| 83 |
| 84 private: |
| 85 std::unique_ptr<ServiceProcessLauncher> Create( |
| 86 const base::FilePath& service_path) override { |
| 87 return base::MakeUnique<ServiceProcessLauncher>( |
| 88 launch_process_runner_, delegate_, service_path); |
| 89 } |
| 90 |
| 91 base::TaskRunner* launch_process_runner_; |
| 92 ServiceProcessLauncher::Delegate* delegate_; |
| 93 }; |
| 94 |
76 std::unique_ptr<base::Thread> CreateIOThread(const char* name) { | 95 std::unique_ptr<base::Thread> CreateIOThread(const char* name) { |
77 std::unique_ptr<base::Thread> thread(new base::Thread(name)); | 96 std::unique_ptr<base::Thread> thread(new base::Thread(name)); |
78 base::Thread::Options options; | 97 base::Thread::Options options; |
79 options.message_loop_type = base::MessageLoop::TYPE_IO; | 98 options.message_loop_type = base::MessageLoop::TYPE_IO; |
80 thread->StartWithOptions(options); | 99 thread->StartWithOptions(options); |
81 return thread; | 100 return thread; |
82 } | 101 } |
83 | 102 |
84 void OnInstanceQuit(const std::string& name, const Identity& identity) { | 103 void OnInstanceQuit(const std::string& name, const Identity& identity) { |
85 if (name == identity.name()) | 104 if (name == identity.name()) |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 kThreadPoolMaxThreads, "blocking_pool", base::TaskPriority::USER_VISIBLE); | 148 kThreadPoolMaxThreads, "blocking_pool", base::TaskPriority::USER_VISIBLE); |
130 | 149 |
131 init_edk_ = !init_params || init_params->init_edk; | 150 init_edk_ = !init_params || init_params->init_edk; |
132 if (init_edk_) { | 151 if (init_edk_) { |
133 mojo::edk::InitIPCSupport(this, io_thread_->task_runner().get()); | 152 mojo::edk::InitIPCSupport(this, io_thread_->task_runner().get()); |
134 #if defined(OS_MACOSX) | 153 #if defined(OS_MACOSX) |
135 mojo::edk::SetMachPortProvider(MachBroker::GetInstance()->port_provider()); | 154 mojo::edk::SetMachPortProvider(MachBroker::GetInstance()->port_provider()); |
136 #endif | 155 #endif |
137 } | 156 } |
138 | 157 |
139 std::unique_ptr<NativeRunnerFactory> runner_factory = | 158 std::unique_ptr<ServiceProcessLauncherFactory> |
140 base::MakeUnique<OutOfProcessNativeRunnerFactory>( | 159 service_process_launcher_factory = |
| 160 base::MakeUnique<ServiceProcessLauncherFactoryImpl>( |
141 blocking_pool_.get(), | 161 blocking_pool_.get(), |
142 init_params ? init_params->native_runner_delegate : nullptr); | 162 init_params ? init_params->service_process_launcher_delegate |
| 163 : nullptr); |
143 std::unique_ptr<catalog::Store> store; | 164 std::unique_ptr<catalog::Store> store; |
144 if (init_params) | 165 if (init_params) |
145 store = std::move(init_params->catalog_store); | 166 store = std::move(init_params->catalog_store); |
146 catalog_.reset( | 167 catalog_.reset( |
147 new catalog::Catalog(blocking_pool_.get(), std::move(store), nullptr)); | 168 new catalog::Catalog(blocking_pool_.get(), std::move(store), nullptr)); |
148 service_manager_.reset(new ServiceManager(std::move(runner_factory), | 169 service_manager_.reset( |
149 catalog_->TakeService())); | 170 new ServiceManager(std::move(service_process_launcher_factory), |
| 171 catalog_->TakeService())); |
150 | 172 |
151 if (command_line.HasSwitch(::switches::kServiceOverrides)) { | 173 if (command_line.HasSwitch(::switches::kServiceOverrides)) { |
152 base::FilePath overrides_file(GetPathFromCommandLineSwitch( | 174 base::FilePath overrides_file(GetPathFromCommandLineSwitch( |
153 command_line.GetSwitchValueASCII(::switches::kServiceOverrides))); | 175 command_line.GetSwitchValueASCII(::switches::kServiceOverrides))); |
154 JSONFileValueDeserializer deserializer(overrides_file); | 176 JSONFileValueDeserializer deserializer(overrides_file); |
155 int error = 0; | 177 int error = 0; |
156 std::string message; | 178 std::string message; |
157 std::unique_ptr<base::Value> contents = | 179 std::unique_ptr<base::Value> contents = |
158 deserializer.Deserialize(&error, &message); | 180 deserializer.Deserialize(&error, &message); |
159 if (!contents) { | 181 if (!contents) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 mojom::InterfaceProviderPtr local_interfaces; | 266 mojom::InterfaceProviderPtr local_interfaces; |
245 | 267 |
246 std::unique_ptr<ConnectParams> params(new ConnectParams); | 268 std::unique_ptr<ConnectParams> params(new ConnectParams); |
247 params->set_source(CreateServiceManagerIdentity()); | 269 params->set_source(CreateServiceManagerIdentity()); |
248 params->set_target(Identity(name, mojom::kRootUserID)); | 270 params->set_target(Identity(name, mojom::kRootUserID)); |
249 params->set_remote_interfaces(mojo::GetProxy(&remote_interfaces)); | 271 params->set_remote_interfaces(mojo::GetProxy(&remote_interfaces)); |
250 service_manager_->Connect(std::move(params)); | 272 service_manager_->Connect(std::move(params)); |
251 } | 273 } |
252 | 274 |
253 } // namespace service_manager | 275 } // namespace service_manager |
OLD | NEW |