Index: chrome/browser/metrics/thread_watcher.cc |
=================================================================== |
--- chrome/browser/metrics/thread_watcher.cc (revision 111993) |
+++ chrome/browser/metrics/thread_watcher.cc (working copy) |
@@ -590,7 +590,7 @@ |
BrowserThread::PostTask( |
BrowserThread::UI, |
FROM_HERE, |
- base::Bind(StartupTimeBomb::Disarm)); |
+ base::Bind(&StartupTimeBomb::DisarmStartupTimeBomb)); |
} |
// static |
@@ -828,9 +828,19 @@ |
// StartupTimeBomb methods and members. |
// |
// static |
-base::Watchdog* StartupTimeBomb::startup_watchdog_ = NULL; |
+StartupTimeBomb* StartupTimeBomb::g_startup_timebomb_ = NULL; |
-// static |
+StartupTimeBomb::StartupTimeBomb() : startup_watchdog_(NULL) { |
+ CHECK(!g_startup_timebomb_); |
+ g_startup_timebomb_ = this; |
+} |
+ |
+StartupTimeBomb::~StartupTimeBomb() { |
+ DCHECK(this == g_startup_timebomb_); |
+ Disarm(); |
+ g_startup_timebomb_ = NULL; |
+} |
+ |
void StartupTimeBomb::Arm(const base::TimeDelta& duration) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
DCHECK(!startup_watchdog_); |
@@ -838,9 +848,8 @@ |
startup_watchdog_->Arm(); |
} |
-// static |
void StartupTimeBomb::Disarm() { |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ // This could be disarm'ed during shutdown when we are not on UI thread. |
jar (doing other things)
2011/11/30 17:18:39
I think this will be racy if called from other tha
ramant (doing other things)
2011/11/30 22:08:40
Added DCHECK's for thread_id for StartupTimeBomb a
|
if (startup_watchdog_) { |
startup_watchdog_->Disarm(); |
// Allow the watchdog thread to shutdown on UI. Watchdog thread shutdowns |
@@ -851,6 +860,13 @@ |
} |
} |
+// static |
+void StartupTimeBomb::DisarmStartupTimeBomb() { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ if (g_startup_timebomb_) |
+ g_startup_timebomb_->Disarm(); |
+} |
+ |
// ShutdownWatcherHelper methods and members. |
// |
// ShutdownWatcherHelper is a wrapper class for detecting hangs during |