summaryrefslogtreecommitdiffstats
path: root/chrome/browser/metrics/thread_watcher.cc
diff options
context:
space:
mode:
authorrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-19 01:46:51 +0000
committerrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-19 01:46:51 +0000
commit75715c3104c131d1a0ea811afd4165f9d1412f80 (patch)
tree91acb6af5d76385281b2a655371dfdc2c0582448 /chrome/browser/metrics/thread_watcher.cc
parenta7d80dc675c467d3ea9c0af84c8a2ab8faff2a60 (diff)
downloadchromium_src-75715c3104c131d1a0ea811afd4165f9d1412f80.zip
chromium_src-75715c3104c131d1a0ea811afd4165f9d1412f80.tar.gz
chromium_src-75715c3104c131d1a0ea811afd4165f9d1412f80.tar.bz2
Watchdog - Added a JOINABLE state to avoid StartupTimebomb
blocking UI thread during Watchdog thread join. StartupTimebomb deletes the startup_watchdog thread only if it is joinable. This fixes the case when UI thread is blocked until watchdog thread finishes generating the dump. StartupTimebomb keeps calling IsJoinable on startup_watchdog thread every 10 secs until it is joinable until it is deleted. The delete method calls Cleanup to set the state to SHUTDOWN for backward compatability. BUG=110055 R=jar TEST=base unit tests and browser ui and unit tests. Review URL: http://codereview.chromium.org/9173002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118209 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/metrics/thread_watcher.cc')
-rw-r--r--chrome/browser/metrics/thread_watcher.cc26
1 files changed, 19 insertions, 7 deletions
diff --git a/chrome/browser/metrics/thread_watcher.cc b/chrome/browser/metrics/thread_watcher.cc
index 7ecc304..c33bc59 100644
--- a/chrome/browser/metrics/thread_watcher.cc
+++ b/chrome/browser/metrics/thread_watcher.cc
@@ -564,6 +564,11 @@ void ThreadWatcherList::InitializeAndStartWatching(
ThreadWatcherList* thread_watcher_list = new ThreadWatcherList();
CHECK(thread_watcher_list);
+ BrowserThread::PostTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&StartupTimeBomb::DisarmStartupTimeBomb));
+
const base::TimeDelta kSleepTime =
base::TimeDelta::FromSeconds(kSleepSeconds);
const base::TimeDelta kUnresponsiveTime =
@@ -588,11 +593,6 @@ void ThreadWatcherList::InitializeAndStartWatching(
StartWatching(BrowserThread::CACHE, "CACHE", kSleepTime, kUnresponsiveTime,
unresponsive_threshold, crash_on_hang_thread_names,
live_threads_threshold);
-
- BrowserThread::PostTask(
- BrowserThread::UI,
- FROM_HERE,
- base::Bind(&StartupTimeBomb::DisarmStartupTimeBomb));
}
// static
@@ -844,7 +844,6 @@ StartupTimeBomb::~StartupTimeBomb() {
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();
@@ -852,15 +851,28 @@ void StartupTimeBomb::Arm(const base::TimeDelta& duration) {
void StartupTimeBomb::Disarm() {
DCHECK_EQ(thread_id_, base::PlatformThread::CurrentId());
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (startup_watchdog_) {
startup_watchdog_->Disarm();
+ startup_watchdog_->Cleanup();
+ DeleteStartupWatchdog();
+ }
+}
+
+void StartupTimeBomb::DeleteStartupWatchdog() {
+ DCHECK_EQ(thread_id_, base::PlatformThread::CurrentId());
+ if (startup_watchdog_->IsJoinable()) {
// Allow the watchdog thread to shutdown on UI. Watchdog thread shutdowns
// very fast.
base::ThreadRestrictions::SetIOAllowed(true);
delete startup_watchdog_;
startup_watchdog_ = NULL;
+ return;
}
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&StartupTimeBomb::DeleteStartupWatchdog,
+ base::Unretained(this)),
+ base::TimeDelta::FromSeconds(10).InMilliseconds());
}
// static