OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chrome_main_delegate.h" | 5 #include "chrome/app/chrome_main_delegate.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/metrics/stats_counters.h" | 10 #include "base/metrics/stats_counters.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 67 |
68 #if !defined(DISABLE_NACL) && defined(OS_LINUX) | 68 #if !defined(DISABLE_NACL) && defined(OS_LINUX) |
69 #include "components/nacl/common/nacl_paths.h" | 69 #include "components/nacl/common/nacl_paths.h" |
70 #include "components/nacl/zygote/nacl_fork_delegate_linux.h" | 70 #include "components/nacl/zygote/nacl_fork_delegate_linux.h" |
71 #endif | 71 #endif |
72 | 72 |
73 #if defined(OS_CHROMEOS) | 73 #if defined(OS_CHROMEOS) |
74 #include "base/sys_info.h" | 74 #include "base/sys_info.h" |
75 #include "chrome/browser/chromeos/boot_times_loader.h" | 75 #include "chrome/browser/chromeos/boot_times_loader.h" |
76 #include "chromeos/chromeos_paths.h" | 76 #include "chromeos/chromeos_paths.h" |
| 77 #include "chromeos/chromeos_switches.h" |
77 #endif | 78 #endif |
78 | 79 |
79 #if defined(OS_ANDROID) | 80 #if defined(OS_ANDROID) |
80 #include "chrome/common/descriptors_android.h" | 81 #include "chrome/common/descriptors_android.h" |
81 #else | 82 #else |
82 // Diagnostics is only available on non-android platforms. | 83 // Diagnostics is only available on non-android platforms. |
83 #include "chrome/browser/diagnostics/diagnostics_controller.h" | 84 #include "chrome/browser/diagnostics/diagnostics_controller.h" |
84 #include "chrome/browser/diagnostics/diagnostics_writer.h" | 85 #include "chrome/browser/diagnostics/diagnostics_writer.h" |
85 #endif | 86 #endif |
86 | 87 |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 } | 414 } |
414 | 415 |
415 diagnostics::DiagnosticsWriter writer(format); | 416 diagnostics::DiagnosticsWriter writer(format); |
416 *exit_code = diagnostics::DiagnosticsController::GetInstance()->Run( | 417 *exit_code = diagnostics::DiagnosticsController::GetInstance()->Run( |
417 command_line, &writer); | 418 command_line, &writer); |
418 diagnostics::DiagnosticsController::GetInstance()->ClearResults(); | 419 diagnostics::DiagnosticsController::GetInstance()->ClearResults(); |
419 return true; | 420 return true; |
420 } | 421 } |
421 #endif | 422 #endif |
422 | 423 |
| 424 #if defined(OS_CHROMEOS) |
| 425 // If we are recovering from a crash on ChromeOS, then we will do some |
| 426 // recovery using the diagnostics module, and then continue on. We fake up a |
| 427 // command line to tell it that we want it to recover, and to preserve the |
| 428 // original command line. |
| 429 if (command_line.HasSwitch(chromeos::switches::kLoginUser) || |
| 430 command_line.HasSwitch(switches::kDiagnosticsRecovery)) { |
| 431 CommandLine interim_command_line(command_line.GetProgram()); |
| 432 if (command_line.HasSwitch(switches::kUserDataDir)) { |
| 433 interim_command_line.AppendSwitchPath( |
| 434 switches::kUserDataDir, |
| 435 command_line.GetSwitchValuePath(switches::kUserDataDir)); |
| 436 } |
| 437 interim_command_line.AppendSwitch(switches::kDiagnostics); |
| 438 interim_command_line.AppendSwitch(switches::kDiagnosticsRecovery); |
| 439 |
| 440 diagnostics::DiagnosticsWriter::FormatType format = |
| 441 diagnostics::DiagnosticsWriter::LOG; |
| 442 if (command_line.HasSwitch(switches::kDiagnosticsFormat)) { |
| 443 std::string format_str = |
| 444 command_line.GetSwitchValueASCII(switches::kDiagnosticsFormat); |
| 445 if (format_str == "machine") { |
| 446 format = diagnostics::DiagnosticsWriter::MACHINE; |
| 447 } else if (format_str == "human") { |
| 448 format = diagnostics::DiagnosticsWriter::HUMAN; |
| 449 } else { |
| 450 DCHECK_EQ("log", format_str); |
| 451 } |
| 452 } |
| 453 |
| 454 diagnostics::DiagnosticsWriter writer(format); |
| 455 int diagnostics_exit_code = |
| 456 diagnostics::DiagnosticsController::GetInstance()->Run(command_line, |
| 457 &writer); |
| 458 if (diagnostics_exit_code) { |
| 459 // Diagnostics has failed somehow, so we exit. |
| 460 *exit_code = diagnostics_exit_code; |
| 461 return true; |
| 462 } |
| 463 |
| 464 // Now we run the actual recovery tasks. |
| 465 int recovery_exit_code = |
| 466 diagnostics::DiagnosticsController::GetInstance()->RunRecovery( |
| 467 command_line, &writer); |
| 468 |
| 469 if (recovery_exit_code) { |
| 470 // Recovery has failed somehow, so we exit. |
| 471 *exit_code = recovery_exit_code; |
| 472 return true; |
| 473 } |
| 474 } |
| 475 #endif |
| 476 |
423 content::SetContentClient(&chrome_content_client_); | 477 content::SetContentClient(&chrome_content_client_); |
424 | 478 |
425 return false; | 479 return false; |
426 } | 480 } |
427 | 481 |
428 #if defined(OS_MACOSX) | 482 #if defined(OS_MACOSX) |
429 void ChromeMainDelegate::InitMacCrashReporter(const CommandLine& command_line, | 483 void ChromeMainDelegate::InitMacCrashReporter(const CommandLine& command_line, |
430 const std::string& process_type) { | 484 const std::string& process_type) { |
431 // TODO(mark): Right now, InitCrashReporter() needs to be called after | 485 // TODO(mark): Right now, InitCrashReporter() needs to be called after |
432 // CommandLine::Init() and chrome::RegisterPathProvider(). Ideally, | 486 // CommandLine::Init() and chrome::RegisterPathProvider(). Ideally, |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 } | 843 } |
790 | 844 |
791 content::ContentUtilityClient* | 845 content::ContentUtilityClient* |
792 ChromeMainDelegate::CreateContentUtilityClient() { | 846 ChromeMainDelegate::CreateContentUtilityClient() { |
793 #if defined(CHROME_MULTIPLE_DLL_BROWSER) | 847 #if defined(CHROME_MULTIPLE_DLL_BROWSER) |
794 return NULL; | 848 return NULL; |
795 #else | 849 #else |
796 return &g_chrome_content_utility_client.Get(); | 850 return &g_chrome_content_utility_client.Get(); |
797 #endif | 851 #endif |
798 } | 852 } |
OLD | NEW |