OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/app/mash/mash_runner.h" | 5 #include "chrome/app/mash/mash_runner.h" |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/debugger.h" | 10 #include "base/debug/debugger.h" |
11 #include "base/i18n/icu_util.h" | 11 #include "base/i18n/icu_util.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/process/launch.h" | 15 #include "base/process/launch.h" |
16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
17 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
18 #include "components/tracing/common/trace_to_console.h" | 18 #include "components/tracing/common/trace_to_console.h" |
19 #include "components/tracing/common/tracing_switches.h" | 19 #include "components/tracing/common/tracing_switches.h" |
20 #include "content/public/common/content_switches.h" | 20 #include "content/public/common/content_switches.h" |
21 #include "content/public/common/service_names.h" | 21 #include "content/public/common/service_names.h" |
22 #include "mash/package/mash_packaged_service.h" | 22 #include "mash/package/mash_packaged_service.h" |
23 #include "mojo/public/cpp/bindings/binding_set.h" | 23 #include "mojo/public/cpp/bindings/binding_set.h" |
24 #include "services/catalog/public/interfaces/catalog.mojom.h" | 24 #include "services/catalog/public/interfaces/catalog.mojom.h" |
25 #include "services/service_manager/background/background_shell.h" | 25 #include "services/service_manager/background/background_service_manager.h" |
26 #include "services/service_manager/native_runner_delegate.h" | 26 #include "services/service_manager/native_runner_delegate.h" |
27 #include "services/service_manager/public/cpp/connector.h" | 27 #include "services/service_manager/public/cpp/connector.h" |
28 #include "services/service_manager/public/cpp/identity.h" | 28 #include "services/service_manager/public/cpp/identity.h" |
29 #include "services/service_manager/public/cpp/service.h" | 29 #include "services/service_manager/public/cpp/service.h" |
30 #include "services/service_manager/public/cpp/service_context.h" | 30 #include "services/service_manager/public/cpp/service_context.h" |
31 #include "services/service_manager/public/interfaces/service_factory.mojom.h" | 31 #include "services/service_manager/public/interfaces/service_factory.mojom.h" |
32 #include "services/service_manager/runner/common/switches.h" | 32 #include "services/service_manager/runner/common/switches.h" |
33 #include "services/service_manager/runner/host/child_process_base.h" | 33 #include "services/service_manager/runner/host/child_process_base.h" |
34 #include "ui/base/resource/resource_bundle.h" | 34 #include "ui/base/resource/resource_bundle.h" |
35 #include "ui/base/ui_base_paths.h" | 35 #include "ui/base/ui_base_paths.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 MashRunner::~MashRunner() {} | 116 MashRunner::~MashRunner() {} |
117 | 117 |
118 void MashRunner::Run() { | 118 void MashRunner::Run() { |
119 if (IsChild()) | 119 if (IsChild()) |
120 RunChild(); | 120 RunChild(); |
121 else | 121 else |
122 RunMain(); | 122 RunMain(); |
123 } | 123 } |
124 | 124 |
125 void MashRunner::RunMain() { | 125 void MashRunner::RunMain() { |
126 // TODO(sky): refactor backgroundshell so can supply own context, we | 126 // TODO(sky): refactor BackgroundServiceManager so can supply own context, we |
127 // shouldn't we using context as it has a lot of stuff we don't really want | 127 // shouldn't we using context as it has a lot of stuff we don't really want |
128 // in chrome. | 128 // in chrome. |
129 NativeRunnerDelegateImpl native_runner_delegate; | 129 NativeRunnerDelegateImpl native_runner_delegate; |
130 service_manager::BackgroundShell background_service_manager; | 130 service_manager::BackgroundServiceManager background_service_manager; |
131 std::unique_ptr<service_manager::BackgroundShell::InitParams> init_params( | 131 std::unique_ptr<service_manager::BackgroundServiceManager::InitParams> |
132 new service_manager::BackgroundShell::InitParams); | 132 init_params(new service_manager::BackgroundServiceManager::InitParams); |
133 init_params->native_runner_delegate = &native_runner_delegate; | 133 init_params->native_runner_delegate = &native_runner_delegate; |
134 background_service_manager.Init(std::move(init_params)); | 134 background_service_manager.Init(std::move(init_params)); |
135 service_.reset(new mash::MashPackagedService); | 135 service_.reset(new mash::MashPackagedService); |
136 service_->set_context(base::MakeUnique<service_manager::ServiceContext>( | 136 service_->set_context(base::MakeUnique<service_manager::ServiceContext>( |
137 service_.get(), | 137 service_.get(), |
138 background_service_manager.CreateServiceRequest(kChromeMashServiceName))); | 138 background_service_manager.CreateServiceRequest(kChromeMashServiceName))); |
139 | 139 |
140 // We need to send a sync messages to the Catalog, so we wait for a completed | 140 // We need to send a sync messages to the Catalog, so we wait for a completed |
141 // connection first. | 141 // connection first. |
142 std::unique_ptr<service_manager::Connection> catalog_connection = | 142 std::unique_ptr<service_manager::Connection> catalog_connection = |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 tracing::GetConfigForTraceToConsole(); | 215 tracing::GetConfigForTraceToConsole(); |
216 base::trace_event::TraceLog::GetInstance()->SetEnabled( | 216 base::trace_event::TraceLog::GetInstance()->SetEnabled( |
217 trace_config, | 217 trace_config, |
218 base::trace_event::TraceLog::RECORDING_MODE); | 218 base::trace_event::TraceLog::RECORDING_MODE); |
219 } | 219 } |
220 | 220 |
221 MashRunner mash_runner; | 221 MashRunner mash_runner; |
222 mash_runner.Run(); | 222 mash_runner.Run(); |
223 return 0; | 223 return 0; |
224 } | 224 } |
OLD | NEW |