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