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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 // because they're flaky on the buildbot, but when you run them locally you | 49 // because they're flaky on the buildbot, but when you run them locally you |
50 // should be able to tell the difference. | 50 // should be able to tell the difference. |
51 | 51 |
52 #include "base/base_export.h" | 52 #include "base/base_export.h" |
53 #include "base/bind.h" | 53 #include "base/bind.h" |
54 #include "base/bind_helpers.h" | 54 #include "base/bind_helpers.h" |
55 #include "base/callback.h" | 55 #include "base/callback.h" |
56 #include "base/location.h" | 56 #include "base/location.h" |
57 #include "base/time.h" | 57 #include "base/time.h" |
58 | 58 |
59 class MessageLoop; | |
60 | |
61 namespace base { | 59 namespace base { |
62 | 60 |
63 class BaseTimerTaskInternal; | 61 class BaseTimerTaskInternal; |
| 62 class MessageLoop; |
64 | 63 |
65 //----------------------------------------------------------------------------- | 64 //----------------------------------------------------------------------------- |
66 // This class wraps MessageLoop::PostDelayedTask to manage delayed and repeating | 65 // This class wraps MessageLoop::PostDelayedTask to manage delayed and repeating |
67 // tasks. It must be destructed on the same thread that starts tasks. There are | 66 // tasks. It must be destructed on the same thread that starts tasks. There are |
68 // DCHECKs in place to verify this. | 67 // DCHECKs in place to verify this. |
69 // | 68 // |
70 class BASE_EXPORT Timer { | 69 class BASE_EXPORT Timer { |
71 public: | 70 public: |
72 // Construct a timer in repeating or one-shot mode. Start or SetTaskInfo must | 71 // Construct a timer in repeating or one-shot mode. Start or SetTaskInfo must |
73 // be called later to set task info. |retain_user_task| determines whether the | 72 // be called later to set task info. |retain_user_task| determines whether the |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 : Timer(posted_from, delay, | 237 : Timer(posted_from, delay, |
239 base::Bind(method, base::Unretained(receiver)), | 238 base::Bind(method, base::Unretained(receiver)), |
240 false) {} | 239 false) {} |
241 | 240 |
242 void Reset() { Timer::Reset(); } | 241 void Reset() { Timer::Reset(); } |
243 }; | 242 }; |
244 | 243 |
245 } // namespace base | 244 } // namespace base |
246 | 245 |
247 #endif // BASE_TIMER_H_ | 246 #endif // BASE_TIMER_H_ |
OLD | NEW |