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