Adding owners for third_party
[chromium-blink-merge.git] / base / hi_res_timer_manager_win.cc
blob1a9239449473490059443025b8957f1bf62803b3
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/time.h"
9 HighResolutionTimerManager::HighResolutionTimerManager()
10 : hi_res_clock_available_(false) {
11 base::SystemMonitor* system_monitor = base::SystemMonitor::Get();
12 system_monitor->AddPowerObserver(this);
13 UseHiResClock(!system_monitor->BatteryPower());
16 HighResolutionTimerManager::~HighResolutionTimerManager() {
17 base::SystemMonitor::Get()->RemovePowerObserver(this);
18 UseHiResClock(false);
21 void HighResolutionTimerManager::OnPowerStateChange(bool on_battery_power) {
22 UseHiResClock(!on_battery_power);
25 void HighResolutionTimerManager::UseHiResClock(bool use) {
26 if (use == hi_res_clock_available_)
27 return;
28 hi_res_clock_available_ = use;
29 base::Time::EnableHighResolutionTimer(use);