Index: chrome/browser/browser_main.cc |
=================================================================== |
--- chrome/browser/browser_main.cc (revision 76198) |
+++ chrome/browser/browser_main.cc (working copy) |
@@ -45,6 +45,7 @@ |
#include "chrome/browser/metrics/histogram_synchronizer.h" |
#include "chrome/browser/metrics/metrics_log.h" |
#include "chrome/browser/metrics/metrics_service.h" |
+#include "chrome/browser/metrics/thread_watcher.h" |
#include "chrome/browser/net/blob_url_request_job_factory.h" |
#include "chrome/browser/net/chrome_dns_cert_provenance_checker.h" |
#include "chrome/browser/net/chrome_dns_cert_provenance_checker_factory.h" |
@@ -702,6 +703,9 @@ |
process->process_launcher_thread(); |
process->cache_thread(); |
process->io_thread(); |
+ // Create watchdog thread after creating all other threads because it will |
+ // watch the other threads and they must be running. |
+ process->watchdog_thread(); |
} |
// Returns the new local state object, guaranteed non-NULL. |
@@ -1353,6 +1357,11 @@ |
scoped_refptr<HistogramSynchronizer> histogram_synchronizer( |
new HistogramSynchronizer()); |
+ // Initialize thread watcher system. This is a singleton and is used by |
+ // WatchDogThread to keep track of information about threads that are being |
+ // watched. |
+ scoped_ptr<ThreadWatcherList> thread_watcher_list(new ThreadWatcherList()); |
+ |
// Initialize the prefs of the local state. |
browser::RegisterLocalState(local_state); |
@@ -1386,6 +1395,14 @@ |
CreateChildThreads(browser_process.get()); |
+ // Start watching all browser threads for responsiveness. |
+ MessageLoop* message_loop = WatchDogThread::CurrentMessageLoop(); |
+ if (message_loop) |
+ message_loop->PostDelayedTask( |
+ FROM_HERE, |
+ NewRunnableFunction(&WatchDogThread::StartWatchingAll), |
+ base::TimeDelta::FromSeconds(10).InMilliseconds()); |
+ |
#if defined(OS_CHROMEOS) |
// Now that the file thread exists we can record our stats. |
chromeos::BootTimesLoader::Get()->RecordChromeMainStats(); |
@@ -1903,6 +1920,9 @@ |
process_singleton.Cleanup(); |
+ // Stop all tasks that might run on WatchDogThread. |
+ ThreadWatcherList::StopWatchingAll(); |
+ |
metrics->Stop(); |
// browser_shutdown takes care of deleting browser_process, so we need to |