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

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
« no previous file with comments | « chrome/browser/metrics/thread_watcher.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,18 +828,33 @@
// StartupTimeBomb methods and members.
//
// static
-base::Watchdog* StartupTimeBomb::startup_watchdog_ = NULL;
+StartupTimeBomb* StartupTimeBomb::g_startup_timebomb_ = NULL;
-// static
+StartupTimeBomb::StartupTimeBomb()
+ : startup_watchdog_(NULL),
+ thread_id_(base::PlatformThread::CurrentId()) {
+ CHECK(!g_startup_timebomb_);
+ g_startup_timebomb_ = this;
+}
+
+StartupTimeBomb::~StartupTimeBomb() {
+ DCHECK(this == g_startup_timebomb_);
+ DCHECK_EQ(thread_id_, base::PlatformThread::CurrentId());
+ if (startup_watchdog_)
+ Disarm();
+ g_startup_timebomb_ = NULL;
+}
+
void StartupTimeBomb::Arm(const base::TimeDelta& duration) {
+ DCHECK_EQ(thread_id_, base::PlatformThread::CurrentId());
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!startup_watchdog_);
startup_watchdog_ = new StartupWatchDogThread(duration);
startup_watchdog_->Arm();
}
-// static
void StartupTimeBomb::Disarm() {
+ DCHECK_EQ(thread_id_, base::PlatformThread::CurrentId());
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (startup_watchdog_) {
startup_watchdog_->Disarm();
@@ -851,14 +866,24 @@
}
}
+// 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
// shutdown.
-ShutdownWatcherHelper::ShutdownWatcherHelper() : shutdown_watchdog_(NULL) {
+ShutdownWatcherHelper::ShutdownWatcherHelper()
+ : shutdown_watchdog_(NULL),
+ thread_id_(base::PlatformThread::CurrentId()) {
}
ShutdownWatcherHelper::~ShutdownWatcherHelper() {
+ DCHECK_EQ(thread_id_, base::PlatformThread::CurrentId());
if (shutdown_watchdog_) {
shutdown_watchdog_->Disarm();
delete shutdown_watchdog_;
@@ -867,6 +892,7 @@
}
void ShutdownWatcherHelper::Arm(const base::TimeDelta& duration) {
+ DCHECK_EQ(thread_id_, base::PlatformThread::CurrentId());
DCHECK(!shutdown_watchdog_);
base::TimeDelta actual_duration = duration;
« no previous file with comments | « chrome/browser/metrics/thread_watcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698