| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 #ifndef BASE_TIMER_TIMER_H_ | 44 #ifndef BASE_TIMER_TIMER_H_ |
| 45 #define BASE_TIMER_TIMER_H_ | 45 #define BASE_TIMER_TIMER_H_ |
| 46 | 46 |
| 47 // IMPORTANT: If you change timer code, make sure that all tests (including | 47 // IMPORTANT: If you change timer code, make sure that all tests (including |
| 48 // disabled ones) from timer_unittests.cc pass locally. Some are disabled | 48 // disabled ones) from timer_unittests.cc pass locally. Some are disabled |
| 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/basictypes.h" |
| 53 #include "base/bind.h" | 54 #include "base/bind.h" |
| 54 #include "base/bind_helpers.h" | 55 #include "base/bind_helpers.h" |
| 55 #include "base/callback.h" | 56 #include "base/callback.h" |
| 56 #include "base/location.h" | 57 #include "base/location.h" |
| 57 #include "base/time/time.h" | 58 #include "base/time/time.h" |
| 58 | 59 |
| 59 namespace base { | 60 namespace base { |
| 60 | 61 |
| 61 class BaseTimerTaskInternal; | 62 class BaseTimerTaskInternal; |
| 62 class MessageLoop; | |
| 63 | 63 |
| 64 //----------------------------------------------------------------------------- | 64 //----------------------------------------------------------------------------- |
| 65 // This class wraps MessageLoop::PostDelayedTask to manage delayed and repeating | 65 // This class wraps MessageLoop::PostDelayedTask to manage delayed and repeating |
| 66 // 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 |
| 67 // DCHECKs in place to verify this. | 67 // DCHECKs in place to verify this. |
| 68 // | 68 // |
| 69 class BASE_EXPORT Timer { | 69 class BASE_EXPORT Timer { |
| 70 public: | 70 public: |
| 71 // 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 |
| 72 // 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... |
| 237 : Timer(posted_from, delay, | 237 : Timer(posted_from, delay, |
| 238 base::Bind(method, base::Unretained(receiver)), | 238 base::Bind(method, base::Unretained(receiver)), |
| 239 false) {} | 239 false) {} |
| 240 | 240 |
| 241 void Reset() { Timer::Reset(); } | 241 void Reset() { Timer::Reset(); } |
| 242 }; | 242 }; |
| 243 | 243 |
| 244 } // namespace base | 244 } // namespace base |
| 245 | 245 |
| 246 #endif // BASE_TIMER_TIMER_H_ | 246 #endif // BASE_TIMER_TIMER_H_ |
| OLD | NEW |