Chromium Code Reviews| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 const base::Closure& user_task() const { return user_task_; } | 104 const base::Closure& user_task() const { return user_task_; } |
| 105 const TimeTicks& desired_run_time() const { return desired_run_time_; } | 105 const TimeTicks& desired_run_time() const { return desired_run_time_; } |
| 106 | 106 |
| 107 protected: | 107 protected: |
| 108 // Used to initiate a new delayed task. This has the side-effect of disabling | 108 // Used to initiate a new delayed task. This has the side-effect of disabling |
| 109 // scheduled_task_ if it is non-null. | 109 // scheduled_task_ if it is non-null. |
| 110 void SetTaskInfo(const tracked_objects::Location& posted_from, | 110 void SetTaskInfo(const tracked_objects::Location& posted_from, |
| 111 TimeDelta delay, | 111 TimeDelta delay, |
| 112 const base::Closure& user_task); | 112 const base::Closure& user_task); |
| 113 | 113 |
| 114 void set_user_task(const Closure& task) { user_task_ = task; } | |
| 115 void set_desired_run_time(TimeTicks desired) { desired_run_time_ = desired; } | |
| 116 void set_is_running(bool running) { is_running_ = running; } | |
| 117 | |
| 118 const tracked_objects::Location& posted_from() { return posted_from_; } | |
|
Lei Zhang
2014/10/24 00:44:49
this can be a const method, same for is_running().
Chirantan Ekbote
2014/10/24 01:04:13
Done.
| |
| 119 | |
| 114 bool retain_user_task() const { return retain_user_task_; } | 120 bool retain_user_task() const { return retain_user_task_; } |
| 115 bool is_repeating() const { return is_repeating_; } | 121 bool is_repeating() const { return is_repeating_; } |
| 116 | 122 |
| 123 bool is_running() { return is_running_; } | |
|
Lei Zhang
2014/10/24 00:44:49
nit: group with the other getters, and put blank l
Chirantan Ekbote
2014/10/24 01:04:13
Done.
| |
| 117 private: | 124 private: |
| 118 friend class BaseTimerTaskInternal; | 125 friend class BaseTimerTaskInternal; |
| 119 | 126 |
| 120 // Allocates a new scheduled_task_ and posts it on the current MessageLoop | 127 // Allocates a new scheduled_task_ and posts it on the current MessageLoop |
| 121 // with the given |delay|. scheduled_task_ must be NULL. scheduled_run_time_ | 128 // with the given |delay|. scheduled_task_ must be NULL. scheduled_run_time_ |
| 122 // and desired_run_time_ are reset to Now() + delay. | 129 // and desired_run_time_ are reset to Now() + delay. |
| 123 void PostNewScheduledTask(TimeDelta delay); | 130 void PostNewScheduledTask(TimeDelta delay); |
| 124 | 131 |
| 125 // Disable scheduled_task_ and abandon it so that it no longer refers back to | 132 // Disable scheduled_task_ and abandon it so that it no longer refers back to |
| 126 // this object. | 133 // this object. |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 : Timer(posted_from, delay, | 245 : Timer(posted_from, delay, |
| 239 base::Bind(method, base::Unretained(receiver)), | 246 base::Bind(method, base::Unretained(receiver)), |
| 240 false) {} | 247 false) {} |
| 241 | 248 |
| 242 void Reset() { Timer::Reset(); } | 249 void Reset() { Timer::Reset(); } |
| 243 }; | 250 }; |
| 244 | 251 |
| 245 } // namespace base | 252 } // namespace base |
| 246 | 253 |
| 247 #endif // BASE_TIMER_TIMER_H_ | 254 #endif // BASE_TIMER_TIMER_H_ |
| OLD | NEW |