Chromium Code Reviews| Index: chrome/app/chrome_main_delegate.cc |
| diff --git a/chrome/app/chrome_main_delegate.cc b/chrome/app/chrome_main_delegate.cc |
| index 66202885e5a43ce7089a33c9e46d7be1c76f512c..f9d3fd74cb8bf4d0dd1fc1a8622de891168f988d 100644 |
| --- a/chrome/app/chrome_main_delegate.cc |
| +++ b/chrome/app/chrome_main_delegate.cc |
| @@ -73,6 +73,7 @@ |
| #include "base/sys_info.h" |
| #include "chrome/browser/chromeos/boot_times_loader.h" |
| #include "chromeos/chromeos_paths.h" |
| +#include "chromeos/chromeos_switches.h" |
| #endif |
| #if defined(OS_ANDROID) |
| @@ -419,6 +420,59 @@ bool ChromeMainDelegate::BasicStartupComplete(int* exit_code) { |
| } |
| #endif |
| +#if defined(OS_CHROMEOS) |
| + // If we are recovering from a crash on ChromeOS, then we will do some |
| + // recovery using the diagnostics module, and then continue on. We fake up a |
| + // command line to tell it that we want it to recover, and to preserve the |
| + // original command line. |
| + if (command_line.HasSwitch(chromeos::switches::kLoginUser) || |
| + command_line.HasSwitch(switches::kDiagnosticsRecovery)) { |
| + CommandLine interim_command_line(command_line.GetProgram()); |
| + if (command_line.HasSwitch(switches::kUserDataDir)) { |
| + interim_command_line.AppendSwitchPath( |
| + switches::kUserDataDir, |
| + command_line.GetSwitchValuePath(switches::kUserDataDir)); |
| + } |
| + interim_command_line.AppendSwitch(switches::kDiagnostics); |
| + interim_command_line.AppendSwitch(switches::kDiagnosticsRecovery); |
| + |
| + diagnostics::DiagnosticsWriter::FormatType format = |
| + diagnostics::DiagnosticsWriter::LOG; |
| + if (command_line.HasSwitch(switches::kDiagnosticsFormat)) { |
| + std::string format_str = |
| + command_line.GetSwitchValueASCII(switches::kDiagnosticsFormat); |
| + if (format_str == "machine") { |
| + format = diagnostics::DiagnosticsWriter::MACHINE; |
| + } else if (format_str == "human") { |
| + format = diagnostics::DiagnosticsWriter::HUMAN; |
| + } else { |
| + DCHECK_EQ("log", format_str); |
| + } |
| + } |
| + |
| + diagnostics::DiagnosticsWriter writer(format); |
| + int diagnostics_exit_code = |
| + diagnostics::DiagnosticsController::GetInstance()->Run(command_line, |
| + &writer); |
| + if (diagnostics_exit_code) { |
| + // Diagnostics has failed somehow, so we exit. |
| + *exit_code = diagnostics_exit_code; |
| + return true; |
| + } |
| + |
| + // Now we run the actual recovery tasks. |
| + int recovery_exit_code = |
| + diagnostics::DiagnosticsController::GetInstance()->RunRecovery( |
| + command_line, &writer); |
| + |
| + if (recovery_exit_code) { |
| + // Recovery has failed somehow, so we exit. |
| + *exit_code = recovery_exit_code; |
| + return true; |
| + } |
|
cpu_(ooo_6.6-7.5)
2013/07/25 19:40:56
shouldn't we return here? in what case it is ok to
Greg Spencer (Chromium)
2013/07/26 18:51:30
No, in fact, we want to continue here because the
|
| + } |
| +#endif |
| + |
| content::SetContentClient(&chrome_content_client_); |
| return false; |