Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: chrome/app/mash/mash_runner.cc

Issue 2557213002: Build services as standalone executables (Closed)
Patch Set: remove DCHECKs with side effects -_- Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/app/mash/BUILD.gn ('k') | chrome/test/base/mash_browser_tests_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 14 matching lines...) Expand all
25 #include "mash/package/mash_packaged_service.h" 25 #include "mash/package/mash_packaged_service.h"
26 #include "mojo/public/cpp/bindings/binding_set.h" 26 #include "mojo/public/cpp/bindings/binding_set.h"
27 #include "services/catalog/public/interfaces/catalog.mojom.h" 27 #include "services/catalog/public/interfaces/catalog.mojom.h"
28 #include "services/catalog/public/interfaces/constants.mojom.h" 28 #include "services/catalog/public/interfaces/constants.mojom.h"
29 #include "services/service_manager/background/background_service_manager.h" 29 #include "services/service_manager/background/background_service_manager.h"
30 #include "services/service_manager/native_runner_delegate.h" 30 #include "services/service_manager/native_runner_delegate.h"
31 #include "services/service_manager/public/cpp/connector.h" 31 #include "services/service_manager/public/cpp/connector.h"
32 #include "services/service_manager/public/cpp/identity.h" 32 #include "services/service_manager/public/cpp/identity.h"
33 #include "services/service_manager/public/cpp/service.h" 33 #include "services/service_manager/public/cpp/service.h"
34 #include "services/service_manager/public/cpp/service_context.h" 34 #include "services/service_manager/public/cpp/service_context.h"
35 #include "services/service_manager/public/cpp/standalone_service/standalone_serv ice.h"
35 #include "services/service_manager/public/interfaces/service_factory.mojom.h" 36 #include "services/service_manager/public/interfaces/service_factory.mojom.h"
36 #include "services/service_manager/runner/common/switches.h" 37 #include "services/service_manager/runner/common/switches.h"
37 #include "services/service_manager/runner/host/child_process.h"
38 #include "services/service_manager/runner/host/child_process_base.h"
39 #include "services/service_manager/runner/init.h" 38 #include "services/service_manager/runner/init.h"
40 #include "services/service_manager/standalone/context.h" 39 #include "services/service_manager/standalone/context.h"
41 #include "ui/base/resource/resource_bundle.h" 40 #include "ui/base/resource/resource_bundle.h"
42 #include "ui/base/ui_base_paths.h" 41 #include "ui/base/ui_base_paths.h"
43 #include "ui/base/ui_base_switches.h" 42 #include "ui/base/ui_base_switches.h"
44 43
45 using service_manager::mojom::ServiceFactory; 44 using service_manager::mojom::ServiceFactory;
46 45
47 namespace { 46 namespace {
48 47
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 class NativeRunnerDelegateImpl : public service_manager::NativeRunnerDelegate { 85 class NativeRunnerDelegateImpl : public service_manager::NativeRunnerDelegate {
87 public: 86 public:
88 NativeRunnerDelegateImpl() {} 87 NativeRunnerDelegateImpl() {}
89 ~NativeRunnerDelegateImpl() override {} 88 ~NativeRunnerDelegateImpl() override {}
90 89
91 private: 90 private:
92 // service_manager::NativeRunnerDelegate: 91 // service_manager::NativeRunnerDelegate:
93 void AdjustCommandLineArgumentsForTarget( 92 void AdjustCommandLineArgumentsForTarget(
94 const service_manager::Identity& target, 93 const service_manager::Identity& target,
95 base::CommandLine* command_line) override { 94 base::CommandLine* command_line) override {
95 if (target.name() == kChromeMashServiceName ||
96 target.name() == content::mojom::kBrowserServiceName) {
97 command_line->SetProgram(
98 base::CommandLine::ForCurrentProcess()->GetProgram());
99 }
96 if (target.name() != content::mojom::kBrowserServiceName) { 100 if (target.name() != content::mojom::kBrowserServiceName) {
97 // If running anything other than the browser process, launch a mash 101 // If running anything other than the browser process, launch a mash
98 // child process. The new process will execute MashRunner::RunChild(). 102 // child process. The new process will execute MashRunner::RunChild().
99 command_line->AppendSwitchASCII(switches::kProcessType, kMashChild); 103 command_line->AppendSwitchASCII(switches::kProcessType, kMashChild);
100 #if defined(OS_WIN) 104 #if defined(OS_WIN)
101 command_line->AppendArg(switches::kPrefetchArgumentOther); 105 command_line->AppendArg(switches::kPrefetchArgumentOther);
102 #endif 106 #endif
103 return; 107 return;
104 } 108 }
105 109
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 186 }
183 187
184 int MashRunner::RunChild() { 188 int MashRunner::RunChild() {
185 // TODO(fdoray): Add TaskScheduler initialization code in 189 // TODO(fdoray): Add TaskScheduler initialization code in
186 // service_manager::ServiceRunner. TaskScheduler can't be initialized here 190 // service_manager::ServiceRunner. TaskScheduler can't be initialized here
187 // because it wouldn't be visible to the service's dynamic library. 191 // because it wouldn't be visible to the service's dynamic library.
188 // https://crbug.com/664996 192 // https://crbug.com/664996
189 193
190 service_manager::WaitForDebuggerIfNecessary(); 194 service_manager::WaitForDebuggerIfNecessary();
191 195
192 base::FilePath path =
193 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
194 switches::kChildProcess);
195 if (base::PathExists(path))
196 return service_manager::ChildProcessMain();
197
198 // If the path doesn't exist - try launching this as a packaged service.
199 base::i18n::InitializeICU(); 196 base::i18n::InitializeICU();
200 InitializeResources(); 197 InitializeResources();
201 service_manager::ChildProcessMainWithCallback( 198 service_manager::RunStandaloneService(
202 base::Bind(&MashRunner::StartChildApp, base::Unretained(this))); 199 base::Bind(&MashRunner::StartChildApp, base::Unretained(this)));
203 return 0; 200 return 0;
204 } 201 }
205 202
206 void MashRunner::StartChildApp( 203 void MashRunner::StartChildApp(
207 service_manager::mojom::ServiceRequest service_request) { 204 service_manager::mojom::ServiceRequest service_request) {
208 // TODO(sad): Normally, this would be a TYPE_DEFAULT message loop. However, 205 // TODO(sad): Normally, this would be a TYPE_DEFAULT message loop. However,
209 // TYPE_UI is needed for mojo:ui. But it is not known whether the child app is 206 // TYPE_UI is needed for mojo:ui. But it is not known whether the child app is
210 // going to be mojo:ui at this point. So always create a TYPE_UI message loop 207 // going to be mojo:ui at this point. So always create a TYPE_UI message loop
211 // for now. 208 // for now.
(...skipping 23 matching lines...) Expand all
235 base::trace_event::TraceConfig trace_config = 232 base::trace_event::TraceConfig trace_config =
236 tracing::GetConfigForTraceToConsole(); 233 tracing::GetConfigForTraceToConsole();
237 base::trace_event::TraceLog::GetInstance()->SetEnabled( 234 base::trace_event::TraceLog::GetInstance()->SetEnabled(
238 trace_config, 235 trace_config,
239 base::trace_event::TraceLog::RECORDING_MODE); 236 base::trace_event::TraceLog::RECORDING_MODE);
240 } 237 }
241 238
242 MashRunner mash_runner; 239 MashRunner mash_runner;
243 return mash_runner.Run(); 240 return mash_runner.Run();
244 } 241 }
OLDNEW
« no previous file with comments | « chrome/app/mash/BUILD.gn ('k') | chrome/test/base/mash_browser_tests_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698