diff options
author | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-03 18:18:14 +0000 |
---|---|---|
committer | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-03 18:18:14 +0000 |
commit | 2d31666a58e746b7a1d415c99e5f68ad9256d236 (patch) | |
tree | 144c99d4b80df0f0f9a3ded83f9d21a8b36f17cc /net/disk_cache/disk_cache_test_util.h | |
parent | 90d6958fe2374a00d3c8583cf4d3b8a509ae8e90 (diff) | |
download | chromium_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.h')
-rw-r--r-- | net/disk_cache/disk_cache_test_util.h | 50 |
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_ |