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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 }; | 177 }; |
178 | 178 |
179 //----------------------------------------------------------------------------- | 179 //----------------------------------------------------------------------------- |
180 // This class is an implementation detail of OneShotTimer and RepeatingTimer. | 180 // This class is an implementation detail of OneShotTimer and RepeatingTimer. |
181 // Please do not use this class directly. | 181 // Please do not use this class directly. |
182 template <class Receiver, bool kIsRepeating> | 182 template <class Receiver, bool kIsRepeating> |
183 class BaseTimerMethodPointer : public Timer { | 183 class BaseTimerMethodPointer : public Timer { |
184 public: | 184 public: |
185 typedef void (Receiver::*ReceiverMethod)(); | 185 typedef void (Receiver::*ReceiverMethod)(); |
186 | 186 |
| 187 // This is here to work around the fact that Timer::Start is "hidden" by the |
| 188 // Start definition below, rather than being overloaded. |
| 189 // TODO(tim): We should remove uses of BaseTimerMethodPointer::Start below |
| 190 // and convert callers to use the base::Closure version in Timer::Start, |
| 191 // see bug 148832. |
| 192 using Timer::Start; |
| 193 |
187 BaseTimerMethodPointer() : Timer(kIsRepeating, kIsRepeating) {} | 194 BaseTimerMethodPointer() : Timer(kIsRepeating, kIsRepeating) {} |
188 | 195 |
189 // Start the timer to run at the given |delay| from now. If the timer is | 196 // Start the timer to run at the given |delay| from now. If the timer is |
190 // already running, it will be replaced to call a task formed from | 197 // already running, it will be replaced to call a task formed from |
191 // |reviewer->*method|. | 198 // |reviewer->*method|. |
192 void Start(const tracked_objects::Location& posted_from, | 199 void Start(const tracked_objects::Location& posted_from, |
193 TimeDelta delay, | 200 TimeDelta delay, |
194 Receiver* receiver, | 201 Receiver* receiver, |
195 ReceiverMethod method) { | 202 ReceiverMethod method) { |
196 Timer::Start(posted_from, delay, | 203 Timer::Start(posted_from, delay, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 : Timer(posted_from, delay, | 238 : Timer(posted_from, delay, |
232 base::Bind(method, base::Unretained(receiver)), | 239 base::Bind(method, base::Unretained(receiver)), |
233 false) {} | 240 false) {} |
234 | 241 |
235 void Reset() { Timer::Reset(); } | 242 void Reset() { Timer::Reset(); } |
236 }; | 243 }; |
237 | 244 |
238 } // namespace base | 245 } // namespace base |
239 | 246 |
240 #endif // BASE_TIMER_H_ | 247 #endif // BASE_TIMER_H_ |
OLD | NEW |