| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // OneShotTimer and RepeatingTimer provide a simple timer API. As the names | 5 // OneShotTimer and RepeatingTimer provide a simple timer API. As the names |
| 6 // suggest, OneShotTimer calls you back once after a time delay expires. | 6 // suggest, OneShotTimer calls you back once after a time delay expires. |
| 7 // RepeatingTimer on the other hand calls you back periodically with the | 7 // RepeatingTimer on the other hand calls you back periodically with the |
| 8 // prescribed time interval. | 8 // prescribed time interval. |
| 9 // | 9 // |
| 10 // OneShotTimer and RepeatingTimer both cancel the timer when they go out of | 10 // OneShotTimer and RepeatingTimer both cancel the timer when they go out of |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 DCHECK(IsRunning()); | 78 DCHECK(IsRunning()); |
| 79 return delayed_task_->delay_; | 79 return delayed_task_->delay_; |
| 80 } | 80 } |
| 81 | 81 |
| 82 protected: | 82 protected: |
| 83 BaseTimer_Helper() : delayed_task_(NULL) {} | 83 BaseTimer_Helper() : delayed_task_(NULL) {} |
| 84 | 84 |
| 85 // We have access to the timer_ member so we can orphan this task. | 85 // We have access to the timer_ member so we can orphan this task. |
| 86 class TimerTask : public Task { | 86 class TimerTask : public Task { |
| 87 public: | 87 public: |
| 88 explicit TimerTask(TimeDelta delay) : timer_(NULL), delay_(delay) { | 88 TimerTask(TimeDelta delay) : timer_(NULL), delay_(delay) { |
| 89 } | 89 } |
| 90 virtual ~TimerTask() {} | 90 virtual ~TimerTask() {} |
| 91 BaseTimer_Helper* timer_; | 91 BaseTimer_Helper* timer_; |
| 92 TimeDelta delay_; | 92 TimeDelta delay_; |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 // Used to orphan delayed_task_ so that when it runs it does nothing. | 95 // Used to orphan delayed_task_ so that when it runs it does nothing. |
| 96 void OrphanDelayedTask(); | 96 void OrphanDelayedTask(); |
| 97 | 97 |
| 98 // Used to initiated a new delayed task. This has the side-effect of | 98 // Used to initiated a new delayed task. This has the side-effect of |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 const ReceiverMethod method_; | 261 const ReceiverMethod method_; |
| 262 const TimeDelta delay_; | 262 const TimeDelta delay_; |
| 263 | 263 |
| 264 OneShotTimer<DelayTimer<Receiver> > timer_; | 264 OneShotTimer<DelayTimer<Receiver> > timer_; |
| 265 Time trigger_time_; | 265 Time trigger_time_; |
| 266 }; | 266 }; |
| 267 | 267 |
| 268 } // namespace base | 268 } // namespace base |
| 269 | 269 |
| 270 #endif // BASE_TIMER_H_ | 270 #endif // BASE_TIMER_H_ |
| OLD | NEW |