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 "base/at_exit.h" | 7 #include "base/at_exit.h" |
| 8 #include "base/base_paths.h" | 8 #include "base/base_paths.h" |
| 9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 39 #include "services/service_manager/public/cpp/service_context.h" | 39 #include "services/service_manager/public/cpp/service_context.h" |
| 40 #include "services/service_manager/public/cpp/standalone_service/standalone_serv ice.h" | 40 #include "services/service_manager/public/cpp/standalone_service/standalone_serv ice.h" |
| 41 #include "services/service_manager/public/interfaces/service_factory.mojom.h" | 41 #include "services/service_manager/public/interfaces/service_factory.mojom.h" |
| 42 #include "services/service_manager/runner/common/client_util.h" | 42 #include "services/service_manager/runner/common/client_util.h" |
| 43 #include "services/service_manager/runner/common/switches.h" | 43 #include "services/service_manager/runner/common/switches.h" |
| 44 #include "services/service_manager/runner/init.h" | 44 #include "services/service_manager/runner/init.h" |
| 45 #include "ui/base/resource/resource_bundle.h" | 45 #include "ui/base/resource/resource_bundle.h" |
| 46 #include "ui/base/ui_base_paths.h" | 46 #include "ui/base/ui_base_paths.h" |
| 47 #include "ui/base/ui_base_switches.h" | 47 #include "ui/base/ui_base_switches.h" |
| 48 | 48 |
| 49 #if defined(OS_CHROMEOS) | |
| 50 #include "chrome/app/mash/mash_crash_reporter_client.h" | |
| 51 #include "components/crash/content/app/breakpad_linux.h" | |
| 52 #endif | |
| 53 | |
| 49 using service_manager::mojom::ServiceFactory; | 54 using service_manager::mojom::ServiceFactory; |
| 50 | 55 |
| 51 namespace { | 56 namespace { |
| 52 | 57 |
| 53 // kProcessType used to identify child processes. | 58 // kProcessType used to identify child processes. |
| 54 const char* kMashChild = "mash-child"; | 59 const char* kMashChild = "mash-child"; |
| 55 | 60 |
| 56 const char kChromeMashServiceName[] = "chrome_mash"; | 61 const char kChromeMashServiceName[] = "chrome_mash"; |
| 57 | 62 |
| 58 const char kChromeContentBrowserPackageName[] = "chrome_content_browser"; | 63 const char kChromeContentBrowserPackageName[] = "chrome_content_browser"; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 for (const base::CommandLine::StringType& arg : command_line->argv()) { | 125 for (const base::CommandLine::StringType& arg : command_line->argv()) { |
| 121 if (arg != FILE_PATH_LITERAL("--mash")) | 126 if (arg != FILE_PATH_LITERAL("--mash")) |
| 122 new_argv.push_back(arg); | 127 new_argv.push_back(arg); |
| 123 } | 128 } |
| 124 *command_line = base::CommandLine(new_argv); | 129 *command_line = base::CommandLine(new_argv); |
| 125 } | 130 } |
| 126 | 131 |
| 127 DISALLOW_COPY_AND_ASSIGN(ServiceProcessLauncherDelegateImpl); | 132 DISALLOW_COPY_AND_ASSIGN(ServiceProcessLauncherDelegateImpl); |
| 128 }; | 133 }; |
| 129 | 134 |
| 135 #if defined(OS_CHROMEOS) | |
| 136 // Initializes breakpad crash reporting. MashCrashReporterClient handles | |
| 137 // registering crash keys. | |
| 138 void InitializeCrashReporting() { | |
| 139 // Intentionally leaked. | |
| 140 static MashCrashReporterClient* client = new MashCrashReporterClient; | |
| 141 crash_reporter::SetCrashReporterClient(client); | |
|
sadrul
2017/01/19 04:22:11
I guess we are deliberately leaking here? Do we ne
James Cook
2017/01/19 18:01:18
Good catch on lsan! Done.
| |
| 142 | |
| 143 // For now all standalone services act like the browser process and write | |
| 144 // their own in-process crash dumps. When ash and the window server are | |
| 145 // sandboxed we will need to hook up the crash signal file descriptor, make | |
| 146 // the root process handle dumping, and pass a process type here. | |
| 147 const std::string process_type_unused; | |
| 148 breakpad::InitCrashReporter(process_type_unused); | |
| 149 } | |
| 150 #endif // defined(OS_CHROMEOS) | |
| 151 | |
| 130 } // namespace | 152 } // namespace |
| 131 | 153 |
| 132 MashRunner::MashRunner() {} | 154 MashRunner::MashRunner() {} |
| 133 | 155 |
| 134 MashRunner::~MashRunner() {} | 156 MashRunner::~MashRunner() {} |
| 135 | 157 |
| 136 int MashRunner::Run() { | 158 int MashRunner::Run() { |
| 137 base::TaskScheduler::CreateAndSetSimpleTaskScheduler( | 159 base::TaskScheduler::CreateAndSetSimpleTaskScheduler( |
| 138 base::SysInfo::NumberOfProcessors()); | 160 base::SysInfo::NumberOfProcessors()); |
| 139 | 161 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 base::RunLoop().Run(); | 238 base::RunLoop().Run(); |
| 217 } | 239 } |
| 218 | 240 |
| 219 int MashMain() { | 241 int MashMain() { |
| 220 #if !defined(OFFICIAL_BUILD) && defined(OS_WIN) | 242 #if !defined(OFFICIAL_BUILD) && defined(OS_WIN) |
| 221 base::RouteStdioToConsole(false); | 243 base::RouteStdioToConsole(false); |
| 222 #endif | 244 #endif |
| 223 // TODO(sky): wire this up correctly. | 245 // TODO(sky): wire this up correctly. |
| 224 service_manager::InitializeLogging(); | 246 service_manager::InitializeLogging(); |
| 225 | 247 |
| 226 std::unique_ptr<base::MessageLoop> message_loop; | |
| 227 #if defined(OS_LINUX) | 248 #if defined(OS_LINUX) |
| 228 base::AtExitManager exit_manager; | 249 base::AtExitManager exit_manager; |
| 229 #endif | 250 #endif |
| 251 | |
| 252 #if !defined(OFFICIAL_BUILD) | |
| 253 // Initialize stack dumping before initializing sandbox to make sure symbol | |
| 254 // names in all loaded libraries will be cached. | |
| 255 base::debug::EnableInProcessStackDumping(); | |
| 256 #endif | |
| 257 | |
| 258 #if defined(OS_CHROMEOS) | |
| 259 // Breakpad installs signal handlers, so crash reporting must be set up after | |
| 260 // EnableInProcessStackDumping() resets the signal handlers. | |
| 261 InitializeCrashReporting(); | |
| 262 #endif | |
| 263 | |
| 264 std::unique_ptr<base::MessageLoop> message_loop; | |
| 230 if (!IsChild()) | 265 if (!IsChild()) |
| 231 message_loop.reset(new base::MessageLoop(base::MessageLoop::TYPE_UI)); | 266 message_loop.reset(new base::MessageLoop(base::MessageLoop::TYPE_UI)); |
| 232 | 267 |
| 233 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 268 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 234 switches::kTraceToConsole)) { | 269 switches::kTraceToConsole)) { |
| 235 base::trace_event::TraceConfig trace_config = | 270 base::trace_event::TraceConfig trace_config = |
| 236 tracing::GetConfigForTraceToConsole(); | 271 tracing::GetConfigForTraceToConsole(); |
| 237 base::trace_event::TraceLog::GetInstance()->SetEnabled( | 272 base::trace_event::TraceLog::GetInstance()->SetEnabled( |
| 238 trace_config, | 273 trace_config, |
| 239 base::trace_event::TraceLog::RECORDING_MODE); | 274 base::trace_event::TraceLog::RECORDING_MODE); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 255 command_line->GetSwitchValueASCII(switches::kWaitForDebugger)) { | 290 command_line->GetSwitchValueASCII(switches::kWaitForDebugger)) { |
| 256 return; | 291 return; |
| 257 } | 292 } |
| 258 | 293 |
| 259 // Include the pid as logging may not have been initialized yet (the pid | 294 // Include the pid as logging may not have been initialized yet (the pid |
| 260 // printed out by logging is wrong). | 295 // printed out by logging is wrong). |
| 261 LOG(WARNING) << "waiting for debugger to attach for service " << service_name | 296 LOG(WARNING) << "waiting for debugger to attach for service " << service_name |
| 262 << " pid=" << base::Process::Current().Pid(); | 297 << " pid=" << base::Process::Current().Pid(); |
| 263 base::debug::WaitForDebugger(120, true); | 298 base::debug::WaitForDebugger(120, true); |
| 264 } | 299 } |
| OLD | NEW |