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

Unified Diff: chrome/browser/metrics/thread_watcher.cc

Issue 8728035: Disarm StartupTimeBomb when it is deleted (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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,8 @@
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
- base::Bind(StartupTimeBomb::Disarm));
+ base::Bind(&StartupTimeBomb::Disarm,
+ base::Unretained(StartupTimeBomb::g_startup_timebomb_)));
}
// static
@@ -828,9 +829,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 +849,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.
if (startup_watchdog_) {
startup_watchdog_->Disarm();
// Allow the watchdog thread to shutdown on UI. Watchdog thread shutdowns
« chrome/browser/metrics/thread_watcher.h ('K') | « chrome/browser/metrics/thread_watcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698