| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 156 |
| 157 // Disable scheduled_task_ and abandon it so that it no longer refers back to | 157 // Disable scheduled_task_ and abandon it so that it no longer refers back to |
| 158 // this object. | 158 // this object. |
| 159 void AbandonScheduledTask(); | 159 void AbandonScheduledTask(); |
| 160 | 160 |
| 161 // Called by BaseTimerTaskInternal when the MessageLoop runs it. | 161 // Called by BaseTimerTaskInternal when the MessageLoop runs it. |
| 162 void RunScheduledTask(); | 162 void RunScheduledTask(); |
| 163 | 163 |
| 164 // Stop running task (if any) and abandon scheduled task (if any). | 164 // Stop running task (if any) and abandon scheduled task (if any). |
| 165 void StopAndAbandon() { | 165 void StopAndAbandon() { |
| 166 AbandonScheduledTask(); |
| 167 |
| 166 Stop(); | 168 Stop(); |
| 167 AbandonScheduledTask(); | 169 // No more member accesses here: |this| could be deleted at this point. |
| 168 } | 170 } |
| 169 | 171 |
| 170 // When non-NULL, the scheduled_task_ is waiting in the MessageLoop to call | 172 // When non-NULL, the scheduled_task_ is waiting in the MessageLoop to call |
| 171 // RunScheduledTask() at scheduled_run_time_. | 173 // RunScheduledTask() at scheduled_run_time_. |
| 172 BaseTimerTaskInternal* scheduled_task_; | 174 BaseTimerTaskInternal* scheduled_task_; |
| 173 | 175 |
| 174 // The task runner on which the task should be scheduled. If it is null, the | 176 // The task runner on which the task should be scheduled. If it is null, the |
| 175 // task runner for the current thread should be used. | 177 // task runner for the current thread should be used. |
| 176 scoped_refptr<SingleThreadTaskRunner> task_runner_; | 178 scoped_refptr<SingleThreadTaskRunner> task_runner_; |
| 177 | 179 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 // 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 |
| 302 // 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 |
| 303 // to satisfy both. | 305 // to satisfy both. |
| 304 inline void DelayTimer::Reset() { | 306 inline void DelayTimer::Reset() { |
| 305 Timer::Reset(); | 307 Timer::Reset(); |
| 306 } | 308 } |
| 307 | 309 |
| 308 } // namespace base | 310 } // namespace base |
| 309 | 311 |
| 310 #endif // BASE_TIMER_TIMER_H_ | 312 #endif // BASE_TIMER_TIMER_H_ |
| OLD | NEW |