Reverting the revert 76468. Removed include for browser_thread.h.
Enable the WATCHDOG thread that monitors browser threads for their
responsiveness using ping-pong messaging. WACTHDOG thread also
collects statistics for response time for each thread via histograms.
This CL was approved http://codereview.chromium.org/6588039
BUG=71378, 73915, 73844, 73975
TEST=performance tests
TBR=jar
Review URL: http://codereview.chromium.org/6591091
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76561 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index 3a76341..b173c7238 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -31,6 +31,7 @@
#include "chrome/browser/intranet_redirect_detector.h"
#include "chrome/browser/io_thread.h"
#include "chrome/browser/metrics/metrics_service.h"
+#include "chrome/browser/metrics/thread_watcher.h"
#include "chrome/browser/net/chrome_net_log.h"
#include "chrome/browser/net/predictor_api.h"
#include "chrome/browser/net/sdch_dictionary_fetcher.h"
@@ -98,6 +99,7 @@
created_db_thread_(false),
created_process_launcher_thread_(false),
created_cache_thread_(false),
+ created_watchdog_thread_(false),
created_profile_manager_(false),
created_local_state_(false),
created_icon_manager_(false),
@@ -248,6 +250,9 @@
// on the db thread too.
db_thread_.reset();
+ // Stop the watchdog thread after stopping other threads.
+ watchdog_thread_.reset();
+
// At this point, no render process exist and the file, io, db, and
// webkit threads in this process have all terminated, so it's safe
// to access local state data such as cookies, database, or local storage.
@@ -393,6 +398,14 @@
}
#endif
+WatchDogThread* BrowserProcessImpl::watchdog_thread() {
+ DCHECK(CalledOnValidThread());
+ if (!created_watchdog_thread_)
+ CreateWatchdogThread();
+ DCHECK(watchdog_thread_.get() != NULL);
+ return watchdog_thread_.get();
+}
+
ProfileManager* BrowserProcessImpl::profile_manager() {
DCHECK(CalledOnValidThread());
if (!created_profile_manager_)
@@ -734,6 +747,16 @@
cache_thread_.swap(thread);
}
+void BrowserProcessImpl::CreateWatchdogThread() {
+ DCHECK(!created_watchdog_thread_ && watchdog_thread_.get() == NULL);
+ created_watchdog_thread_ = true;
+
+ scoped_ptr<WatchDogThread> thread(new WatchDogThread());
+ if (!thread->Start())
+ return;
+ watchdog_thread_.swap(thread);
+}
+
void BrowserProcessImpl::CreateProfileManager() {
DCHECK(!created_profile_manager_ && profile_manager_.get() == NULL);
created_profile_manager_ = true;