| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 #ifndef BASE_TIMER_H_ | 41 #ifndef BASE_TIMER_H_ |
| 42 #define BASE_TIMER_H_ | 42 #define BASE_TIMER_H_ |
| 43 #pragma once | 43 #pragma once |
| 44 | 44 |
| 45 // IMPORTANT: If you change timer code, make sure that all tests (including | 45 // IMPORTANT: If you change timer code, make sure that all tests (including |
| 46 // disabled ones) from timer_unittests.cc pass locally. Some are disabled | 46 // disabled ones) from timer_unittests.cc pass locally. Some are disabled |
| 47 // because they're flaky on the buildbot, but when you run them locally you | 47 // because they're flaky on the buildbot, but when you run them locally you |
| 48 // should be able to tell the difference. | 48 // should be able to tell the difference. |
| 49 | 49 |
| 50 #include "base/base_api.h" | 50 #include "base/base_export.h" |
| 51 #include "base/logging.h" | 51 #include "base/logging.h" |
| 52 #include "base/task.h" | 52 #include "base/task.h" |
| 53 #include "base/time.h" | 53 #include "base/time.h" |
| 54 | 54 |
| 55 class MessageLoop; | 55 class MessageLoop; |
| 56 | 56 |
| 57 namespace base { | 57 namespace base { |
| 58 | 58 |
| 59 //----------------------------------------------------------------------------- | 59 //----------------------------------------------------------------------------- |
| 60 // This class is an implementation detail of OneShotTimer and RepeatingTimer. | 60 // This class is an implementation detail of OneShotTimer and RepeatingTimer. |
| 61 // Please do not use this class directly. | 61 // Please do not use this class directly. |
| 62 // | 62 // |
| 63 // This class exists to share code between BaseTimer<T> template instantiations. | 63 // This class exists to share code between BaseTimer<T> template instantiations. |
| 64 // | 64 // |
| 65 class BASE_API BaseTimer_Helper { | 65 class BASE_EXPORT BaseTimer_Helper { |
| 66 public: | 66 public: |
| 67 // Stops the timer. | 67 // Stops the timer. |
| 68 ~BaseTimer_Helper() { | 68 ~BaseTimer_Helper() { |
| 69 OrphanDelayedTask(); | 69 OrphanDelayedTask(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 // Returns true if the timer is running (i.e., not stopped). | 72 // Returns true if the timer is running (i.e., not stopped). |
| 73 bool IsRunning() const { | 73 bool IsRunning() const { |
| 74 return delayed_task_ != NULL; | 74 return delayed_task_ != NULL; |
| 75 } | 75 } |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 const ReceiverMethod method_; | 263 const ReceiverMethod method_; |
| 264 const TimeDelta delay_; | 264 const TimeDelta delay_; |
| 265 | 265 |
| 266 OneShotTimer<DelayTimer<Receiver> > timer_; | 266 OneShotTimer<DelayTimer<Receiver> > timer_; |
| 267 TimeTicks trigger_time_; | 267 TimeTicks trigger_time_; |
| 268 }; | 268 }; |
| 269 | 269 |
| 270 } // namespace base | 270 } // namespace base |
| 271 | 271 |
| 272 #endif // BASE_TIMER_H_ | 272 #endif // BASE_TIMER_H_ |
| OLD | NEW |