diff options
Diffstat (limited to 'base/timer.h')
-rw-r--r-- | base/timer.h | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/base/timer.h b/base/timer.h index 2e21582..30cb109 100644 --- a/base/timer.h +++ b/base/timer.h @@ -87,9 +87,14 @@ class BASE_EXPORT BaseTimer_Helper { // We have access to the timer_ member so we can orphan this task. class TimerTask : public Task { public: - explicit TimerTask(TimeDelta delay) : timer_(NULL), delay_(delay) { + TimerTask(const tracked_objects::Location& posted_from, + TimeDelta delay) + : posted_from_(posted_from), + timer_(NULL), + delay_(delay) { } virtual ~TimerTask() {} + tracked_objects::Location posted_from_; BaseTimer_Helper* timer_; TimeDelta delay_; }; @@ -116,9 +121,12 @@ class BaseTimer : public BaseTimer_Helper { // Call this method to start the timer. It is an error to call this method // while the timer is already running. - void Start(TimeDelta delay, Receiver* receiver, ReceiverMethod method) { + void Start(const tracked_objects::Location& posted_from, + TimeDelta delay, + Receiver* receiver, + ReceiverMethod method) { DCHECK(!IsRunning()); - InitiateDelayedTask(new TimerTask(delay, receiver, method)); + InitiateDelayedTask(new TimerTask(posted_from, delay, receiver, method)); } // Call this method to stop the timer. It is a no-op if the timer is not @@ -138,8 +146,11 @@ class BaseTimer : public BaseTimer_Helper { class TimerTask : public BaseTimer_Helper::TimerTask { public: - TimerTask(TimeDelta delay, Receiver* receiver, ReceiverMethod method) - : BaseTimer_Helper::TimerTask(delay), + TimerTask(const tracked_objects::Location& posted_from, + TimeDelta delay, + Receiver* receiver, + ReceiverMethod method) + : BaseTimer_Helper::TimerTask(posted_from, delay), receiver_(receiver), method_(method) { } @@ -162,7 +173,7 @@ class BaseTimer : public BaseTimer_Helper { } TimerTask* Clone() const { - return new TimerTask(delay_, receiver_, method_); + return new TimerTask(posted_from_, delay_, receiver_, method_); } private: @@ -221,8 +232,12 @@ class DelayTimer { public: typedef void (Receiver::*ReceiverMethod)(); - DelayTimer(TimeDelta delay, Receiver* receiver, ReceiverMethod method) - : receiver_(receiver), + DelayTimer(const tracked_objects::Location& posted_from, + TimeDelta delay, + Receiver* receiver, + ReceiverMethod method) + : posted_from_(posted_from), + receiver_(receiver), method_(method), delay_(delay) { } @@ -242,7 +257,7 @@ class DelayTimer { // The timer isn't running, or will expire too late, so restart it. timer_.Stop(); - timer_.Start(delay, this, &DelayTimer<Receiver>::Check); + timer_.Start(posted_from_, delay, this, &DelayTimer<Receiver>::Check); } void Check() { @@ -259,6 +274,7 @@ class DelayTimer { (receiver_->*method_)(); } + tracked_objects::Location posted_from_; Receiver *const receiver_; const ReceiverMethod method_; const TimeDelta delay_; |