OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 23 matching lines...) Expand all Loading... |
34 // Both OneShotTimer and RepeatingTimer also support a Reset method, which | 34 // Both OneShotTimer and RepeatingTimer also support a Reset method, which |
35 // allows you to easily defer the timer event until the timer delay passes once | 35 // allows you to easily defer the timer event until the timer delay passes once |
36 // again. So, in the above example, if 0.5 seconds have already passed, | 36 // again. So, in the above example, if 0.5 seconds have already passed, |
37 // calling Reset on timer_ would postpone DoStuff by another 1 second. In | 37 // calling Reset on timer_ would postpone DoStuff by another 1 second. In |
38 // other words, Reset is shorthand for calling Stop and then Start again with | 38 // other words, Reset is shorthand for calling Stop and then Start again with |
39 // the same arguments. | 39 // the same arguments. |
40 | 40 |
41 #ifndef BASE_TIMER_H_ | 41 #ifndef BASE_TIMER_H_ |
42 #define BASE_TIMER_H_ | 42 #define BASE_TIMER_H_ |
43 | 43 |
| 44 // IMPORTANT: If you change timer code, make sure that all tests (including |
| 45 // disabled ones) from timer_unittests.cc pass locally. Some are disabled |
| 46 // because they're flaky on the buildbot, but when you run them locally you |
| 47 // should be able to tell the difference. |
| 48 |
44 #include "base/task.h" | 49 #include "base/task.h" |
45 #include "base/time.h" | 50 #include "base/time.h" |
46 | 51 |
47 class MessageLoop; | 52 class MessageLoop; |
48 | 53 |
49 namespace base { | 54 namespace base { |
50 | 55 |
51 //----------------------------------------------------------------------------- | 56 //----------------------------------------------------------------------------- |
52 // This class is an implementation detail of OneShotTimer and RepeatingTimer. | 57 // This class is an implementation detail of OneShotTimer and RepeatingTimer. |
53 // Please do not use this class directly. | 58 // Please do not use this class directly. |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 const ReceiverMethod method_; | 261 const ReceiverMethod method_; |
257 const TimeDelta delay_; | 262 const TimeDelta delay_; |
258 | 263 |
259 OneShotTimer<DelayTimer<Receiver> > timer_; | 264 OneShotTimer<DelayTimer<Receiver> > timer_; |
260 Time trigger_time_; | 265 Time trigger_time_; |
261 }; | 266 }; |
262 | 267 |
263 } // namespace base | 268 } // namespace base |
264 | 269 |
265 #endif // BASE_TIMER_H_ | 270 #endif // BASE_TIMER_H_ |
OLD | NEW |