summaryrefslogtreecommitdiffstats
path: root/net/disk_cache/disk_cache_test_util.cc
diff options
context:
space:
mode:
authordarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-03 18:18:14 +0000
committerdarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-03 18:18:14 +0000
commit2d31666a58e746b7a1d415c99e5f68ad9256d236 (patch)
tree144c99d4b80df0f0f9a3ded83f9d21a8b36f17cc /net/disk_cache/disk_cache_test_util.cc
parent90d6958fe2374a00d3c8583cf4d3b8a509ae8e90 (diff)
downloadchromium_src-2d31666a58e746b7a1d415c99e5f68ad9256d236.zip
chromium_src-2d31666a58e746b7a1d415c99e5f68ad9256d236.tar.gz
chromium_src-2d31666a58e746b7a1d415c99e5f68ad9256d236.tar.bz2
Minor cleanup to OneShotTimer and RepeatingTimer: moves more of the member variables into the Task subclass.
Also included in this change: deprecate MessageLoop::timer_manager(), and change consumers over to use OneShotTimer or RepeatingTimer. R=beng BUG=1346553 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1684 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/disk_cache_test_util.cc')
-rw-r--r--net/disk_cache/disk_cache_test_util.cc45
1 files changed, 20 insertions, 25 deletions
diff --git a/net/disk_cache/disk_cache_test_util.cc b/net/disk_cache/disk_cache_test_util.cc
index 98bd092..d82cbb4 100644
--- a/net/disk_cache/disk_cache_test_util.cc
+++ b/net/disk_cache/disk_cache_test_util.cc
@@ -96,9 +96,28 @@ void CallbackTest::RunWithParams(const Tuple1<int>& params) {
// -----------------------------------------------------------------------
+MessageLoopHelper::MessageLoopHelper()
+ : num_callbacks_(0),
+ num_iterations_(0),
+ last_(0),
+ completed_(false) {
+ // Create a recurrent timer of 50 mS.
+ timer_.Start(
+ TimeDelta::FromMilliseconds(50), this, &MessageLoopHelper::TimerExpired);
+}
+
+bool MessageLoopHelper::WaitUntilCacheIoFinished(int num_callbacks) {
+ if (num_callbacks == g_cache_tests_received)
+ return true;
+
+ ExpectCallbacks(num_callbacks);
+ MessageLoop::current()->Run();
+ return completed_;
+}
+
// Quits the message loop when all callbacks are called or we've been waiting
// too long for them (2 secs without a callback).
-void TimerTask::Run() {
+void MessageLoopHelper::TimerExpired() {
if (g_cache_tests_received > num_callbacks_) {
NOTREACHED();
} else if (g_cache_tests_received == num_callbacks_) {
@@ -114,27 +133,3 @@ void TimerTask::Run() {
MessageLoop::current()->Quit();
}
}
-
-// -----------------------------------------------------------------------
-
-MessageLoopHelper::MessageLoopHelper() {
- message_loop_ = MessageLoop::current();
- // Create a recurrent timer of 50 mS.
- timer_ = message_loop_->timer_manager()->StartTimer(50, &timer_task_, true);
-}
-
-MessageLoopHelper::~MessageLoopHelper() {
- message_loop_->timer_manager()->StopTimer(timer_);
- delete timer_;
-}
-
-bool MessageLoopHelper::WaitUntilCacheIoFinished(int num_callbacks) {
- if (num_callbacks == g_cache_tests_received)
- return true;
-
- timer_task_.ExpectCallbacks(num_callbacks);
- message_loop_->Run();
- return timer_task_.GetSate();
-}
-
-