| 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/timer/timer.h" |
| 13 #include "build/build_config.h" |
| 11 | 14 |
| 12 namespace base { | 15 namespace base { |
| 13 | 16 |
| 14 // Ensures that the Windows high resolution timer is only used | 17 // Ensures that the Windows high resolution timer is only used |
| 15 // when not running on battery power. | 18 // when not running on battery power. |
| 16 class BASE_EXPORT HighResolutionTimerManager : public base::PowerObserver { | 19 class BASE_EXPORT HighResolutionTimerManager : public base::PowerObserver { |
| 17 public: | 20 public: |
| 18 HighResolutionTimerManager(); | 21 HighResolutionTimerManager(); |
| 19 ~HighResolutionTimerManager() override; | 22 ~HighResolutionTimerManager() override; |
| 20 | 23 |
| 21 // base::PowerObserver method. | 24 // base::PowerObserver methods. |
| 22 void OnPowerStateChange(bool on_battery_power) override; | 25 void OnPowerStateChange(bool on_battery_power) override; |
| 26 void OnSuspend() override; |
| 27 void OnResume() override; |
| 23 | 28 |
| 24 // Returns true if the hi resolution clock could be used right now. | 29 // Returns true if the hi resolution clock could be used right now. |
| 25 bool hi_res_clock_available() const { return hi_res_clock_available_; } | 30 bool hi_res_clock_available() const { return hi_res_clock_available_; } |
| 26 | 31 |
| 27 private: | 32 private: |
| 28 // Enable or disable the faster multimedia timer. | 33 // Enable or disable the faster multimedia timer. |
| 29 void UseHiResClock(bool use); | 34 void UseHiResClock(bool use); |
| 30 | 35 |
| 31 bool hi_res_clock_available_; | 36 bool hi_res_clock_available_; |
| 32 | 37 |
| 38 #if defined(OS_WIN) |
| 39 // Timer for polling the high resolution timer usage. |
| 40 base::RepeatingTimer timer_; |
| 41 #endif |
| 42 |
| 33 DISALLOW_COPY_AND_ASSIGN(HighResolutionTimerManager); | 43 DISALLOW_COPY_AND_ASSIGN(HighResolutionTimerManager); |
| 34 }; | 44 }; |
| 35 | 45 |
| 36 } // namespace base | 46 } // namespace base |
| 37 | 47 |
| 38 #endif // BASE_TIMER_HI_RES_TIMER_MANAGER_H_ | 48 #endif // BASE_TIMER_HI_RES_TIMER_MANAGER_H_ |
| OLD | NEW |