diff options
author | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-28 20:50:12 +0000 |
---|---|---|
committer | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-28 20:50:12 +0000 |
commit | aeab57ea8560065d6c513fcd46bb43e1bfbfd7a6 (patch) | |
tree | a63f2d36e86361d5c27122a6d6ef4098b755d7d9 /base/idletimer_unittest.cc | |
parent | e115558691eb08608fad56bb32f40265fdfa4ac5 (diff) | |
download | chromium_src-aeab57ea8560065d6c513fcd46bb43e1bfbfd7a6.zip chromium_src-aeab57ea8560065d6c513fcd46bb43e1bfbfd7a6.tar.gz chromium_src-aeab57ea8560065d6c513fcd46bb43e1bfbfd7a6.tar.bz2 |
Simplify OneShotTimer and RepeatingTimer. Fix up all consumers.
Major changes:
OneShotTimer and RepeatingTimer become template classes that no longer require
a Task or a Timer object. They just use PostDelayedTask. Under the hood that
still uses a Timer object.
The API is much simpler for consumers as they now no longer need to worry about
allocating a Task or managing the lifetime of the object pointer held by the
Task.
I added some new unit tests to timer_unittest.cc to cover the API.
I preserved the old TimerManager / Timer API for now, but I plan to soon kill
it.
R=brettw
BUG=1346553
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1502 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/idletimer_unittest.cc')
-rw-r--r-- | base/idletimer_unittest.cc | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/base/idletimer_unittest.cc b/base/idletimer_unittest.cc index ea53854..1e2baa9 100644 --- a/base/idletimer_unittest.cc +++ b/base/idletimer_unittest.cc @@ -6,12 +6,14 @@ #include "base/message_loop.h" #include "testing/gtest/include/gtest/gtest.h" +using base::IdleTimer; + namespace { - class IdleTimerTest : public testing::Test { - private: - // IdleTimer requires a UI message loop on the current thread. - MessageLoopForUI message_loop_; - }; + +class IdleTimerTest : public testing::Test { + private: + // IdleTimer requires a UI message loop on the current thread. + MessageLoopForUI message_loop_; }; // We Mock the GetLastInputInfo function to return @@ -25,12 +27,12 @@ BOOL __stdcall MockGetLastInputInfoFunction(PLASTINPUTINFO plii) { } // TestIdle task fires after 100ms of idle time. -class TestIdleTask : public IdleTimerTask { +class TestIdleTask : public IdleTimer { public: TestIdleTask(bool repeat) - : IdleTimerTask(TimeDelta::FromMilliseconds(100), repeat), - idle_counter_(0) { - set_last_input_info_fn(MockGetLastInputInfoFunction); + : IdleTimer(TimeDelta::FromMilliseconds(100), repeat), + idle_counter_(0) { + set_last_input_info_fn(MockGetLastInputInfoFunction); } int get_idle_counter() { return idle_counter_; } @@ -61,6 +63,8 @@ class ResetIdleTask : public Task { } }; +} // namespace + /////////////////////////////////////////////////////////////////////////////// // NoRepeat tests: // A non-repeating idle timer will fire once on idle, and |