summaryrefslogtreecommitdiffstats
path: root/base/threading
diff options
context:
space:
mode:
authortedvessenes@gmail.com <tedvessenes@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-31 22:53:51 +0000
committertedvessenes@gmail.com <tedvessenes@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-31 22:53:51 +0000
commita1b75b94f61d90054e3b432e8be3c897383450bd (patch)
tree22a388ee703fe9aa05aab3cb850e0012c3b501f8 /base/threading
parentd117d35a46d16907c89b92e5ed03d40690fb8f81 (diff)
downloadchromium_src-a1b75b94f61d90054e3b432e8be3c897383450bd.zip
chromium_src-a1b75b94f61d90054e3b432e8be3c897383450bd.tar.gz
chromium_src-a1b75b94f61d90054e3b432e8be3c897383450bd.tar.bz2
Change code in base (primarily unit tests) to use Sleep(TimeDelta).
BUG=108171 TEST= Review URL: http://codereview.chromium.org/9055001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116065 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/threading')
-rw-r--r--base/threading/platform_thread_unittest.cc4
-rw-r--r--base/threading/thread_collision_warner_unittest.cc6
-rw-r--r--base/threading/thread_unittest.cc10
-rw-r--r--base/threading/watchdog_unittest.cc9
4 files changed, 16 insertions, 13 deletions
diff --git a/base/threading/platform_thread_unittest.cc b/base/threading/platform_thread_unittest.cc
index 4b49450..6bff1d4 100644
--- a/base/threading/platform_thread_unittest.cc
+++ b/base/threading/platform_thread_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -59,7 +59,7 @@ class FunctionTestThread : public TrivialThread {
virtual void ThreadMain() {
thread_id_ = PlatformThread::CurrentId();
PlatformThread::YieldCurrentThread();
- PlatformThread::Sleep(50);
+ PlatformThread::Sleep(TimeDelta::FromMilliseconds(50));
TrivialThread::ThreadMain();
}
diff --git a/base/threading/thread_collision_warner_unittest.cc b/base/threading/thread_collision_warner_unittest.cc
index 4613955..d9e535b8 100644
--- a/base/threading/thread_collision_warner_unittest.cc
+++ b/base/threading/thread_collision_warner_unittest.cc
@@ -190,7 +190,7 @@ TEST(ThreadCollisionTest, MTScopedBookCriticalSectionTest) {
void push(int value) {
DFAKE_SCOPED_LOCK(push_pop_);
- base::PlatformThread::Sleep(5000);
+ base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(5));
}
int pop() {
@@ -248,7 +248,7 @@ TEST(ThreadCollisionTest, MTSynchedScopedBookCriticalSectionTest) {
void push(int value) {
DFAKE_SCOPED_LOCK(push_pop_);
- base::PlatformThread::Sleep(2000);
+ base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(2));
}
int pop() {
@@ -318,7 +318,7 @@ TEST(ThreadCollisionTest, MTSynchedScopedRecursiveBookCriticalSectionTest) {
void push(int) {
DFAKE_SCOPED_RECURSIVE_LOCK(push_pop_);
bar();
- base::PlatformThread::Sleep(2000);
+ base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(2));
}
int pop() {
diff --git a/base/threading/thread_unittest.cc b/base/threading/thread_unittest.cc
index be5ad90..0444947 100644
--- a/base/threading/thread_unittest.cc
+++ b/base/threading/thread_unittest.cc
@@ -36,7 +36,7 @@ class SleepInsideInitThread : public Thread {
}
virtual void Init() {
- base::PlatformThread::Sleep(500);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(500));
init_called_ = true;
}
bool InitCalled() { return init_called_; }
@@ -162,7 +162,7 @@ TEST_F(ThreadTest, StartWithOptions_StackSize) {
// instead to avoid busy waiting, but this is sufficient for
// testing purposes).
for (int i = 100; i >= 0 && !was_invoked; --i) {
- base::PlatformThread::Sleep(10);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10));
}
EXPECT_TRUE(was_invoked);
}
@@ -179,8 +179,10 @@ TEST_F(ThreadTest, TwoTasks) {
// event that will toggle our sentinel value.
a.message_loop()->PostTask(
FROM_HERE,
- base::Bind(static_cast<void (*)(int)>(&base::PlatformThread::Sleep),
- 20));
+ base::Bind(
+ static_cast<void (*)(base::TimeDelta)>(
+ &base::PlatformThread::Sleep),
+ base::TimeDelta::FromMilliseconds(20)));
a.message_loop()->PostTask(FROM_HERE, base::Bind(&ToggleValue,
&was_invoked));
}
diff --git a/base/threading/watchdog_unittest.cc b/base/threading/watchdog_unittest.cc
index f96487b..32a137f 100644
--- a/base/threading/watchdog_unittest.cc
+++ b/base/threading/watchdog_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -99,7 +99,7 @@ TEST_F(WatchdogTest, ConstructorDisabledTest) {
WatchdogCounter watchdog(TimeDelta::FromMilliseconds(10), "Disabled", false);
watchdog.Arm();
// Alarm should not fire, as it was disabled.
- PlatformThread::Sleep(500);
+ PlatformThread::Sleep(TimeDelta::FromMilliseconds(500));
EXPECT_EQ(0, watchdog.alarm_counter());
}
@@ -109,7 +109,8 @@ TEST_F(WatchdogTest, DisarmTest) {
TimeTicks start = TimeTicks::Now();
watchdog.Arm();
- PlatformThread::Sleep(100); // Sleep a bit, but not past the alarm point.
+ // Sleep a bit, but not past the alarm point.
+ PlatformThread::Sleep(TimeDelta::FromMilliseconds(100));
watchdog.Disarm();
TimeTicks end = TimeTicks::Now();
@@ -124,7 +125,7 @@ TEST_F(WatchdogTest, DisarmTest) {
// Sleep past the point where it would have fired if it wasn't disarmed,
// and verify that it didn't fire.
- PlatformThread::Sleep(1000);
+ PlatformThread::Sleep(TimeDelta::FromSeconds(1));
EXPECT_EQ(0, watchdog.alarm_counter());
// ...but even after disarming, we can still use the alarm...