summaryrefslogtreecommitdiffstats
path: root/chrome/browser/metrics/thread_watcher.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/metrics/thread_watcher.cc')
-rw-r--r--chrome/browser/metrics/thread_watcher.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/chrome/browser/metrics/thread_watcher.cc b/chrome/browser/metrics/thread_watcher.cc
index 1737593..8246b3e 100644
--- a/chrome/browser/metrics/thread_watcher.cc
+++ b/chrome/browser/metrics/thread_watcher.cc
@@ -409,6 +409,8 @@ bool ThreadWatcher::IsVeryUnresponsive() {
// static
ThreadWatcherList* ThreadWatcherList::g_thread_watcher_list_ = NULL;
// static
+bool ThreadWatcherList::g_stopped_ = false;
+// static
const int ThreadWatcherList::kSleepSeconds = 1;
// static
const int ThreadWatcherList::kUnresponsiveSeconds = 2;
@@ -443,6 +445,10 @@ void ThreadWatcherList::StartWatchingAll(const CommandLine& command_line) {
ThreadWatcherObserver::SetupNotifications(
base::TimeDelta::FromSeconds(kSleepSeconds * unresponsive_threshold));
+ WatchDogThread::PostTask(
+ FROM_HERE,
+ base::Bind(&ThreadWatcherList::SetStopped, false));
+
WatchDogThread::PostDelayedTask(
FROM_HERE,
base::Bind(&ThreadWatcherList::InitializeAndStartWatching,
@@ -635,6 +641,12 @@ void ThreadWatcherList::InitializeAndStartWatching(
const CrashOnHangThreadMap& crash_on_hang_threads) {
DCHECK(WatchDogThread::CurrentlyOnWatchDogThread());
+ // This method is deferred in relationship to its StopWatchingAll()
+ // counterpart. If a previous initialization has already happened, or if
+ // stop has been called, there's nothing left to do here.
+ if (g_thread_watcher_list_ || g_stopped_)
+ return;
+
ThreadWatcherList* thread_watcher_list = new ThreadWatcherList();
CHECK(thread_watcher_list);
@@ -700,6 +712,9 @@ void ThreadWatcherList::DeleteAll() {
}
DCHECK(WatchDogThread::CurrentlyOnWatchDogThread());
+
+ SetStopped(true);
+
if (!g_thread_watcher_list_)
return;
@@ -725,6 +740,12 @@ ThreadWatcher* ThreadWatcherList::Find(const BrowserThread::ID& thread_id) {
return it->second;
}
+// static
+void ThreadWatcherList::SetStopped(bool stopped) {
+ DCHECK(WatchDogThread::CurrentlyOnWatchDogThread());
+ g_stopped_ = stopped;
+}
+
// ThreadWatcherObserver methods and members.
//
// static