OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/metrics/thread_watcher.h" | 5 #include "chrome/browser/metrics/thread_watcher.h" |
6 | 6 |
7 #include <math.h> // ceil | 7 #include <math.h> // ceil |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 (*crash_on_hang_threads)[thread_name] = crash_data; | 650 (*crash_on_hang_threads)[thread_name] = crash_data; |
651 } | 651 } |
652 } | 652 } |
653 | 653 |
654 // static | 654 // static |
655 void ThreadWatcherList::InitializeAndStartWatching( | 655 void ThreadWatcherList::InitializeAndStartWatching( |
656 uint32 unresponsive_threshold, | 656 uint32 unresponsive_threshold, |
657 const CrashOnHangThreadMap& crash_on_hang_threads) { | 657 const CrashOnHangThreadMap& crash_on_hang_threads) { |
658 DCHECK(WatchDogThread::CurrentlyOnWatchDogThread()); | 658 DCHECK(WatchDogThread::CurrentlyOnWatchDogThread()); |
659 | 659 |
| 660 // Disarm the startup timebomb, even if stop has been called. |
| 661 BrowserThread::PostTask( |
| 662 BrowserThread::UI, |
| 663 FROM_HERE, |
| 664 base::Bind(&StartupTimeBomb::DisarmStartupTimeBomb)); |
| 665 |
660 // This method is deferred in relationship to its StopWatchingAll() | 666 // This method is deferred in relationship to its StopWatchingAll() |
661 // counterpart. If a previous initialization has already happened, or if | 667 // counterpart. If a previous initialization has already happened, or if |
662 // stop has been called, there's nothing left to do here. | 668 // stop has been called, there's nothing left to do here. |
663 if (g_thread_watcher_list_ || g_stopped_) | 669 if (g_thread_watcher_list_ || g_stopped_) |
664 return; | 670 return; |
665 | 671 |
666 ThreadWatcherList* thread_watcher_list = new ThreadWatcherList(); | 672 ThreadWatcherList* thread_watcher_list = new ThreadWatcherList(); |
667 CHECK(thread_watcher_list); | 673 CHECK(thread_watcher_list); |
668 | 674 |
669 BrowserThread::PostTask( | |
670 BrowserThread::UI, | |
671 FROM_HERE, | |
672 base::Bind(&StartupTimeBomb::DisarmStartupTimeBomb)); | |
673 | |
674 const base::TimeDelta kSleepTime = | 675 const base::TimeDelta kSleepTime = |
675 base::TimeDelta::FromSeconds(kSleepSeconds); | 676 base::TimeDelta::FromSeconds(kSleepSeconds); |
676 const base::TimeDelta kUnresponsiveTime = | 677 const base::TimeDelta kUnresponsiveTime = |
677 base::TimeDelta::FromSeconds(kUnresponsiveSeconds); | 678 base::TimeDelta::FromSeconds(kUnresponsiveSeconds); |
678 | 679 |
679 StartWatching(BrowserThread::UI, "UI", kSleepTime, kUnresponsiveTime, | 680 StartWatching(BrowserThread::UI, "UI", kSleepTime, kUnresponsiveTime, |
680 unresponsive_threshold, crash_on_hang_threads); | 681 unresponsive_threshold, crash_on_hang_threads); |
681 StartWatching(BrowserThread::IO, "IO", kSleepTime, kUnresponsiveTime, | 682 StartWatching(BrowserThread::IO, "IO", kSleepTime, kUnresponsiveTime, |
682 unresponsive_threshold, crash_on_hang_threads); | 683 unresponsive_threshold, crash_on_hang_threads); |
683 StartWatching(BrowserThread::DB, "DB", kSleepTime, kUnresponsiveTime, | 684 StartWatching(BrowserThread::DB, "DB", kSleepTime, kUnresponsiveTime, |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1079 | 1080 |
1080 #if defined(OS_WIN) | 1081 #if defined(OS_WIN) |
1081 // On Windows XP, give twice the time for shutdown. | 1082 // On Windows XP, give twice the time for shutdown. |
1082 if (base::win::GetVersion() <= base::win::VERSION_XP) | 1083 if (base::win::GetVersion() <= base::win::VERSION_XP) |
1083 actual_duration *= 2; | 1084 actual_duration *= 2; |
1084 #endif | 1085 #endif |
1085 | 1086 |
1086 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration); | 1087 shutdown_watchdog_ = new ShutdownWatchDogThread(actual_duration); |
1087 shutdown_watchdog_->Arm(); | 1088 shutdown_watchdog_->Arm(); |
1088 } | 1089 } |
OLD | NEW |