summaryrefslogtreecommitdiffstats
path: root/chrome/browser/metrics/thread_watcher_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/metrics/thread_watcher_unittest.cc')
-rw-r--r--chrome/browser/metrics/thread_watcher_unittest.cc80
1 files changed, 40 insertions, 40 deletions
diff --git a/chrome/browser/metrics/thread_watcher_unittest.cc b/chrome/browser/metrics/thread_watcher_unittest.cc
index 0082d08..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,7 +13,6 @@
#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"
@@ -145,7 +146,7 @@ class CustomThreadWatcher : public ThreadWatcher {
}
void VeryLongMethod(TimeDelta wait_time) {
- DCHECK(!WatchDogThread::CurrentlyOnWatchDogThread());
+ DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::WATCHDOG));
TimeTicks end_time = TimeTicks::Now() + wait_time;
{
base::AutoLock auto_lock(custom_lock_);
@@ -160,7 +161,7 @@ class CustomThreadWatcher : public ThreadWatcher {
}
State WaitForStateChange(const TimeDelta& wait_time, State expected_state) {
- DCHECK(!WatchDogThread::CurrentlyOnWatchDogThread());
+ DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::WATCHDOG));
UpdateWaitState(STARTED_WAITING);
State exit_state;
@@ -195,7 +196,7 @@ class CustomThreadWatcher : public ThreadWatcher {
CheckResponseState WaitForCheckResponse(const TimeDelta& wait_time,
CheckResponseState expected_state) {
- DCHECK(!WatchDogThread::CurrentlyOnWatchDogThread());
+ DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::WATCHDOG));
UpdateWaitState(STARTED_WAITING);
CheckResponseState exit_state;
@@ -244,9 +245,13 @@ 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 WatchDogThread());
+ watchdog_thread_.reset(new BrowserThread(BrowserThread::WATCHDOG));
webkit_thread_->Start();
io_thread_->Start();
watchdog_thread_->Start();
@@ -263,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();
@@ -276,7 +281,7 @@ class ThreadWatcherTest : public ::testing::Test {
private:
scoped_ptr<BrowserThread> webkit_thread_;
scoped_ptr<BrowserThread> io_thread_;
- scoped_ptr<WatchDogThread> watchdog_thread_;
+ scoped_ptr<BrowserThread> watchdog_thread_;
ThreadWatcherList* thread_watcher_list_;
};
@@ -314,15 +319,14 @@ TEST_F(ThreadWatcherTest, Registration) {
// Test ActivateThreadWatching and DeActivateThreadWatching of IO thread. This
// method also checks that pong message was sent by the watched thread and pong
-// message was received by the WatchDogThread. It also checks that
+// message was received by the WATCHDOG thread. It also checks that
// OnCheckResponsiveness has verified the ping-pong mechanism and the watched
// thread is not hung.
TEST_F(ThreadWatcherTest, ThreadResponding) {
TimeTicks time_before_ping = TimeTicks::Now();
// Activate watching IO thread.
- MessageLoop* message_loop = WatchDogThread::CurrentMessageLoop();
- ASSERT_TRUE(message_loop != NULL);
- message_loop->PostTask(
+ BrowserThread::PostTask(
+ BrowserThread::WATCHDOG,
FROM_HERE,
NewRunnableMethod(io_watcher_, &ThreadWatcher::ActivateThreadWatching));
@@ -345,9 +349,8 @@ TEST_F(ThreadWatcherTest, ThreadResponding) {
EXPECT_EQ(io_watcher_->failed_response_, static_cast<uint64>(0));
// DeActivate thread watching for shutdown.
- message_loop = WatchDogThread::CurrentMessageLoop();
- ASSERT_TRUE(message_loop != NULL);
- message_loop->PostTask(
+ BrowserThread::PostTask(
+ BrowserThread::WATCHDOG,
FROM_HERE,
NewRunnableMethod(io_watcher_, &ThreadWatcher::DeActivateThreadWatching));
}
@@ -368,9 +371,8 @@ TEST_F(ThreadWatcherTest, ThreadNotResponding) {
kUnresponsiveTime * 10));
// Activate thread watching.
- MessageLoop* message_loop = WatchDogThread::CurrentMessageLoop();
- ASSERT_TRUE(message_loop != NULL);
- message_loop->PostTask(
+ BrowserThread::PostTask(
+ BrowserThread::WATCHDOG,
FROM_HERE,
NewRunnableMethod(io_watcher_, &ThreadWatcher::ActivateThreadWatching));
@@ -381,9 +383,8 @@ TEST_F(ThreadWatcherTest, ThreadNotResponding) {
EXPECT_GT(io_watcher_->failed_response_, static_cast<uint64>(0));
// DeActivate thread watching for shutdown.
- message_loop = WatchDogThread::CurrentMessageLoop();
- ASSERT_TRUE(message_loop != NULL);
- message_loop->PostTask(
+ BrowserThread::PostTask(
+ BrowserThread::WATCHDOG,
FROM_HERE,
NewRunnableMethod(io_watcher_, &ThreadWatcher::DeActivateThreadWatching));
}
@@ -391,15 +392,14 @@ TEST_F(ThreadWatcherTest, ThreadNotResponding) {
// Test watching of multiple threads with all threads not responding.
TEST_F(ThreadWatcherTest, MultipleThreadsResponding) {
// Check for WEBKIT thread to perform ping/pong messaging.
- MessageLoop* message_loop = WatchDogThread::CurrentMessageLoop();
- ASSERT_TRUE(message_loop != NULL);
- message_loop->PostTask(
+ BrowserThread::PostTask(
+ BrowserThread::WATCHDOG,
FROM_HERE,
NewRunnableMethod(
webkit_watcher_, &ThreadWatcher::ActivateThreadWatching));
-
// Check for IO thread to perform ping/pong messaging.
- message_loop->PostTask(
+ BrowserThread::PostTask(
+ BrowserThread::WATCHDOG,
FROM_HERE,
NewRunnableMethod(io_watcher_, &ThreadWatcher::ActivateThreadWatching));
@@ -422,14 +422,12 @@ TEST_F(ThreadWatcherTest, MultipleThreadsResponding) {
EXPECT_EQ(io_watcher_->failed_response_, static_cast<uint64>(0));
// DeActivate thread watching for shutdown.
- message_loop = WatchDogThread::CurrentMessageLoop();
- ASSERT_TRUE(message_loop != NULL);
- message_loop->PostTask(
+ BrowserThread::PostTask(
+ BrowserThread::WATCHDOG,
FROM_HERE,
- NewRunnableMethod(
- io_watcher_, &ThreadWatcher::DeActivateThreadWatching));
-
- message_loop->PostTask(
+ NewRunnableMethod(io_watcher_, &ThreadWatcher::DeActivateThreadWatching));
+ BrowserThread::PostTask(
+ BrowserThread::WATCHDOG,
FROM_HERE,
NewRunnableMethod(
webkit_watcher_, &ThreadWatcher::DeActivateThreadWatching));
@@ -448,15 +446,15 @@ TEST_F(ThreadWatcherTest, MultipleThreadsNotResponding) {
kUnresponsiveTime * 10));
// Activate watching of WEBKIT thread.
- MessageLoop* message_loop = WatchDogThread::CurrentMessageLoop();
- ASSERT_TRUE(message_loop != NULL);
- message_loop->PostTask(
+ BrowserThread::PostTask(
+ BrowserThread::WATCHDOG,
FROM_HERE,
NewRunnableMethod(
webkit_watcher_, &ThreadWatcher::ActivateThreadWatching));
// Activate watching of IO thread.
- message_loop->PostTask(
+ BrowserThread::PostTask(
+ BrowserThread::WATCHDOG,
FROM_HERE,
NewRunnableMethod(io_watcher_, &ThreadWatcher::ActivateThreadWatching));
@@ -473,13 +471,15 @@ TEST_F(ThreadWatcherTest, MultipleThreadsNotResponding) {
EXPECT_GT(io_watcher_->failed_response_, static_cast<uint64>(0));
// DeActivate thread watching for shutdown.
- message_loop = WatchDogThread::CurrentMessageLoop();
- ASSERT_TRUE(message_loop != NULL);
- message_loop->PostTask(
+ BrowserThread::PostTask(
+ BrowserThread::WATCHDOG,
FROM_HERE,
NewRunnableMethod(io_watcher_, &ThreadWatcher::DeActivateThreadWatching));
- message_loop->PostTask(
+ BrowserThread::PostTask(
+ BrowserThread::WATCHDOG,
FROM_HERE,
NewRunnableMethod(
webkit_watcher_, &ThreadWatcher::DeActivateThreadWatching));
}
+
+#endif // 0