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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 bool is_running() const { return is_running_; } | 147 bool is_running() const { return is_running_; } |
148 | 148 |
149 private: | 149 private: |
150 friend class BaseTimerTaskInternal; | 150 friend class BaseTimerTaskInternal; |
151 | 151 |
152 // Allocates a new |scheduled_task_| and posts it on the current sequence with | 152 // Allocates a new |scheduled_task_| and posts it on the current sequence with |
153 // the given |delay|. |scheduled_task_| must be null. |scheduled_run_time_| | 153 // the given |delay|. |scheduled_task_| must be null. |scheduled_run_time_| |
154 // and |desired_run_time_| are reset to Now() + delay. | 154 // and |desired_run_time_| are reset to Now() + delay. |
155 void PostNewScheduledTask(TimeDelta delay); | 155 void PostNewScheduledTask(TimeDelta delay); |
156 | 156 |
157 // Returns the task runner on which the task should be scheduled. If the | |
158 // corresponding |task_runner_| field is null, the task runner for the current | |
159 // sequence is returned. | |
160 scoped_refptr<SequencedTaskRunner> GetTaskRunner(); | |
161 | |
162 // Disable |scheduled_task_| and abandon it so that it no longer refers back | 157 // Disable |scheduled_task_| and abandon it so that it no longer refers back |
163 // to this object. | 158 // to this object. |
164 void AbandonScheduledTask(); | 159 void AbandonScheduledTask(); |
165 | 160 |
166 // Called by BaseTimerTaskInternal when the delayed task fires. | 161 // Called by BaseTimerTaskInternal when the delayed task fires. |
167 void RunScheduledTask(); | 162 void RunScheduledTask(); |
168 | 163 |
169 // Stop running task (if any) and abandon scheduled task (if any). | 164 // Stop running task (if any) and abandon scheduled task (if any). |
170 void AbandonAndStop() { | 165 void AbandonAndStop() { |
171 AbandonScheduledTask(); | 166 AbandonScheduledTask(); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 // to link in MSVC. But clang-plugin does not allow inline definitions of | 303 // to link in MSVC. But clang-plugin does not allow inline definitions of |
309 // virtual methods, so the inline definition lives in the header file here | 304 // virtual methods, so the inline definition lives in the header file here |
310 // to satisfy both. | 305 // to satisfy both. |
311 inline void DelayTimer::Reset() { | 306 inline void DelayTimer::Reset() { |
312 Timer::Reset(); | 307 Timer::Reset(); |
313 } | 308 } |
314 | 309 |
315 } // namespace base | 310 } // namespace base |
316 | 311 |
317 #endif // BASE_TIMER_TIMER_H_ | 312 #endif // BASE_TIMER_TIMER_H_ |
OLD | NEW |