| 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/in_process_native_runner.h" | |
| 42 #include "services/service_manager/runner/host/out_of_process_native_runner.h" | 41 #include "services/service_manager/runner/host/out_of_process_native_runner.h" |
| 43 #include "services/service_manager/standalone/tracer.h" | 42 #include "services/service_manager/standalone/tracer.h" |
| 44 #include "services/service_manager/switches.h" | 43 #include "services/service_manager/switches.h" |
| 45 #include "services/tracing/public/cpp/provider.h" | 44 #include "services/tracing/public/cpp/provider.h" |
| 46 #include "services/tracing/public/cpp/switches.h" | 45 #include "services/tracing/public/cpp/switches.h" |
| 47 #include "services/tracing/public/interfaces/constants.mojom.h" | 46 #include "services/tracing/public/interfaces/constants.mojom.h" |
| 48 #include "services/tracing/public/interfaces/tracing.mojom.h" | 47 #include "services/tracing/public/interfaces/tracing.mojom.h" |
| 49 | 48 |
| 50 #if defined(OS_MACOSX) | 49 #if defined(OS_MACOSX) |
| 51 #include "services/service_manager/runner/host/mach_broker.h" | 50 #include "services/service_manager/public/cpp/standalone_service/mach_broker.h" |
| 52 #endif | 51 #endif |
| 53 | 52 |
| 54 namespace service_manager { | 53 namespace service_manager { |
| 55 namespace { | 54 namespace { |
| 56 | 55 |
| 57 base::FilePath::StringType GetPathFromCommandLineSwitch( | 56 base::FilePath::StringType GetPathFromCommandLineSwitch( |
| 58 const base::StringPiece& value) { | 57 const base::StringPiece& value) { |
| 59 #if defined(OS_POSIX) | 58 #if defined(OS_POSIX) |
| 60 return value.as_string(); | 59 return value.as_string(); |
| 61 #elif defined(OS_WIN) | 60 #elif defined(OS_WIN) |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 kThreadPoolMaxThreads, "blocking_pool", base::TaskPriority::USER_VISIBLE); | 129 kThreadPoolMaxThreads, "blocking_pool", base::TaskPriority::USER_VISIBLE); |
| 131 | 130 |
| 132 init_edk_ = !init_params || init_params->init_edk; | 131 init_edk_ = !init_params || init_params->init_edk; |
| 133 if (init_edk_) { | 132 if (init_edk_) { |
| 134 mojo::edk::InitIPCSupport(this, io_thread_->task_runner().get()); | 133 mojo::edk::InitIPCSupport(this, io_thread_->task_runner().get()); |
| 135 #if defined(OS_MACOSX) | 134 #if defined(OS_MACOSX) |
| 136 mojo::edk::SetMachPortProvider(MachBroker::GetInstance()->port_provider()); | 135 mojo::edk::SetMachPortProvider(MachBroker::GetInstance()->port_provider()); |
| 137 #endif | 136 #endif |
| 138 } | 137 } |
| 139 | 138 |
| 140 std::unique_ptr<NativeRunnerFactory> runner_factory; | 139 std::unique_ptr<NativeRunnerFactory> runner_factory = |
| 141 if (command_line.HasSwitch(switches::kSingleProcess)) { | 140 base::MakeUnique<OutOfProcessNativeRunnerFactory>( |
| 142 #if defined(COMPONENT_BUILD) | 141 blocking_pool_.get(), |
| 143 LOG(ERROR) << "Running Mojo in single process component build, which isn't " | 142 init_params ? init_params->native_runner_delegate : nullptr); |
| 144 << "supported because statics in apps interact. Use static build" | |
| 145 << " or don't pass --single-process."; | |
| 146 #endif | |
| 147 runner_factory.reset( | |
| 148 new InProcessNativeRunnerFactory(blocking_pool_.get())); | |
| 149 } else { | |
| 150 NativeRunnerDelegate* native_runner_delegate = init_params ? | |
| 151 init_params->native_runner_delegate : nullptr; | |
| 152 runner_factory.reset(new OutOfProcessNativeRunnerFactory( | |
| 153 blocking_pool_.get(), native_runner_delegate)); | |
| 154 } | |
| 155 std::unique_ptr<catalog::Store> store; | 143 std::unique_ptr<catalog::Store> store; |
| 156 if (init_params) | 144 if (init_params) |
| 157 store = std::move(init_params->catalog_store); | 145 store = std::move(init_params->catalog_store); |
| 158 catalog_.reset( | 146 catalog_.reset( |
| 159 new catalog::Catalog(blocking_pool_.get(), std::move(store), nullptr)); | 147 new catalog::Catalog(blocking_pool_.get(), std::move(store), nullptr)); |
| 160 service_manager_.reset(new ServiceManager(std::move(runner_factory), | 148 service_manager_.reset(new ServiceManager(std::move(runner_factory), |
| 161 catalog_->TakeService())); | 149 catalog_->TakeService())); |
| 162 | 150 |
| 163 if (command_line.HasSwitch(::switches::kServiceOverrides)) { | 151 if (command_line.HasSwitch(::switches::kServiceOverrides)) { |
| 164 base::FilePath overrides_file(GetPathFromCommandLineSwitch( | 152 base::FilePath overrides_file(GetPathFromCommandLineSwitch( |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 mojom::InterfaceProviderPtr local_interfaces; | 244 mojom::InterfaceProviderPtr local_interfaces; |
| 257 | 245 |
| 258 std::unique_ptr<ConnectParams> params(new ConnectParams); | 246 std::unique_ptr<ConnectParams> params(new ConnectParams); |
| 259 params->set_source(CreateServiceManagerIdentity()); | 247 params->set_source(CreateServiceManagerIdentity()); |
| 260 params->set_target(Identity(name, mojom::kRootUserID)); | 248 params->set_target(Identity(name, mojom::kRootUserID)); |
| 261 params->set_remote_interfaces(mojo::GetProxy(&remote_interfaces)); | 249 params->set_remote_interfaces(mojo::GetProxy(&remote_interfaces)); |
| 262 service_manager_->Connect(std::move(params)); | 250 service_manager_->Connect(std::move(params)); |
| 263 } | 251 } |
| 264 | 252 |
| 265 } // namespace service_manager | 253 } // namespace service_manager |
| OLD | NEW |