diff options
author | nsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-02 15:34:06 +0000 |
---|---|---|
committer | nsylvain@chromium.org <nsylvain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-02 15:34:06 +0000 |
commit | 6e022a5f0a75f716c23db51c7a2e60cb6969ad37 (patch) | |
tree | cfc8c3d9fe944a8528887e482d7c81ec1982f3bf /base/timer.h | |
parent | a1a2e8ea06bdd7220d57fa7d193787374c0f296e (diff) | |
download | chromium_src-6e022a5f0a75f716c23db51c7a2e60cb6969ad37.zip chromium_src-6e022a5f0a75f716c23db51c7a2e60cb6969ad37.tar.gz chromium_src-6e022a5f0a75f716c23db51c7a2e60cb6969ad37.tar.bz2 |
Reland 6190 now that the tree is green to see if
it's still breaking the tests
Review URL: http://codereview.chromium.org/12868
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6218 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/timer.h')
-rw-r--r-- | base/timer.h | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/base/timer.h b/base/timer.h index 5361130..f449d2a 100644 --- a/base/timer.h +++ b/base/timer.h @@ -135,21 +135,42 @@ class BaseTimer : public BaseTimer_Helper { receiver_(receiver), method_(method) { } + + virtual ~TimerTask() { + ClearBaseTimer(); + } + virtual void Run() { if (!timer_) // timer_ is null if we were orphaned. return; - SelfType* self = static_cast<SelfType*>(timer_); - if (kIsRepeating) { - self->Reset(); - } else { - self->delayed_task_ = NULL; - } + if (kIsRepeating) + ResetBaseTimer(); + else + ClearBaseTimer(); DispatchToMethod(receiver_, method_, Tuple0()); } + TimerTask* Clone() const { return new TimerTask(delay_, receiver_, method_); } + private: + // Inform the Base that the timer is no longer active. + void ClearBaseTimer() { + if (timer_) { + SelfType* self = static_cast<SelfType*>(timer_); + self->delayed_task_ = NULL; + } + } + + // Inform the Base that we're resetting the timer. + void ResetBaseTimer() { + DCHECK(timer_); + DCHECK(kIsRepeating); + SelfType* self = static_cast<SelfType*>(timer_); + self->Reset(); + } + Receiver* receiver_; ReceiverMethod method_; }; |