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 /chrome/views/repeat_controller.cc | |
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 'chrome/views/repeat_controller.cc')
-rw-r--r-- | chrome/views/repeat_controller.cc | 34 |
1 files changed, 9 insertions, 25 deletions
diff --git a/chrome/views/repeat_controller.cc b/chrome/views/repeat_controller.cc index cf41dea..96aa923 100644 --- a/chrome/views/repeat_controller.cc +++ b/chrome/views/repeat_controller.cc @@ -15,45 +15,29 @@ static const int kRepeatDelay = 50; // RepeatController, public: RepeatController::RepeatController(RepeatCallback* callback) - : timer_(NULL), - callback_(callback) { + : callback_(callback) { } RepeatController::~RepeatController() { - DestroyTimer(); } void RepeatController::Start() { - DCHECK(!timer_); // The first timer is slightly longer than subsequent repeats. - timer_ = MessageLoop::current()->timer_manager()->StartTimer( - kInitialRepeatDelay, this, false); + timer_.Start(TimeDelta::FromMilliseconds(kInitialRepeatDelay), this, + &RepeatController::Run); } void RepeatController::Stop() { - DestroyTimer(); -} - -void RepeatController::Run() { - DestroyTimer(); - - // TODO(beng): (Cleanup) change this to just Run() when base rolls forward. - callback_->RunWithParams(Tuple0()); - timer_ = MessageLoop::current()->timer_manager()->StartTimer( - kRepeatDelay, this, true); + timer_.Stop(); } /////////////////////////////////////////////////////////////////////////////// // RepeatController, private: -void RepeatController::DestroyTimer() { - if (!timer_) - return; - - MessageLoop::current()->timer_manager()->StopTimer(timer_); - delete timer_; - timer_ = NULL; -} - +void RepeatController::Run() { + timer_.Start(TimeDelta::FromMilliseconds(kRepeatDelay), this, + &RepeatController::Run); + callback_->Run(); } +} // namespace ChromeViews |