OLD | NEW |
| (Empty) |
1 // Copyright (c) 2009 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. | |
4 | |
5 #include "app/hi_res_timer_manager.h" | |
6 | |
7 #include "base/time.h" | |
8 | |
9 HighResolutionTimerManager::HighResolutionTimerManager() | |
10 : hi_res_clock_used_(false) { | |
11 SystemMonitor* system_monitor = SystemMonitor::Get(); | |
12 system_monitor->AddObserver(this); | |
13 UseHiResClock(!system_monitor->BatteryPower()); | |
14 } | |
15 | |
16 HighResolutionTimerManager::~HighResolutionTimerManager() { | |
17 SystemMonitor::Get()->RemoveObserver(this); | |
18 UseHiResClock(false); | |
19 } | |
20 | |
21 void HighResolutionTimerManager::OnPowerStateChange(bool on_battery_power) { | |
22 UseHiResClock(!on_battery_power); | |
23 } | |
24 | |
25 void HighResolutionTimerManager::UseHiResClock(bool use) { | |
26 if (use == hi_res_clock_used_) | |
27 return; | |
28 base::Time::EnableHighResolutionTimer(use); | |
29 } | |
OLD | NEW |