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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 TimeDelta delay, | 116 TimeDelta delay, |
117 const base::Closure& user_task); | 117 const base::Closure& user_task); |
118 | 118 |
119 void set_user_task(const Closure& task) { user_task_ = task; } | 119 void set_user_task(const Closure& task) { user_task_ = task; } |
120 void set_desired_run_time(TimeTicks desired) { desired_run_time_ = desired; } | 120 void set_desired_run_time(TimeTicks desired) { desired_run_time_ = desired; } |
121 void set_is_running(bool running) { is_running_ = running; } | 121 void set_is_running(bool running) { is_running_ = running; } |
122 | 122 |
123 const tracked_objects::Location& posted_from() const { return posted_from_; } | 123 const tracked_objects::Location& posted_from() const { return posted_from_; } |
124 bool retain_user_task() const { return retain_user_task_; } | 124 bool retain_user_task() const { return retain_user_task_; } |
125 bool is_repeating() const { return is_repeating_; } | 125 bool is_repeating() const { return is_repeating_; } |
126 bool is_running() const { return is_running_; } | |
127 | 126 |
128 private: | 127 private: |
129 friend class BaseTimerTaskInternal; | 128 friend class BaseTimerTaskInternal; |
130 | 129 |
131 // Allocates a new scheduled_task_ and posts it on the current MessageLoop | 130 // Allocates a new scheduled_task_ and posts it on the current MessageLoop |
132 // with the given |delay|. scheduled_task_ must be NULL. scheduled_run_time_ | 131 // with the given |delay|. scheduled_task_ must be NULL. scheduled_run_time_ |
133 // and desired_run_time_ are reset to Now() + delay. | 132 // and desired_run_time_ are reset to Now() + delay. |
134 void PostNewScheduledTask(TimeDelta delay); | 133 void PostNewScheduledTask(TimeDelta delay); |
135 | 134 |
136 // Returns the task runner on which the task should be scheduled. If the | 135 // Returns the task runner on which the task should be scheduled. If the |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 : Timer(posted_from, delay, | 257 : Timer(posted_from, delay, |
259 base::Bind(method, base::Unretained(receiver)), | 258 base::Bind(method, base::Unretained(receiver)), |
260 false) {} | 259 false) {} |
261 | 260 |
262 void Reset() { Timer::Reset(); } | 261 void Reset() { Timer::Reset(); } |
263 }; | 262 }; |
264 | 263 |
265 } // namespace base | 264 } // namespace base |
266 | 265 |
267 #endif // BASE_TIMER_TIMER_H_ | 266 #endif // BASE_TIMER_TIMER_H_ |
OLD | NEW |