| 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/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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 unresponsive_threshold(unresponsive_threshold) { | 432 unresponsive_threshold(unresponsive_threshold) { |
| 433 } | 433 } |
| 434 | 434 |
| 435 ThreadWatcherList::CrashDataThresholds::CrashDataThresholds() | 435 ThreadWatcherList::CrashDataThresholds::CrashDataThresholds() |
| 436 : live_threads_threshold(kLiveThreadsThreshold), | 436 : live_threads_threshold(kLiveThreadsThreshold), |
| 437 unresponsive_threshold(kUnresponsiveCount) { | 437 unresponsive_threshold(kUnresponsiveCount) { |
| 438 } | 438 } |
| 439 | 439 |
| 440 // static | 440 // static |
| 441 void ThreadWatcherList::StartWatchingAll(const CommandLine& command_line) { | 441 void ThreadWatcherList::StartWatchingAll(const CommandLine& command_line) { |
| 442 // TODO(rtenneti): Enable ThreadWatcher. | 442 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 443 uint32 unresponsive_threshold; | 443 uint32 unresponsive_threshold; |
| 444 CrashOnHangThreadMap crash_on_hang_threads; | 444 CrashOnHangThreadMap crash_on_hang_threads; |
| 445 ParseCommandLine(command_line, | 445 ParseCommandLine(command_line, |
| 446 &unresponsive_threshold, | 446 &unresponsive_threshold, |
| 447 &crash_on_hang_threads); | 447 &crash_on_hang_threads); |
| 448 | 448 |
| 449 ThreadWatcherObserver::SetupNotifications( | 449 ThreadWatcherObserver::SetupNotifications( |
| 450 base::TimeDelta::FromSeconds(kSleepSeconds * unresponsive_threshold)); | 450 base::TimeDelta::FromSeconds(kSleepSeconds * unresponsive_threshold)); |
| 451 | 451 |
| 452 WatchDogThread::PostTask( | 452 WatchDogThread::PostTask( |
| 453 FROM_HERE, | 453 FROM_HERE, |
| 454 base::Bind(&ThreadWatcherList::SetStopped, false)); | 454 base::Bind(&ThreadWatcherList::SetStopped, false)); |
| 455 | 455 |
| 456 WatchDogThread::PostDelayedTask( | 456 if (!WatchDogThread::PostDelayedTask( |
| 457 FROM_HERE, | 457 FROM_HERE, |
| 458 base::Bind(&ThreadWatcherList::InitializeAndStartWatching, | 458 base::Bind(&ThreadWatcherList::InitializeAndStartWatching, |
| 459 unresponsive_threshold, | 459 unresponsive_threshold, |
| 460 crash_on_hang_threads), | 460 crash_on_hang_threads), |
| 461 base::TimeDelta::FromSeconds(g_initialize_delay_seconds)); | 461 base::TimeDelta::FromSeconds(g_initialize_delay_seconds))) { |
| 462 // Disarm() the startup timebomb, if we couldn't post the task to start the |
| 463 // ThreadWatcher (becasue WatchDog thread is not running). |
| 464 StartupTimeBomb::DisarmStartupTimeBomb(); |
| 465 } |
| 462 } | 466 } |
| 463 | 467 |
| 464 // static | 468 // static |
| 465 void ThreadWatcherList::StopWatchingAll() { | 469 void ThreadWatcherList::StopWatchingAll() { |
| 466 // TODO(rtenneti): Enable ThreadWatcher. | 470 // TODO(rtenneti): Enable ThreadWatcher. |
| 467 ThreadWatcherObserver::RemoveNotifications(); | 471 ThreadWatcherObserver::RemoveNotifications(); |
| 468 DeleteAll(); | 472 DeleteAll(); |
| 469 } | 473 } |
| 470 | 474 |
| 471 // static | 475 // static |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 | 1081 |
| 1078 #if defined(OS_WIN) | 1082 #if defined(OS_WIN) |
| 1079 // On Windows XP, give twice the time for shutdown. | 1083 // On Windows XP, give twice the time for shutdown. |
| 1080 if (base::win::GetVersion() <= base::win::VERSION_XP) | 1084 if (base::win::GetVersion() <= base::win::VERSION_XP) |
| 1081 actual_duration *= 2; | 1085 actual_duration *= 2; |
| 1082 #endif | 1086 #endif |
| 1083 | 1087 |
| 1084 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration); | 1088 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration); |
| 1085 shutdown_watchdog_->Arm(); | 1089 shutdown_watchdog_->Arm(); |
| 1086 } | 1090 } |
| OLD | NEW |