Chromium Code Reviews| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
| 10 #include "base/base_paths.h" | 10 #include "base/base_paths.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 #include "services/service_manager/public/cpp/standalone_service/standalone_serv ice.h" | 49 #include "services/service_manager/public/cpp/standalone_service/standalone_serv ice.h" |
| 50 #include "services/service_manager/public/interfaces/service_factory.mojom.h" | 50 #include "services/service_manager/public/interfaces/service_factory.mojom.h" |
| 51 #include "services/service_manager/runner/common/client_util.h" | 51 #include "services/service_manager/runner/common/client_util.h" |
| 52 #include "services/service_manager/runner/common/switches.h" | 52 #include "services/service_manager/runner/common/switches.h" |
| 53 #include "services/service_manager/runner/init.h" | 53 #include "services/service_manager/runner/init.h" |
| 54 #include "services/ui/public/interfaces/constants.mojom.h" | 54 #include "services/ui/public/interfaces/constants.mojom.h" |
| 55 #include "ui/base/resource/resource_bundle.h" | 55 #include "ui/base/resource/resource_bundle.h" |
| 56 #include "ui/base/ui_base_paths.h" | 56 #include "ui/base/ui_base_paths.h" |
| 57 #include "ui/base/ui_base_switches.h" | 57 #include "ui/base/ui_base_switches.h" |
| 58 | 58 |
| 59 #if defined(OS_CHROMEOS) | |
| 60 #include "chrome/app/mash/mash_crash_keys.h" | |
| 61 #endif // defined(OS_CHROMEOS) | |
| 62 | |
| 59 using service_manager::mojom::ServiceFactory; | 63 using service_manager::mojom::ServiceFactory; |
| 60 | 64 |
| 61 namespace { | 65 namespace { |
| 62 | 66 |
| 63 // kProcessType used to identify child processes. | 67 // kProcessType used to identify child processes. |
| 64 const char* kMashChild = "mash-child"; | 68 const char* kMashChild = "mash-child"; |
| 65 | 69 |
| 66 const char kChromeMashServiceName[] = "chrome_mash"; | 70 const char kChromeMashServiceName[] = "chrome_mash"; |
| 67 | 71 |
| 68 bool IsChild() { | 72 bool IsChild() { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 } | 142 } |
| 139 | 143 |
| 140 LOG(ERROR) << "Main process exiting because service " << identity.name() | 144 LOG(ERROR) << "Main process exiting because service " << identity.name() |
| 141 << " quit unexpectedly."; | 145 << " quit unexpectedly."; |
| 142 *exit_value = 1; | 146 *exit_value = 1; |
| 143 run_loop->Quit(); | 147 run_loop->Quit(); |
| 144 } | 148 } |
| 145 | 149 |
| 146 } // namespace | 150 } // namespace |
| 147 | 151 |
| 148 MashRunner::MashRunner() {} | 152 MashRunner::MashRunner() { |
| 153 #if defined(OS_CHROMEOS) | |
| 154 // NOTE: On Chrome OS, crash reporting for the root process and non-browser | |
| 155 // service processes is handled by the OS-level crash_reporter, not in-process | |
| 156 // breakpad. It therefore uses its own crash key implementation. | |
| 157 mash_crash_keys::Initialize(); | |
|
hashimoto
2017/03/02 07:42:23
How about putting this code in MashMain or RunMain
| |
| 158 #endif | |
| 159 } | |
| 149 | 160 |
| 150 MashRunner::~MashRunner() {} | 161 MashRunner::~MashRunner() { |
|
hashimoto
2017/03/02 07:42:23
ditto.
Other shutdown code is in RunMain().
| |
| 162 #if defined(OS_CHROMEOS) | |
| 163 mash_crash_keys::Shutdown(); | |
| 164 #endif | |
| 165 } | |
| 151 | 166 |
| 152 int MashRunner::Run() { | 167 int MashRunner::Run() { |
| 153 base::TaskScheduler::CreateAndSetSimpleTaskScheduler( | 168 base::TaskScheduler::CreateAndSetSimpleTaskScheduler( |
| 154 base::SysInfo::NumberOfProcessors()); | 169 base::SysInfo::NumberOfProcessors()); |
| 155 | 170 |
| 156 if (IsChild()) | 171 if (IsChild()) |
| 157 return RunChild(); | 172 return RunChild(); |
| 158 | 173 |
| 159 return RunMain(); | 174 return RunMain(); |
| 160 } | 175 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 250 // TODO(sky): wire this up correctly. | 265 // TODO(sky): wire this up correctly. |
| 251 service_manager::InitializeLogging(); | 266 service_manager::InitializeLogging(); |
| 252 | 267 |
| 253 #if defined(OS_LINUX) | 268 #if defined(OS_LINUX) |
| 254 base::AtExitManager exit_manager; | 269 base::AtExitManager exit_manager; |
| 255 #endif | 270 #endif |
| 256 | 271 |
| 257 #if !defined(OFFICIAL_BUILD) | 272 #if !defined(OFFICIAL_BUILD) |
| 258 // Initialize stack dumping before initializing sandbox to make sure symbol | 273 // Initialize stack dumping before initializing sandbox to make sure symbol |
| 259 // names in all loaded libraries will be cached. | 274 // names in all loaded libraries will be cached. |
| 260 // NOTE: On Chrome OS, crash reporting for the root process and non-browser | |
| 261 // service processes is handled by the OS-level crash_reporter. | |
|
hashimoto
2017/03/02 07:42:23
IMO we still need this comment here to describe ho
| |
| 262 base::debug::EnableInProcessStackDumping(); | 275 base::debug::EnableInProcessStackDumping(); |
| 263 #endif | 276 #endif |
| 264 | 277 |
| 265 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 278 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 266 switches::kTraceToConsole)) { | 279 switches::kTraceToConsole)) { |
| 267 base::trace_event::TraceConfig trace_config = | 280 base::trace_event::TraceConfig trace_config = |
| 268 tracing::GetConfigForTraceToConsole(); | 281 tracing::GetConfigForTraceToConsole(); |
| 269 base::trace_event::TraceLog::GetInstance()->SetEnabled( | 282 base::trace_event::TraceLog::GetInstance()->SetEnabled( |
| 270 trace_config, | 283 trace_config, |
| 271 base::trace_event::TraceLog::RECORDING_MODE); | 284 base::trace_event::TraceLog::RECORDING_MODE); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 287 command_line->GetSwitchValueASCII(switches::kWaitForDebugger)) { | 300 command_line->GetSwitchValueASCII(switches::kWaitForDebugger)) { |
| 288 return; | 301 return; |
| 289 } | 302 } |
| 290 | 303 |
| 291 // Include the pid as logging may not have been initialized yet (the pid | 304 // Include the pid as logging may not have been initialized yet (the pid |
| 292 // printed out by logging is wrong). | 305 // printed out by logging is wrong). |
| 293 LOG(WARNING) << "waiting for debugger to attach for service " << service_name | 306 LOG(WARNING) << "waiting for debugger to attach for service " << service_name |
| 294 << " pid=" << base::Process::Current().Pid(); | 307 << " pid=" << base::Process::Current().Pid(); |
| 295 base::debug::WaitForDebugger(120, true); | 308 base::debug::WaitForDebugger(120, true); |
| 296 } | 309 } |
| OLD | NEW |