OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/metrics/thread_watcher.h" | 5 #include "chrome/browser/metrics/thread_watcher.h" |
6 | 6 |
7 #include <math.h> // ceil | 7 #include <math.h> // ceil |
8 | 8 |
9 #include "base/debug/alias.h" | 9 #include "base/debug/alias.h" |
10 #include "base/string_tokenizer.h" | 10 #include "base/string_tokenizer.h" |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
416 | 416 |
417 // static | 417 // static |
418 void ThreadWatcherList::ParseCommandLine( | 418 void ThreadWatcherList::ParseCommandLine( |
419 const CommandLine& command_line, | 419 const CommandLine& command_line, |
420 uint32* unresponsive_threshold, | 420 uint32* unresponsive_threshold, |
421 std::set<std::string>* crash_on_hang_thread_names, | 421 std::set<std::string>* crash_on_hang_thread_names, |
422 uint32* live_threads_threshold) { | 422 uint32* live_threads_threshold) { |
423 // Determine |unresponsive_threshold| based on switches::kCrashOnHangSeconds. | 423 // Determine |unresponsive_threshold| based on switches::kCrashOnHangSeconds. |
424 *unresponsive_threshold = kUnresponsiveCount; | 424 *unresponsive_threshold = kUnresponsiveCount; |
425 | 425 |
426 if (chrome::VersionInfo::GetChannel() == chrome::VersionInfo::CHANNEL_BETA) { | 426 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
427 // Increase the unresponsive_threshold in Beta channel to reduce the number | 427 if (channel == chrome::VersionInfo::CHANNEL_STABLE || |
jar (doing other things)
2011/09/10 19:20:31
I agree. This addition makes the code less fragile
| |
428 // of crashes due to ThreadWatcher. | 428 channel == chrome::VersionInfo::CHANNEL_BETA) { |
429 // Increase the unresponsive_threshold in Stable and Beta channels to | |
430 // reduce the number of crashes due to ThreadWatcher. | |
429 *unresponsive_threshold *= 2; | 431 *unresponsive_threshold *= 2; |
Mark Mentovai
2011/09/10 18:50:38
I couldn’t figure out why you would want to do thi
| |
430 } else { | 432 } else if (channel == chrome::VersionInfo::CHANNEL_DEV || |
433 channel == chrome::VersionInfo::CHANNEL_CANARY) { | |
431 // In Canary and Dev channels, for Windows XP (old systems), double the | 434 // In Canary and Dev channels, for Windows XP (old systems), double the |
432 // unresponsive_threshold to give OS a chance to schedule UI/IO threads a | 435 // unresponsive_threshold to give OS a chance to schedule UI/IO threads a |
433 // time slice to respond with a pong message (to get around limitations with | 436 // time slice to respond with a pong message (to get around limitations with |
434 // the OS). | 437 // the OS). |
435 #if defined(OS_WIN) | 438 #if defined(OS_WIN) |
436 if (base::win::GetVersion() <= base::win::VERSION_XP) | 439 if (base::win::GetVersion() <= base::win::VERSION_XP) |
437 *unresponsive_threshold *= 2; | 440 *unresponsive_threshold *= 2; |
jar (doing other things)
2011/09/10 19:20:31
IMO, this multiplier should not be within an if bl
| |
438 #endif | 441 #endif |
439 } | 442 } |
440 | 443 |
441 std::string crash_on_hang_seconds = | 444 std::string crash_on_hang_seconds = |
442 command_line.GetSwitchValueASCII(switches::kCrashOnHangSeconds); | 445 command_line.GetSwitchValueASCII(switches::kCrashOnHangSeconds); |
443 if (!crash_on_hang_seconds.empty()) { | 446 if (!crash_on_hang_seconds.empty()) { |
444 int crash_seconds = atoi(crash_on_hang_seconds.c_str()); | 447 int crash_seconds = atoi(crash_on_hang_seconds.c_str()); |
445 if (crash_seconds > 0) { | 448 if (crash_seconds > 0) { |
446 *unresponsive_threshold = static_cast<uint32>( | 449 *unresponsive_threshold = static_cast<uint32>( |
447 ceil(static_cast<float>(crash_seconds) / kUnresponsiveSeconds)); | 450 ceil(static_cast<float>(crash_seconds) / kUnresponsiveSeconds)); |
448 } | 451 } |
449 } | 452 } |
450 | 453 |
451 std::string crash_on_hang_threads; | 454 std::string crash_on_hang_threads; |
452 | 455 |
453 // Default to crashing the browser if UI or IO threads are not responsive | 456 // Default to crashing the browser if UI or IO threads are not responsive |
454 // except in stable channel. | 457 // except in stable channel. |
455 if (chrome::VersionInfo::GetChannel() == chrome::VersionInfo::CHANNEL_STABLE) | 458 if (channel == chrome::VersionInfo::CHANNEL_STABLE) |
456 crash_on_hang_threads = ""; | 459 crash_on_hang_threads = ""; |
457 else | 460 else |
458 crash_on_hang_threads = "UI,IO"; | 461 crash_on_hang_threads = "UI,IO"; |
459 | 462 |
460 if (command_line.HasSwitch(switches::kCrashOnHangThreads)) { | 463 if (command_line.HasSwitch(switches::kCrashOnHangThreads)) { |
461 crash_on_hang_threads = | 464 crash_on_hang_threads = |
462 command_line.GetSwitchValueASCII(switches::kCrashOnHangThreads); | 465 command_line.GetSwitchValueASCII(switches::kCrashOnHangThreads); |
463 } | 466 } |
464 StringTokenizer tokens(crash_on_hang_threads, ","); | 467 StringTokenizer tokens(crash_on_hang_threads, ","); |
465 while (tokens.GetNext()) | 468 while (tokens.GetNext()) |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
727 | 730 |
728 void ShutdownWatcherHelper::Arm(const base::TimeDelta& duration) { | 731 void ShutdownWatcherHelper::Arm(const base::TimeDelta& duration) { |
729 DCHECK(!shutdown_watchdog_); | 732 DCHECK(!shutdown_watchdog_); |
730 base::TimeDelta actual_duration = duration; | 733 base::TimeDelta actual_duration = duration; |
731 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | 734 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
732 if (channel == chrome::VersionInfo::CHANNEL_STABLE) { | 735 if (channel == chrome::VersionInfo::CHANNEL_STABLE) { |
733 actual_duration *= 50; | 736 actual_duration *= 50; |
734 } else if (channel == chrome::VersionInfo::CHANNEL_BETA || | 737 } else if (channel == chrome::VersionInfo::CHANNEL_BETA || |
735 channel == chrome::VersionInfo::CHANNEL_DEV) { | 738 channel == chrome::VersionInfo::CHANNEL_DEV) { |
736 actual_duration *= 25; | 739 actual_duration *= 25; |
737 } else { | 740 } else if (channel == chrome::VersionInfo::CHANNEL_CANARY) { |
738 // In Canary, for Windows XP, give twice the time for shutdown. | 741 // In Canary, for Windows XP, give twice the time for shutdown. |
739 #if defined(OS_WIN) | 742 #if defined(OS_WIN) |
740 if (base::win::GetVersion() <= base::win::VERSION_XP) | 743 if (base::win::GetVersion() <= base::win::VERSION_XP) |
741 actual_duration *= 2; | 744 actual_duration *= 2; |
jar (doing other things)
2011/09/10 19:20:31
Here again, I think the XP test should provide the
| |
742 #endif | 745 #endif |
743 } | 746 } |
744 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration); | 747 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration); |
745 shutdown_watchdog_->Arm(); | 748 shutdown_watchdog_->Arm(); |
746 } | 749 } |
OLD | NEW |