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

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

Issue 2643853005: chromeos: Initial support for crash reporting for chrome --mash (Closed)
Patch Set: sadrul comments Created 3 years, 11 months 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/mash_runner.h ('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/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
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 "base/debug/leak_annotations.h"
51 #include "chrome/app/mash/mash_crash_reporter_client.h"
52 #include "components/crash/content/app/breakpad_linux.h"
53 #endif
54
49 using service_manager::mojom::ServiceFactory; 55 using service_manager::mojom::ServiceFactory;
50 56
51 namespace { 57 namespace {
52 58
53 // kProcessType used to identify child processes. 59 // kProcessType used to identify child processes.
54 const char* kMashChild = "mash-child"; 60 const char* kMashChild = "mash-child";
55 61
56 const char kChromeMashServiceName[] = "chrome_mash"; 62 const char kChromeMashServiceName[] = "chrome_mash";
57 63
58 const char kChromeContentBrowserPackageName[] = "chrome_content_browser"; 64 const char kChromeContentBrowserPackageName[] = "chrome_content_browser";
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 for (const base::CommandLine::StringType& arg : command_line->argv()) { 126 for (const base::CommandLine::StringType& arg : command_line->argv()) {
121 if (arg != FILE_PATH_LITERAL("--mash")) 127 if (arg != FILE_PATH_LITERAL("--mash"))
122 new_argv.push_back(arg); 128 new_argv.push_back(arg);
123 } 129 }
124 *command_line = base::CommandLine(new_argv); 130 *command_line = base::CommandLine(new_argv);
125 } 131 }
126 132
127 DISALLOW_COPY_AND_ASSIGN(ServiceProcessLauncherDelegateImpl); 133 DISALLOW_COPY_AND_ASSIGN(ServiceProcessLauncherDelegateImpl);
128 }; 134 };
129 135
136 #if defined(OS_CHROMEOS)
137 // Initializes breakpad crash reporting. MashCrashReporterClient handles
138 // registering crash keys.
139 void InitializeCrashReporting() {
140 DCHECK(!breakpad::IsCrashReporterEnabled());
141
142 // Intentionally leaked. The crash client needs to outlive all other code.
143 MashCrashReporterClient* client = new MashCrashReporterClient;
144 ANNOTATE_LEAKING_OBJECT_PTR(client);
145 crash_reporter::SetCrashReporterClient(client);
146
147 // For now all standalone services act like the browser process and write
148 // their own in-process crash dumps. When ash and the window server are
149 // sandboxed we will need to hook up the crash signal file descriptor, make
150 // the root process handle dumping, and pass a process type here.
151 const std::string process_type_unused;
152 breakpad::InitCrashReporter(process_type_unused);
153 }
154 #endif // defined(OS_CHROMEOS)
155
130 } // namespace 156 } // namespace
131 157
132 MashRunner::MashRunner() {} 158 MashRunner::MashRunner() {}
133 159
134 MashRunner::~MashRunner() {} 160 MashRunner::~MashRunner() {}
135 161
136 int MashRunner::Run() { 162 int MashRunner::Run() {
137 base::TaskScheduler::CreateAndSetSimpleTaskScheduler( 163 base::TaskScheduler::CreateAndSetSimpleTaskScheduler(
138 base::SysInfo::NumberOfProcessors()); 164 base::SysInfo::NumberOfProcessors());
139 165
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 base::RunLoop().Run(); 242 base::RunLoop().Run();
217 } 243 }
218 244
219 int MashMain() { 245 int MashMain() {
220 #if !defined(OFFICIAL_BUILD) && defined(OS_WIN) 246 #if !defined(OFFICIAL_BUILD) && defined(OS_WIN)
221 base::RouteStdioToConsole(false); 247 base::RouteStdioToConsole(false);
222 #endif 248 #endif
223 // TODO(sky): wire this up correctly. 249 // TODO(sky): wire this up correctly.
224 service_manager::InitializeLogging(); 250 service_manager::InitializeLogging();
225 251
226 std::unique_ptr<base::MessageLoop> message_loop;
227 #if defined(OS_LINUX) 252 #if defined(OS_LINUX)
228 base::AtExitManager exit_manager; 253 base::AtExitManager exit_manager;
229 #endif 254 #endif
255
256 #if !defined(OFFICIAL_BUILD)
257 // Initialize stack dumping before initializing sandbox to make sure symbol
258 // names in all loaded libraries will be cached.
259 base::debug::EnableInProcessStackDumping();
260 #endif
261
262 #if defined(OS_CHROMEOS)
263 // Breakpad installs signal handlers, so crash reporting must be set up after
264 // EnableInProcessStackDumping() resets the signal handlers.
265 InitializeCrashReporting();
266 #endif
267
268 std::unique_ptr<base::MessageLoop> message_loop;
230 if (!IsChild()) 269 if (!IsChild())
231 message_loop.reset(new base::MessageLoop(base::MessageLoop::TYPE_UI)); 270 message_loop.reset(new base::MessageLoop(base::MessageLoop::TYPE_UI));
232 271
233 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 272 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
234 switches::kTraceToConsole)) { 273 switches::kTraceToConsole)) {
235 base::trace_event::TraceConfig trace_config = 274 base::trace_event::TraceConfig trace_config =
236 tracing::GetConfigForTraceToConsole(); 275 tracing::GetConfigForTraceToConsole();
237 base::trace_event::TraceLog::GetInstance()->SetEnabled( 276 base::trace_event::TraceLog::GetInstance()->SetEnabled(
238 trace_config, 277 trace_config,
239 base::trace_event::TraceLog::RECORDING_MODE); 278 base::trace_event::TraceLog::RECORDING_MODE);
(...skipping 15 matching lines...) Expand all
255 command_line->GetSwitchValueASCII(switches::kWaitForDebugger)) { 294 command_line->GetSwitchValueASCII(switches::kWaitForDebugger)) {
256 return; 295 return;
257 } 296 }
258 297
259 // Include the pid as logging may not have been initialized yet (the pid 298 // Include the pid as logging may not have been initialized yet (the pid
260 // printed out by logging is wrong). 299 // printed out by logging is wrong).
261 LOG(WARNING) << "waiting for debugger to attach for service " << service_name 300 LOG(WARNING) << "waiting for debugger to attach for service " << service_name
262 << " pid=" << base::Process::Current().Pid(); 301 << " pid=" << base::Process::Current().Pid();
263 base::debug::WaitForDebugger(120, true); 302 base::debug::WaitForDebugger(120, true);
264 } 303 }
OLDNEW
« no previous file with comments | « chrome/app/mash/mash_runner.h ('k') | chrome/test/base/mash_browser_tests_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698