| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 TickClock* tick_clock); | 93 TickClock* tick_clock); |
| 94 | 94 |
| 95 virtual ~Timer(); | 95 virtual ~Timer(); |
| 96 | 96 |
| 97 // Returns true if the timer is running (i.e., not stopped). | 97 // Returns true if the timer is running (i.e., not stopped). |
| 98 virtual bool IsRunning() const; | 98 virtual bool IsRunning() const; |
| 99 | 99 |
| 100 // Returns the current delay for this timer. | 100 // Returns the current delay for this timer. |
| 101 virtual TimeDelta GetCurrentDelay() const; | 101 virtual TimeDelta GetCurrentDelay() const; |
| 102 | 102 |
| 103 // Returns an estimated time to the timer calling the user_task_ back. | |
| 104 // Note that the time may be negative if the timer has not been started, | |
| 105 // is late to call back or has done its last call back. | |
| 106 virtual TimeDelta GetTimeToCallback() const; | |
| 107 | |
| 108 // Set the task runner on which the task should be scheduled. This method can | 103 // Set the task runner on which the task should be scheduled. This method can |
| 109 // only be called before any tasks have been scheduled. The task runner must | 104 // only be called before any tasks have been scheduled. The task runner must |
| 110 // run tasks on the same thread the timer is used on. | 105 // run tasks on the same thread the timer is used on. |
| 111 virtual void SetTaskRunner(scoped_refptr<SingleThreadTaskRunner> task_runner); | 106 virtual void SetTaskRunner(scoped_refptr<SingleThreadTaskRunner> task_runner); |
| 112 | 107 |
| 113 // Start the timer to run at the given |delay| from now. If the timer is | 108 // Start the timer to run at the given |delay| from now. If the timer is |
| 114 // already running, it will be replaced to call the given |user_task|. | 109 // already running, it will be replaced to call the given |user_task|. |
| 115 virtual void Start(const tracked_objects::Location& posted_from, | 110 virtual void Start(const tracked_objects::Location& posted_from, |
| 116 TimeDelta delay, | 111 TimeDelta delay, |
| 117 const base::Closure& user_task); | 112 const base::Closure& user_task); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 // to link in MSVC. But clang-plugin does not allow inline definitions of | 301 // to link in MSVC. But clang-plugin does not allow inline definitions of |
| 307 // virtual methods, so the inline definition lives in the header file here | 302 // virtual methods, so the inline definition lives in the header file here |
| 308 // to satisfy both. | 303 // to satisfy both. |
| 309 inline void DelayTimer::Reset() { | 304 inline void DelayTimer::Reset() { |
| 310 Timer::Reset(); | 305 Timer::Reset(); |
| 311 } | 306 } |
| 312 | 307 |
| 313 } // namespace base | 308 } // namespace base |
| 314 | 309 |
| 315 #endif // BASE_TIMER_TIMER_H_ | 310 #endif // BASE_TIMER_TIMER_H_ |
| OLD | NEW |