OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 101 |
102 // Call this method to stop and cancel the timer. It is a no-op if the timer | 102 // Call this method to stop and cancel the timer. It is a no-op if the timer |
103 // is not running. | 103 // is not running. |
104 void Stop(); | 104 void Stop(); |
105 | 105 |
106 // Call this method to reset the timer delay. The user_task_ must be set. If | 106 // Call this method to reset the timer delay. The user_task_ must be set. If |
107 // the timer is not running, this will start it by posting a task. | 107 // the timer is not running, this will start it by posting a task. |
108 void Reset(); | 108 void Reset(); |
109 | 109 |
110 const base::Closure& user_task() const { return user_task_; } | 110 const base::Closure& user_task() const { return user_task_; } |
| 111 const TimeTicks& desired_run_time() const { return desired_run_time_; } |
111 | 112 |
112 protected: | 113 protected: |
113 // Used to initiate a new delayed task. This has the side-effect of disabling | 114 // Used to initiate a new delayed task. This has the side-effect of disabling |
114 // scheduled_task_ if it is non-null. | 115 // scheduled_task_ if it is non-null. |
115 void SetTaskInfo(const tracked_objects::Location& posted_from, | 116 void SetTaskInfo(const tracked_objects::Location& posted_from, |
116 TimeDelta delay, | 117 TimeDelta delay, |
117 const base::Closure& user_task); | 118 const base::Closure& user_task); |
118 | 119 |
119 private: | 120 private: |
120 friend class BaseTimerTaskInternal; | 121 friend class BaseTimerTaskInternal; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 : Timer(posted_from, delay, | 232 : Timer(posted_from, delay, |
232 base::Bind(method, base::Unretained(receiver)), | 233 base::Bind(method, base::Unretained(receiver)), |
233 false) {} | 234 false) {} |
234 | 235 |
235 void Reset() { Timer::Reset(); } | 236 void Reset() { Timer::Reset(); } |
236 }; | 237 }; |
237 | 238 |
238 } // namespace base | 239 } // namespace base |
239 | 240 |
240 #endif // BASE_TIMER_H_ | 241 #endif // BASE_TIMER_H_ |
OLD | NEW |