summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/debug/debugger.cc2
-rw-r--r--base/debug/debugger_posix.cc4
-rw-r--r--base/debug/trace_event_unittest.cc8
-rw-r--r--base/file_util_unittest.cc9
-rw-r--r--base/lazy_instance_unittest.cc2
-rw-r--r--base/message_loop_unittest.cc43
-rw-r--r--base/process_util_posix.cc5
-rw-r--r--base/process_util_unittest.cc12
-rw-r--r--base/shared_memory_posix.cc2
-rw-r--r--base/shared_memory_unittest.cc6
-rw-r--r--base/spin_wait.h4
-rw-r--r--base/synchronization/condition_variable_unittest.cc4
-rw-r--r--base/synchronization/lock_unittest.cc12
-rw-r--r--base/synchronization/waitable_event_unittest.cc2
-rw-r--r--base/synchronization/waitable_event_watcher_unittest.cc2
-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
-rw-r--r--base/time_unittest.cc2
-rw-r--r--base/time_win_unittest.cc5
-rw-r--r--base/timer_unittest.cc2
-rw-r--r--base/tools_sanity_unittest.cc6
23 files changed, 86 insertions, 75 deletions
diff --git a/base/debug/debugger.cc b/base/debug/debugger.cc
index a0d8a92..79233c5 100644
--- a/base/debug/debugger.cc
+++ b/base/debug/debugger.cc
@@ -24,7 +24,7 @@ bool WaitForDebugger(int wait_seconds, bool silent) {
BreakDebugger();
return true;
}
- PlatformThread::Sleep(100);
+ PlatformThread::Sleep(TimeDelta::FromMilliseconds(100));
}
return false;
}
diff --git a/base/debug/debugger_posix.cc b/base/debug/debugger_posix.cc
index 4dee92d..f16cd6d 100644
--- a/base/debug/debugger_posix.cc
+++ b/base/debug/debugger_posix.cc
@@ -198,7 +198,9 @@ bool BeingDebugged() {
// Use GDB to set |go| to 1 to resume execution.
#define DEBUG_BREAK() do { \
volatile int go = 0; \
- while (!go) { base::PlatformThread::Sleep(100); } \
+ while (!go) { \
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); \
+ } \
} while (0)
#else
// ARM && !ANDROID
diff --git a/base/debug/trace_event_unittest.cc b/base/debug/trace_event_unittest.cc
index 36a510c..cb77fee 100644
--- a/base/debug/trace_event_unittest.cc
+++ b/base/debug/trace_event_unittest.cc
@@ -629,7 +629,7 @@ TEST_F(TraceEventTestFixture, DataCapturedThreshold) {
// 100+ seconds to avoid flakiness.
TRACE_EVENT_IF_LONGER_THAN0(100000000, "time", "threshold long1");
TRACE_EVENT_IF_LONGER_THAN0(200000000, "time", "threshold long2");
- base::PlatformThread::Sleep(20); // 20000 us
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(20));
}
// Test that a normal nested event remains after it's parent event is dropped.
@@ -654,7 +654,8 @@ TEST_F(TraceEventTestFixture, DataCapturedThreshold) {
TRACE_EVENT_IF_LONGER_THAN0(1000, "time", "3threshold1000");
{
TRACE_EVENT_IF_LONGER_THAN0(100, "time", "3threshold100");
- base::PlatformThread::Sleep(20);
+ base::PlatformThread::Sleep(
+ base::TimeDelta::FromMilliseconds(20));
}
}
}
@@ -678,7 +679,8 @@ TEST_F(TraceEventTestFixture, DataCapturedThreshold) {
{
TRACE_EVENT_IF_LONGER_THAN0(200000000, "time",
"4thresholdlong2");
- base::PlatformThread::Sleep(20);
+ base::PlatformThread::Sleep(
+ base::TimeDelta::FromMilliseconds(20));
}
}
}
diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc
index 4cd6f03..0cade2a 100644
--- a/base/file_util_unittest.cc
+++ b/base/file_util_unittest.cc
@@ -22,7 +22,6 @@
#include "base/path_service.h"
#include "base/scoped_temp_dir.h"
#include "base/threading/platform_thread.h"
-#include "base/time.h"
#include "base/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
@@ -349,11 +348,11 @@ TEST_F(FileUtilTest, FLAKY_CountFilesCreatedAfter) {
// Age to perfection
#if defined(OS_WIN)
- base::PlatformThread::Sleep(100);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100));
#elif defined(OS_POSIX)
// We need to wait at least one second here because the precision of
// file creation time is one second.
- base::PlatformThread::Sleep(1500);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1500));
#endif
// Establish our cutoff time
@@ -1250,9 +1249,9 @@ TEST_F(FileUtilTest, GetFileCreationLocalTime) {
SYSTEMTIME start_time;
GetLocalTime(&start_time);
- Sleep(100);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100));
CreateTextFile(file_name, L"New file!");
- Sleep(100);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100));
SYSTEMTIME end_time;
GetLocalTime(&end_time);
diff --git a/base/lazy_instance_unittest.cc b/base/lazy_instance_unittest.cc
index b177745..9ccbbd5 100644
--- a/base/lazy_instance_unittest.cc
+++ b/base/lazy_instance_unittest.cc
@@ -27,7 +27,7 @@ class SlowConstructor {
public:
SlowConstructor() : some_int_(0) {
// Sleep for 1 second to try to cause a race.
- base::PlatformThread::Sleep(1000);
+ base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1));
++constructed;
some_int_ = 12;
}
diff --git a/base/message_loop_unittest.cc b/base/message_loop_unittest.cc
index 7eb4f4a..01a57c8 100644
--- a/base/message_loop_unittest.cc
+++ b/base/message_loop_unittest.cc
@@ -176,8 +176,8 @@ void RunTest_PostTask_SEH(MessageLoop::Type message_loop_type) {
}
// This function runs slowly to simulate a large amount of work being done.
-static void SlowFunc(int pause_ms, int* quit_counter) {
- PlatformThread::Sleep(pause_ms);
+static void SlowFunc(TimeDelta pause, int* quit_counter) {
+ PlatformThread::Sleep(pause);
if (--(*quit_counter) == 0)
MessageLoop::current()->Quit();
}
@@ -190,7 +190,7 @@ static void RecordRunTimeFunc(Time* run_time, int* quit_counter) {
// Cause our Run function to take some time to execute. As a result we can
// count on subsequent RecordRunTimeFunc()s running at a future time,
// without worry about the resolution of our system clock being an issue.
- SlowFunc(10, quit_counter);
+ SlowFunc(TimeDelta::FromMilliseconds(10), quit_counter);
}
void RunTest_PostDelayedTask_Basic(MessageLoop::Type message_loop_type) {
@@ -273,12 +273,12 @@ void RunTest_PostDelayedTask_InPostOrder_2(
// Test that a delayed task still runs after a normal tasks even if the
// normal tasks take a long time to run.
- const int kPauseMS = 50;
+ const TimeDelta kPause = TimeDelta::FromMilliseconds(50);
int num_tasks = 2;
Time run_time;
- loop.PostTask(FROM_HERE, base::Bind(&SlowFunc, kPauseMS, &num_tasks));
+ loop.PostTask(FROM_HERE, base::Bind(&SlowFunc, kPause, &num_tasks));
loop.PostDelayedTask(
FROM_HERE, base::Bind(&RecordRunTimeFunc, &run_time, &num_tasks), 10);
@@ -288,7 +288,7 @@ void RunTest_PostDelayedTask_InPostOrder_2(
EXPECT_EQ(0, num_tasks);
- EXPECT_LT(kPauseMS, (time_after_run - time_before_run).InMilliseconds());
+ EXPECT_LT(kPause, time_after_run - time_before_run);
}
void RunTest_PostDelayedTask_InPostOrder_3(
@@ -349,7 +349,7 @@ void RunTest_PostDelayedTask_SharedTimer(
// In case both timers somehow run at nearly the same time, sleep a little
// and then run all pending to force them both to have run. This is just
// encouraging flakiness if there is any.
- PlatformThread::Sleep(100);
+ PlatformThread::Sleep(TimeDelta::FromMilliseconds(100));
loop.RunAllPending();
EXPECT_TRUE(run_time1.is_null());
@@ -402,7 +402,7 @@ void RunTest_PostDelayedTask_SharedTimer_SubPump() {
// In case both timers somehow run at nearly the same time, sleep a little
// and then run all pending to force them both to have run. This is just
// encouraging flakiness if there is any.
- PlatformThread::Sleep(100);
+ PlatformThread::Sleep(TimeDelta::FromMilliseconds(100));
loop.RunAllPending();
EXPECT_TRUE(run_time.is_null());
@@ -497,7 +497,7 @@ class Crasher : public base::RefCounted<Crasher> {
}
void Run() {
- PlatformThread::Sleep(1);
+ PlatformThread::Sleep(TimeDelta::FromMilliseconds(1));
if (trash_SEH_handler_)
::SetUnhandledExceptionFilter(&BadExceptionHandler);
// Generate a SEH fault. We do it in asm to make sure we know how to undo
@@ -736,7 +736,7 @@ void RecursiveFunc(TaskList* order, int cookie, int depth,
void RecursiveSlowFunc(TaskList* order, int cookie, int depth,
bool is_reentrant) {
RecursiveFunc(order, cookie, depth, is_reentrant);
- PlatformThread::Sleep(10); // milliseconds
+ PlatformThread::Sleep(TimeDelta::FromMilliseconds(10));
}
void QuitFunc(TaskList* order, int cookie) {
@@ -745,9 +745,9 @@ void QuitFunc(TaskList* order, int cookie) {
order->RecordEnd(QUITMESSAGELOOP, cookie);
}
-void SleepFunc(TaskList* order, int cookie, int ms) {
+void SleepFunc(TaskList* order, int cookie, TimeDelta delay) {
order->RecordStart(SLEEP, cookie);
- PlatformThread::Sleep(ms);
+ PlatformThread::Sleep(delay);
order->RecordEnd(SLEEP, cookie);
}
@@ -1056,8 +1056,9 @@ void RunTest_NonNestableInNestedLoop(MessageLoop::Type message_loop_type,
}
MessageLoop::current()->PostTask(FROM_HERE,
base::Bind(&OrderedFunc, &order, 3));
- MessageLoop::current()->PostTask(FROM_HERE,
- base::Bind(&SleepFunc, &order, 4, 50));
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&SleepFunc, &order, 4, TimeDelta::FromMilliseconds(50)));
MessageLoop::current()->PostTask(FROM_HERE,
base::Bind(&OrderedFunc, &order, 5));
if (use_delayed) {
@@ -1220,7 +1221,8 @@ void RunTest_IOHandler() {
TestIOHandler handler(kPipeName, callback_called, false);
thread_loop->PostTask(FROM_HERE, base::Bind(&TestIOHandler::Init,
base::Unretained(&handler)));
- Sleep(100); // Make sure the thread runs and sleeps for lack of work.
+ // Make sure the thread runs and sleeps for lack of work.
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100));
const char buffer[] = "Hello there!";
DWORD written;
@@ -1262,10 +1264,12 @@ void RunTest_WaitForIO() {
thread_loop->PostTask(FROM_HERE, base::Bind(&TestIOHandler::Init,
base::Unretained(&handler1)));
// TODO(ajwong): Do we really need such long Sleeps in ths function?
- Sleep(100); // Make sure the thread runs and sleeps for lack of work.
+ // Make sure the thread runs and sleeps for lack of work.
+ base::TimeDelta delay = base::TimeDelta::FromMilliseconds(100);
+ base::PlatformThread::Sleep(delay);
thread_loop->PostTask(FROM_HERE, base::Bind(&TestIOHandler::Init,
base::Unretained(&handler2)));
- Sleep(100);
+ base::PlatformThread::Sleep(delay);
// At this time handler1 is waiting to be called, and the thread is waiting
// on the Init method of handler2, filtering only handler2 callbacks.
@@ -1273,7 +1277,7 @@ void RunTest_WaitForIO() {
const char buffer[] = "Hello there!";
DWORD written;
EXPECT_TRUE(WriteFile(server1, buffer, sizeof(buffer), &written, NULL));
- Sleep(200);
+ base::PlatformThread::Sleep(2 * delay);
EXPECT_EQ(WAIT_TIMEOUT, WaitForSingleObject(callback1_called, 0)) <<
"handler1 has not been called";
@@ -1542,7 +1546,8 @@ TEST(MessageLoopTest, HighResolutionTimer) {
EXPECT_TRUE(loop.high_resolution_timers_enabled());
// Wait for a while so that high-resolution mode elapses.
- Sleep(MessageLoop::kHighResolutionTimerModeLeaseTimeMs);
+ base::PlatformThread::Sleep(TimeDelta::FromMilliseconds(
+ MessageLoop::kHighResolutionTimerModeLeaseTimeMs));
// Post a slow task to disable the high resolution timers.
loop.PostDelayedTask(FROM_HERE, base::Bind(&PostNTasksThenQuit, 1),
diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc
index addd1c3..5a1d442 100644
--- a/base/process_util_posix.cc
+++ b/base/process_util_posix.cc
@@ -31,7 +31,6 @@
#include "base/third_party/dynamic_annotations/dynamic_annotations.h"
#include "base/threading/platform_thread.h"
#include "base/threading/thread_restrictions.h"
-#include "base/time.h"
#if defined(OS_FREEBSD)
#include <sys/event.h>
@@ -1197,7 +1196,7 @@ bool WaitForProcessesToExit(const FilePath::StringType& executable_name,
result = true;
break;
}
- base::PlatformThread::Sleep(100);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100));
} while ((end_time - base::Time::Now()) > base::TimeDelta());
return result;
@@ -1264,7 +1263,7 @@ class BackgroundReaper : public PlatformThread::Delegate {
// Wait for 2 * timeout_ 500 milliseconds intervals.
for (unsigned i = 0; i < 2 * timeout_; ++i) {
- PlatformThread::Sleep(500); // 0.5 seconds
+ PlatformThread::Sleep(TimeDelta::FromMilliseconds(500));
if (IsChildDead(child_))
return;
}
diff --git a/base/process_util_unittest.cc b/base/process_util_unittest.cc
index 36d48b6..426a78f 100644
--- a/base/process_util_unittest.cc
+++ b/base/process_util_unittest.cc
@@ -74,7 +74,7 @@ const int kExpectedStillRunningExitCode = 0;
void WaitToDie(const char* filename) {
FILE *fp;
do {
- base::PlatformThread::Sleep(10);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10));
fp = fopen(filename, "r");
} while (!fp);
fclose(fp);
@@ -95,14 +95,14 @@ base::TerminationStatus WaitForChildTermination(base::ProcessHandle handle,
int* exit_code) {
// Now we wait until the result is something other than STILL_RUNNING.
base::TerminationStatus status = base::TERMINATION_STATUS_STILL_RUNNING;
- const int kIntervalMs = 20;
- int waited = 0;
+ const base::TimeDelta kInterval = base::TimeDelta::FromMilliseconds(20);
+ base::TimeDelta waited;
do {
status = base::GetTerminationStatus(handle, exit_code);
- base::PlatformThread::Sleep(kIntervalMs);
- waited += kIntervalMs;
+ base::PlatformThread::Sleep(kInterval);
+ waited += kInterval;
} while (status == base::TERMINATION_STATUS_STILL_RUNNING &&
- waited < TestTimeouts::action_max_timeout_ms());
+ waited.InMilliseconds() < TestTimeouts::action_max_timeout_ms());
return status;
}
diff --git a/base/shared_memory_posix.cc b/base/shared_memory_posix.cc
index a66c859..32a55e9 100644
--- a/base/shared_memory_posix.cc
+++ b/base/shared_memory_posix.cc
@@ -340,7 +340,7 @@ void SharedMemory::LockOrUnlockCommon(int function) {
continue;
} else if (errno == ENOLCK) {
// temporary kernel resource exaustion
- base::PlatformThread::Sleep(500);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(500));
continue;
} else {
NOTREACHED() << "lockf() failed."
diff --git a/base/shared_memory_unittest.cc b/base/shared_memory_unittest.cc
index ef5cf2e..a0df9b5 100644
--- a/base/shared_memory_unittest.cc
+++ b/base/shared_memory_unittest.cc
@@ -58,7 +58,7 @@ class MultipleThreadMain : public PlatformThread::Delegate {
for (int idx = 0; idx < 100; idx++) {
*ptr = idx;
- PlatformThread::Sleep(1); // Short wait.
+ PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1));
EXPECT_EQ(*ptr, idx);
}
// Reset back to 0 for the next test that uses the same name.
@@ -113,7 +113,7 @@ class MultipleLockThread : public PlatformThread::Delegate {
memory2.Lock();
int i = (id_ << 16) + idx;
*ptr = i;
- PlatformThread::Sleep(1); // Short wait.
+ PlatformThread::Sleep(TimeDelta::FromMilliseconds(1));
EXPECT_EQ(*ptr, i);
memory2.Unlock();
}
@@ -388,7 +388,7 @@ class SharedMemoryProcessTest : public MultiProcessTest {
memory.Lock();
int i = (1 << 16) + idx;
*ptr = i;
- PlatformThread::Sleep(10); // Short wait.
+ PlatformThread::Sleep(TimeDelta::FromMilliseconds(10));
if (*ptr != i)
errors++;
memory.Unlock();
diff --git a/base/spin_wait.h b/base/spin_wait.h
index 1e31b14..b609ba5 100644
--- a/base/spin_wait.h
+++ b/base/spin_wait.h
@@ -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.
@@ -44,7 +44,7 @@
kTimeout.InMilliseconds()) << "Timed out"; \
break; \
} \
- base::PlatformThread::Sleep(50); \
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(50)); \
} \
} while (0)
diff --git a/base/synchronization/condition_variable_unittest.cc b/base/synchronization/condition_variable_unittest.cc
index 808ecde..d3a53f2 100644
--- a/base/synchronization/condition_variable_unittest.cc
+++ b/base/synchronization/condition_variable_unittest.cc
@@ -661,7 +661,7 @@ void WorkQueue::SpinUntilAllThreadsAreWaiting() {
if (waiting_thread_count_ == thread_count_)
break;
}
- PlatformThread::Sleep(30);
+ PlatformThread::Sleep(TimeDelta::FromMilliseconds(30));
}
}
@@ -672,7 +672,7 @@ void WorkQueue::SpinUntilTaskCountLessThan(int task_count) {
if (task_count_ < task_count)
break;
}
- PlatformThread::Sleep(30);
+ PlatformThread::Sleep(TimeDelta::FromMilliseconds(30));
}
}
diff --git a/base/synchronization/lock_unittest.cc b/base/synchronization/lock_unittest.cc
index 5ac3e6b..1dae49b 100644
--- a/base/synchronization/lock_unittest.cc
+++ b/base/synchronization/lock_unittest.cc
@@ -25,13 +25,13 @@ class BasicLockTestThread : public PlatformThread::Delegate {
for (int i = 0; i < 10; i++) {
lock_->Acquire();
acquired_++;
- PlatformThread::Sleep(rand() % 20);
+ PlatformThread::Sleep(TimeDelta::FromMilliseconds(rand() % 20));
lock_->Release();
}
for (int i = 0; i < 10; i++) {
if (lock_->Try()) {
acquired_++;
- PlatformThread::Sleep(rand() % 20);
+ PlatformThread::Sleep(TimeDelta::FromMilliseconds(rand() % 20));
lock_->Release();
}
}
@@ -62,20 +62,20 @@ TEST(LockTest, Basic) {
for (int i = 0; i < 10; i++) {
lock.Acquire();
acquired++;
- PlatformThread::Sleep(rand() % 20);
+ PlatformThread::Sleep(TimeDelta::FromMilliseconds(rand() % 20));
lock.Release();
}
for (int i = 0; i < 10; i++) {
if (lock.Try()) {
acquired++;
- PlatformThread::Sleep(rand() % 20);
+ PlatformThread::Sleep(TimeDelta::FromMilliseconds(rand() % 20));
lock.Release();
}
}
for (int i = 0; i < 5; i++) {
lock.Acquire();
acquired++;
- PlatformThread::Sleep(rand() % 20);
+ PlatformThread::Sleep(TimeDelta::FromMilliseconds(rand() % 20));
lock.Release();
}
@@ -154,7 +154,7 @@ class MutexLockTestThread : public PlatformThread::Delegate {
for (int i = 0; i < 40; i++) {
lock->Acquire();
int v = *value;
- PlatformThread::Sleep(rand() % 10);
+ PlatformThread::Sleep(TimeDelta::FromMilliseconds(rand() % 10));
*value = v + 1;
lock->Release();
}
diff --git a/base/synchronization/waitable_event_unittest.cc b/base/synchronization/waitable_event_unittest.cc
index ad86d14..f253265 100644
--- a/base/synchronization/waitable_event_unittest.cc
+++ b/base/synchronization/waitable_event_unittest.cc
@@ -77,7 +77,7 @@ class WaitableEventSignaler : public PlatformThread::Delegate {
}
void ThreadMain() {
- PlatformThread::Sleep(static_cast<int>(seconds_ * 1000));
+ PlatformThread::Sleep(TimeDelta::FromSeconds(static_cast<int>(seconds_)));
ev_->Signal();
}
diff --git a/base/synchronization/waitable_event_watcher_unittest.cc b/base/synchronization/waitable_event_watcher_unittest.cc
index 1715dff..ee9478a 100644
--- a/base/synchronization/waitable_event_watcher_unittest.cc
+++ b/base/synchronization/waitable_event_watcher_unittest.cc
@@ -80,7 +80,7 @@ void RunTest_CancelAfterSet(MessageLoop::Type message_loop_type) {
event.Signal();
// Let the background thread do its business
- base::PlatformThread::Sleep(30);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(30));
watcher.StopWatching();
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...
diff --git a/base/time_unittest.cc b/base/time_unittest.cc
index 6ba03b8..261b831 100644
--- a/base/time_unittest.cc
+++ b/base/time_unittest.cc
@@ -311,7 +311,7 @@ TEST_F(TimeTest, ParseTimeTestInvalidString) {
TEST(TimeTicks, Deltas) {
for (int index = 0; index < 50; index++) {
TimeTicks ticks_start = TimeTicks::Now();
- base::PlatformThread::Sleep(10);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10));
TimeTicks ticks_stop = TimeTicks::Now();
TimeDelta delta = ticks_stop - ticks_start;
// Note: Although we asked for a 10ms sleep, if the
diff --git a/base/time_win_unittest.cc b/base/time_win_unittest.cc
index 3a96b91..e3ba09a 100644
--- a/base/time_win_unittest.cc
+++ b/base/time_win_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.
@@ -220,7 +220,8 @@ TEST(TimeTicks, Drift) {
// Sleep for a few milliseconds (note that it means 1000 microseconds).
// If we check the drift too frequently, it's going to increase
// monotonically, making our measurement less realistic.
- base::PlatformThread::Sleep((i % 2 == 0) ? 1 : 2);
+ base::PlatformThread::Sleep(
+ base::TimeDelta::FromMilliseconds((i % 2 == 0) ? 1 : 2));
total_drift += drift_microseconds;
}
diff --git a/base/timer_unittest.cc b/base/timer_unittest.cc
index 0013bcc..a31f7ba 100644
--- a/base/timer_unittest.cc
+++ b/base/timer_unittest.cc
@@ -267,7 +267,7 @@ void RunTest_DelayTimer_Deleted(MessageLoop::Type message_loop_type) {
// When the timer is deleted, the DelayTimerFatalTarget should never be
// called.
- base::PlatformThread::Sleep(100);
+ base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100));
}
} // namespace
diff --git a/base/tools_sanity_unittest.cc b/base/tools_sanity_unittest.cc
index 547fc98c..60ac015 100644
--- a/base/tools_sanity_unittest.cc
+++ b/base/tools_sanity_unittest.cc
@@ -170,7 +170,7 @@ class TOOLS_SANITY_TEST_CONCURRENT_THREAD : public PlatformThread::Delegate {
// Sleep for a few milliseconds so the two threads are more likely to live
// simultaneously. Otherwise we may miss the report due to mutex
// lock/unlock's inside thread creation code in pure-happens-before mode...
- PlatformThread::Sleep(100);
+ PlatformThread::Sleep(TimeDelta::FromMilliseconds(100));
}
private:
bool *value_;
@@ -186,7 +186,7 @@ class ReleaseStoreThread : public PlatformThread::Delegate {
// Sleep for a few milliseconds so the two threads are more likely to live
// simultaneously. Otherwise we may miss the report due to mutex
// lock/unlock's inside thread creation code in pure-happens-before mode...
- PlatformThread::Sleep(100);
+ PlatformThread::Sleep(TimeDelta::FromMilliseconds(100));
}
private:
base::subtle::Atomic32 *value_;
@@ -198,7 +198,7 @@ class AcquireLoadThread : public PlatformThread::Delegate {
~AcquireLoadThread() {}
void ThreadMain() {
// Wait for the other thread to make Release_Store
- PlatformThread::Sleep(100);
+ PlatformThread::Sleep(TimeDelta::FromMilliseconds(100));
base::subtle::Acquire_Load(value_);
}
private: