summaryrefslogtreecommitdiffstats
path: root/net/disk_cache/disk_cache_test_util.h
diff options
context:
space:
mode:
Diffstat (limited to 'net/disk_cache/disk_cache_test_util.h')
-rw-r--r--net/disk_cache/disk_cache_test_util.h50
1 files changed, 15 insertions, 35 deletions
diff --git a/net/disk_cache/disk_cache_test_util.h b/net/disk_cache/disk_cache_test_util.h
index 3b5c9ef8..4277d02 100644
--- a/net/disk_cache/disk_cache_test_util.h
+++ b/net/disk_cache/disk_cache_test_util.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef NET_DISK_CACHE_DISK_CACHE_TEST_UTIL_H__
-#define NET_DISK_CACHE_DISK_CACHE_TEST_UTIL_H__
+#ifndef NET_DISK_CACHE_DISK_CACHE_TEST_UTIL_H_
+#define NET_DISK_CACHE_DISK_CACHE_TEST_UTIL_H_
#include <string>
@@ -46,20 +46,21 @@ class CallbackTest : public CallbackRunner< Tuple1<int> > {
private:
int id_;
int reuse_;
- DISALLOW_EVIL_CONSTRUCTORS(CallbackTest);
+ DISALLOW_COPY_AND_ASSIGN(CallbackTest);
};
// -----------------------------------------------------------------------
-// We'll use a timer to fire from time to time to check the number of IO
-// operations finished so far.
-class TimerTask : public Task {
+// Simple helper to deal with the message loop on a test.
+class MessageLoopHelper {
public:
- TimerTask() : num_callbacks_(0), num_iterations_(0) {}
- ~TimerTask() {}
+ MessageLoopHelper();
- virtual void Run();
+ // Run the message loop and wait for num_callbacks before returning. Returns
+ // false if we are waiting to long.
+ bool WaitUntilCacheIoFinished(int num_callbacks);
+ private:
// Sets the number of callbacks that can be received so far.
void ExpectCallbacks(int num_callbacks) {
num_callbacks_ = num_callbacks;
@@ -67,37 +68,16 @@ class TimerTask : public Task {
completed_ = false;
}
- // Returns true if all callbacks were invoked.
- bool GetSate() {
- return completed_;
- }
+ // Called periodically to test if WaitUntilCacheIoFinished should return.
+ void TimerExpired();
- private:
+ base::RepeatingTimer<MessageLoopHelper> timer_;
int num_callbacks_;
int num_iterations_;
int last_;
bool completed_;
- DISALLOW_EVIL_CONSTRUCTORS(TimerTask);
-};
-
-// -----------------------------------------------------------------------
-// Simple helper to deal with the message loop on a test.
-class MessageLoopHelper {
- public:
- MessageLoopHelper();
- ~MessageLoopHelper();
-
- // Run the message loop and wait for num_callbacks before returning. Returns
- // false if we are waiting to long.
- bool WaitUntilCacheIoFinished(int num_callbacks);
-
- private:
- MessageLoop* message_loop_;
- Timer* timer_;
- TimerTask timer_task_;
- DISALLOW_EVIL_CONSTRUCTORS(MessageLoopHelper);
+ DISALLOW_COPY_AND_ASSIGN(MessageLoopHelper);
};
-#endif // NET_DISK_CACHE_DISK_CACHE_TEST_UTIL_H__
-
+#endif // NET_DISK_CACHE_DISK_CACHE_TEST_UTIL_H_