summaryrefslogtreecommitdiffstats
path: root/chrome/browser/metrics
diff options
context:
space:
mode:
authorrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-26 06:41:23 +0000
committerrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-26 06:41:23 +0000
commit129071ef966172279f9614b7be04d48cb304130e (patch)
tree7b8ec3b813c400ac4893759cd95f7577702a51ba /chrome/browser/metrics
parentc82b0682d1d66e38346a664ef83d1211f83b3b5f (diff)
downloadchromium_src-129071ef966172279f9614b7be04d48cb304130e.zip
chromium_src-129071ef966172279f9614b7be04d48cb304130e.tar.gz
chromium_src-129071ef966172279f9614b7be04d48cb304130e.tar.bz2
Revert 76154 - Revert 76015 - Added back thread watcher changes by
reverting the revert. will revert the changes right away. trying to test impact on memory on mac. BUG=73915 TEST=performance tests Review URL: http://codereview.chromium.org/6594011 TBR=rtenneti@chromium.org Review URL: http://codereview.chromium.org/6588038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76155 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/metrics')
-rw-r--r--chrome/browser/metrics/thread_watcher.cc86
-rw-r--r--chrome/browser/metrics/thread_watcher.h17
-rw-r--r--chrome/browser/metrics/thread_watcher_unittest.cc13
3 files changed, 43 insertions, 73 deletions
diff --git a/chrome/browser/metrics/thread_watcher.cc b/chrome/browser/metrics/thread_watcher.cc
index 9a07dde..ececcac 100644
--- a/chrome/browser/metrics/thread_watcher.cc
+++ b/chrome/browser/metrics/thread_watcher.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#if 0
+
#include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
#include "chrome/browser/metrics/metrics_service.h"
@@ -190,7 +192,7 @@ ThreadWatcherList::ThreadWatcherList()
// Assert we are not running on WATCHDOG thread. Would be ideal to assert we
// are on UI thread, but Unit tests are not running on UI thread.
DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::WATCHDOG));
- CHECK(!global_);
+ DCHECK(!global_);
global_ = this;
// Register Notifications observer.
#if defined(OS_WIN)
@@ -200,6 +202,11 @@ ThreadWatcherList::ThreadWatcherList()
ThreadWatcherList::~ThreadWatcherList() {
base::AutoLock auto_lock(lock_);
+ while (!registered_.empty()) {
+ RegistrationList::iterator it = registered_.begin();
+ delete it->second;
+ registered_.erase(it->first);
+ }
DCHECK(this == global_);
global_ = NULL;
}
@@ -217,15 +224,15 @@ void ThreadWatcherList::StopWatchingAll() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (!global_)
return;
-
- // Remove all notifications for all watched threads.
- RemoveNotifications();
-
- // Delete all thread watcher objects on WATCHDOG thread.
- BrowserThread::PostTask(
- BrowserThread::WATCHDOG,
- FROM_HERE,
- NewRunnableMethod(global_, &ThreadWatcherList::DeleteAll));
+ base::AutoLock auto_lock(global_->lock_);
+ for (RegistrationList::iterator it = global_->registered_.begin();
+ global_->registered_.end() != it;
+ ++it)
+ BrowserThread::PostTask(
+ BrowserThread::WATCHDOG,
+ FROM_HERE,
+ NewRunnableMethod(
+ it->second, &ThreadWatcher::DeActivateThreadWatching));
}
// static
@@ -239,16 +246,6 @@ void ThreadWatcherList::RemoveNotifications() {
#endif
}
-void ThreadWatcherList::DeleteAll() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WATCHDOG));
- base::AutoLock auto_lock(lock_);
- while (!registered_.empty()) {
- RegistrationList::iterator it = registered_.begin();
- delete it->second;
- registered_.erase(it->first);
- }
-}
-
void ThreadWatcherList::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
@@ -306,6 +303,8 @@ WatchDogThread::WatchDogThread()
}
WatchDogThread::~WatchDogThread() {
+ // Remove all notifications for all watched threads.
+ ThreadWatcherList::RemoveNotifications();
// We cannot rely on our base class to stop the thread since we want our
// CleanUp function to run.
Stop();
@@ -318,42 +317,19 @@ void WatchDogThread::Init() {
BrowserProcessSubThread::Init();
#if defined(OS_WIN)
- BrowserThread::PostDelayedTask(
- BrowserThread::WATCHDOG,
- FROM_HERE,
- NewRunnableFunction(&WatchDogThread::StartWatchingAll),
- base::TimeDelta::FromSeconds(10).InMilliseconds());
-#endif
-}
-
-void WatchDogThread::CleanUp() {
- BrowserProcessSubThread::CleanUp();
-}
-
-void WatchDogThread::CleanUpAfterMessageLoopDestruction() {
- // This will delete the |notification_service_|. Make sure it's done after
- // anything else can reference it.
- BrowserProcessSubThread::CleanUpAfterMessageLoopDestruction();
-}
-
-void WatchDogThread::StartWatchingAll() {
const base::TimeDelta kSleepTime = base::TimeDelta::FromSeconds(5);
const base::TimeDelta kUnresponsiveTime = base::TimeDelta::FromSeconds(10);
- if (BrowserThread::IsMessageLoopValid(BrowserThread::UI))
- ThreadWatcher::StartWatching(BrowserThread::UI, "UI", kSleepTime,
- kUnresponsiveTime);
- if (BrowserThread::IsMessageLoopValid(BrowserThread::IO))
- ThreadWatcher::StartWatching(BrowserThread::IO, "IO", kSleepTime,
- kUnresponsiveTime);
- if (BrowserThread::IsMessageLoopValid(BrowserThread::DB))
- ThreadWatcher::StartWatching(BrowserThread::DB, "DB", kSleepTime,
- kUnresponsiveTime);
- if (BrowserThread::IsMessageLoopValid(BrowserThread::FILE))
- ThreadWatcher::StartWatching(BrowserThread::FILE, "FILE", kSleepTime,
- kUnresponsiveTime);
- if (BrowserThread::IsMessageLoopValid(BrowserThread::CACHE))
- ThreadWatcher::StartWatching(BrowserThread::CACHE, "CACHE", kSleepTime,
- kUnresponsiveTime);
+ ThreadWatcher::StartWatching(BrowserThread::UI, "UI", kSleepTime,
+ kUnresponsiveTime);
+ ThreadWatcher::StartWatching(BrowserThread::IO, "IO", kSleepTime,
+ kUnresponsiveTime);
+ ThreadWatcher::StartWatching(BrowserThread::DB, "DB", kSleepTime,
+ kUnresponsiveTime);
+ ThreadWatcher::StartWatching(BrowserThread::FILE, "FILE", kSleepTime,
+ kUnresponsiveTime);
+ ThreadWatcher::StartWatching(BrowserThread::CACHE, "CACHE", kSleepTime,
+ kUnresponsiveTime);
+#endif
}
-
+#endif // 0
diff --git a/chrome/browser/metrics/thread_watcher.h b/chrome/browser/metrics/thread_watcher.h
index 7d93561..f7765c8 100644
--- a/chrome/browser/metrics/thread_watcher.h
+++ b/chrome/browser/metrics/thread_watcher.h
@@ -8,6 +8,8 @@
#define CHROME_BROWSER_METRICS_THREAD_WATCHER_H_
#pragma once
+#if 0
+
#include <map>
#include <string>
#include <vector>
@@ -204,33 +206,25 @@ class ThreadWatcherList : public NotificationObserver {
// This method posts a task on WATCHDOG thread to RevokeAll tasks and to
// deactive thread watching of other threads and tell NotificationService to
// stop calling Observe.
- // This method is accessible on UI thread.
static void StopWatchingAll();
// RemoveAll NotificationTypes that are being observed.
- // This method is accessible on UI thread.
static void RemoveNotifications();
private:
// Allow tests to access our innards for testing purposes.
FRIEND_TEST(ThreadWatcherTest, Registration);
- // Delete all thread watcher objects and remove them from global map.
- // This method is accessible on WATCHDOG thread.
- void DeleteAll();
-
// This will ensure that the watching is actively taking place. It will wakeup
// all thread watchers every 2 seconds. This is the implementation of
// NotificationObserver. When a matching notification is posted to the
// notification service, this method is called.
- // This method is accessible on UI thread.
virtual void Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details);
// This will ensure that the watching is actively taking place, and awaken
// all thread watchers that are registered.
- // This method is accessible on WATCHDOG thread.
virtual void WakeUpAll();
// The Find() method can be used to test to see if a given ThreadWatcher was
@@ -265,11 +259,6 @@ class WatchDogThread : public BrowserProcessSubThread {
protected:
virtual void Init();
- virtual void CleanUp();
- virtual void CleanUpAfterMessageLoopDestruction();
-
- // Start watching all browser threads.
- static void StartWatchingAll();
DISALLOW_COPY_AND_ASSIGN(WatchDogThread);
};
@@ -278,4 +267,6 @@ class WatchDogThread : public BrowserProcessSubThread {
DISABLE_RUNNABLE_METHOD_REFCOUNT(ThreadWatcher);
DISABLE_RUNNABLE_METHOD_REFCOUNT(ThreadWatcherList);
+#endif // 0
+
#endif // CHROME_BROWSER_METRICS_THREAD_WATCHER_H_
diff --git a/chrome/browser/metrics/thread_watcher_unittest.cc b/chrome/browser/metrics/thread_watcher_unittest.cc
index b077492..52a4288 100644
--- a/chrome/browser/metrics/thread_watcher_unittest.cc
+++ b/chrome/browser/metrics/thread_watcher_unittest.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#if 0
+
#include "base/basictypes.h"
#include "base/logging.h"
#include "base/message_loop.h"
@@ -11,13 +13,10 @@
#include "base/synchronization/lock.h"
#include "base/threading/platform_thread.h"
#include "base/time.h"
-#include "build/build_config.h"
#include "chrome/browser/metrics/thread_watcher.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
-#if defined(OS_WIN)
-
using base::TimeDelta;
using base::TimeTicks;
@@ -246,6 +245,10 @@ class ThreadWatcherTest : public ::testing::Test {
CustomThreadWatcher* webkit_watcher_;
ThreadWatcherTest() {
+ }
+
+ protected:
+ virtual void SetUp() {
webkit_thread_.reset(new BrowserThread(BrowserThread::WEBKIT));
io_thread_.reset(new BrowserThread(BrowserThread::IO));
watchdog_thread_.reset(new BrowserThread(BrowserThread::WATCHDOG));
@@ -265,7 +268,7 @@ class ThreadWatcherTest : public ::testing::Test {
webkit_thread_id, webkit_thread_name, kSleepTime, kUnresponsiveTime);
}
- ~ThreadWatcherTest() {
+ virtual void TearDown() {
// io_thread_->Stop();
// webkit_thread_->Stop();
// watchdog_thread_->Stop();
@@ -479,4 +482,4 @@ TEST_F(ThreadWatcherTest, MultipleThreadsNotResponding) {
webkit_watcher_, &ThreadWatcher::DeActivateThreadWatching));
}
-#endif // OS_WIN
+#endif // 0