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 #ifndef BASE_TIMER_HI_RES_TIMER_MANAGER_H_ | 5 #ifndef BASE_TIMER_HI_RES_TIMER_MANAGER_H_ |
6 #define BASE_TIMER_HI_RES_TIMER_MANAGER_H_ | 6 #define BASE_TIMER_HI_RES_TIMER_MANAGER_H_ |
7 | 7 |
8 #include "base/base_export.h" | 8 #include "base/base_export.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" |
10 #include "base/power_monitor/power_observer.h" | 11 #include "base/power_monitor/power_observer.h" |
| 12 #include "base/sequenced_task_runner.h" |
11 | 13 |
12 namespace base { | 14 namespace base { |
13 | 15 |
14 // Ensures that the Windows high resolution timer is only used | 16 // Ensures that the Windows high resolution timer is only used |
15 // when not running on battery power. | 17 // when not running on battery power. |
16 class BASE_EXPORT HighResolutionTimerManager : public base::PowerObserver { | 18 class BASE_EXPORT HighResolutionTimerManager : public base::PowerObserver { |
17 public: | 19 public: |
18 HighResolutionTimerManager(); | 20 HighResolutionTimerManager(); |
19 ~HighResolutionTimerManager() override; | 21 ~HighResolutionTimerManager() override; |
20 | 22 |
21 // base::PowerObserver method. | 23 // base::PowerObserver methods. |
22 void OnPowerStateChange(bool on_battery_power) override; | 24 void OnPowerStateChange(bool on_battery_power) override; |
| 25 void OnSuspend() override; |
| 26 void OnResume() override; |
23 | 27 |
24 // Returns true if the hi resolution clock could be used right now. | 28 // Returns true if the hi resolution clock could be used right now. |
25 bool hi_res_clock_available() const { return hi_res_clock_available_; } | 29 bool hi_res_clock_available() const { return hi_res_clock_available_; } |
26 | 30 |
27 private: | 31 private: |
28 // Enable or disable the faster multimedia timer. | 32 // Enable or disable the faster multimedia timer. |
29 void UseHiResClock(bool use); | 33 void UseHiResClock(bool use); |
30 | 34 |
31 bool hi_res_clock_available_; | 35 bool hi_res_clock_available_; |
32 | 36 |
33 DISALLOW_COPY_AND_ASSIGN(HighResolutionTimerManager); | 37 DISALLOW_COPY_AND_ASSIGN(HighResolutionTimerManager); |
34 }; | 38 }; |
35 | 39 |
36 } // namespace base | 40 } // namespace base |
37 | 41 |
38 #endif // BASE_TIMER_HI_RES_TIMER_MANAGER_H_ | 42 #endif // BASE_TIMER_HI_RES_TIMER_MANAGER_H_ |
OLD | NEW |