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

Side by Side Diff: chrome/browser/metrics/thread_watcher.cc

Issue 7780022: Fix GetChannel interface misuse in ThreadWatcher and ShutdownWatcher. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // Increase the unresponsive_threshold on the Stable and Beta channels to
427 // Increase the unresponsive_threshold in Beta channel to reduce the number 427 // reduce the number of crashes due to ThreadWatcher.
428 // of crashes due to ThreadWatcher. 428 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
429 if (channel == chrome::VersionInfo::CHANNEL_STABLE) {
430 *unresponsive_threshold *= 4;
431 } else if (channel == chrome::VersionInfo::CHANNEL_BETA) {
429 *unresponsive_threshold *= 2; 432 *unresponsive_threshold *= 2;
430 } else { 433 }
431 // In Canary and Dev channels, for Windows XP (old systems), double the 434
432 // 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
434 // the OS).
435 #if defined(OS_WIN) 435 #if defined(OS_WIN)
436 if (base::win::GetVersion() <= base::win::VERSION_XP) 436 // For Windows XP (old systems), double the unresponsive_threshold to give
437 *unresponsive_threshold *= 2; 437 // the OS a chance to schedule UI/IO threads a time slice to respond with a
438 // pong message (to get around limitations with the OS).
439 if (base::win::GetVersion() <= base::win::VERSION_XP)
440 *unresponsive_threshold *= 2;
438 #endif 441 #endif
439 }
440 442
441 std::string crash_on_hang_seconds = 443 std::string crash_on_hang_seconds =
442 command_line.GetSwitchValueASCII(switches::kCrashOnHangSeconds); 444 command_line.GetSwitchValueASCII(switches::kCrashOnHangSeconds);
443 if (!crash_on_hang_seconds.empty()) { 445 if (!crash_on_hang_seconds.empty()) {
444 int crash_seconds = atoi(crash_on_hang_seconds.c_str()); 446 int crash_seconds = atoi(crash_on_hang_seconds.c_str());
445 if (crash_seconds > 0) { 447 if (crash_seconds > 0) {
446 *unresponsive_threshold = static_cast<uint32>( 448 *unresponsive_threshold = static_cast<uint32>(
447 ceil(static_cast<float>(crash_seconds) / kUnresponsiveSeconds)); 449 ceil(static_cast<float>(crash_seconds) / kUnresponsiveSeconds));
448 } 450 }
449 } 451 }
450 452
451 std::string crash_on_hang_threads; 453 std::string crash_on_hang_threads;
452 454
453 // Default to crashing the browser if UI or IO threads are not responsive 455 // Default to crashing the browser if UI or IO threads are not responsive
454 // except in stable channel. 456 // except in stable channel.
455 if (chrome::VersionInfo::GetChannel() == chrome::VersionInfo::CHANNEL_STABLE) 457 if (channel == chrome::VersionInfo::CHANNEL_STABLE)
456 crash_on_hang_threads = ""; 458 crash_on_hang_threads = "";
457 else 459 else
458 crash_on_hang_threads = "UI,IO"; 460 crash_on_hang_threads = "UI,IO";
459 461
460 if (command_line.HasSwitch(switches::kCrashOnHangThreads)) { 462 if (command_line.HasSwitch(switches::kCrashOnHangThreads)) {
461 crash_on_hang_threads = 463 crash_on_hang_threads =
462 command_line.GetSwitchValueASCII(switches::kCrashOnHangThreads); 464 command_line.GetSwitchValueASCII(switches::kCrashOnHangThreads);
463 } 465 }
464 StringTokenizer tokens(crash_on_hang_threads, ","); 466 StringTokenizer tokens(crash_on_hang_threads, ",");
465 while (tokens.GetNext()) 467 while (tokens.GetNext())
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 if (shutdown_watchdog_) { 723 if (shutdown_watchdog_) {
722 shutdown_watchdog_->Disarm(); 724 shutdown_watchdog_->Disarm();
723 delete shutdown_watchdog_; 725 delete shutdown_watchdog_;
724 shutdown_watchdog_ = NULL; 726 shutdown_watchdog_ = NULL;
725 } 727 }
726 } 728 }
727 729
728 void ShutdownWatcherHelper::Arm(const base::TimeDelta& duration) { 730 void ShutdownWatcherHelper::Arm(const base::TimeDelta& duration) {
729 DCHECK(!shutdown_watchdog_); 731 DCHECK(!shutdown_watchdog_);
730 base::TimeDelta actual_duration = duration; 732 base::TimeDelta actual_duration = duration;
733
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 }
738 // In Canary, for Windows XP, give twice the time for shutdown. 741
739 #if defined(OS_WIN) 742 #if defined(OS_WIN)
740 if (base::win::GetVersion() <= base::win::VERSION_XP) 743 // On Windows XP, give twice the time for shutdown.
741 actual_duration *= 2; 744 if (base::win::GetVersion() <= base::win::VERSION_XP)
745 actual_duration *= 2;
742 #endif 746 #endif
743 } 747
744 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration); 748 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration);
745 shutdown_watchdog_->Arm(); 749 shutdown_watchdog_->Arm();
746 } 750 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698