Bluetooth: fix fake device classes
[chromium-blink-merge.git] / base / hi_res_timer_manager_win.cc
blob2a297dcc339a72dafb85deff8ae855c20729af2b
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
3 // found in the LICENSE file.
5 #include "base/hi_res_timer_manager.h"
7 #include "base/power_monitor/power_monitor.h"
8 #include "base/time.h"
10 HighResolutionTimerManager::HighResolutionTimerManager()
11 : hi_res_clock_available_(false) {
12 base::PowerMonitor* power_monitor = base::PowerMonitor::Get();
13 power_monitor->AddObserver(this);
14 UseHiResClock(!power_monitor->BatteryPower());
17 HighResolutionTimerManager::~HighResolutionTimerManager() {
18 base::PowerMonitor::Get()->RemoveObserver(this);
19 UseHiResClock(false);
22 void HighResolutionTimerManager::OnPowerStateChange(bool on_battery_power) {
23 UseHiResClock(!on_battery_power);
26 void HighResolutionTimerManager::UseHiResClock(bool use) {
27 if (use == hi_res_clock_available_)
28 return;
29 hi_res_clock_available_ = use;
30 base::Time::EnableHighResolutionTimer(use);