| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 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 "base/power_monitor/power_monitor_device_source.h" | |
| 6 | |
| 7 #include "base/time/time.h" | |
| 8 | |
| 9 namespace base { | |
| 10 | |
| 11 #if defined(ENABLE_BATTERY_MONITORING) | |
| 12 // The amount of time (in ms) to wait before running the initial | |
| 13 // battery check. | |
| 14 static int kDelayedBatteryCheckMs = 10 * 1000; | |
| 15 #endif // defined(ENABLE_BATTERY_MONITORING) | |
| 16 | |
| 17 PowerMonitorDeviceSource::PowerMonitorDeviceSource() { | |
| 18 DCHECK(MessageLoop::current()); | |
| 19 #if defined(ENABLE_BATTERY_MONITORING) | |
| 20 delayed_battery_check_.Start(FROM_HERE, | |
| 21 base::TimeDelta::FromMilliseconds(kDelayedBatteryCheckMs), this, | |
| 22 &PowerMonitorDeviceSource::BatteryCheck); | |
| 23 #endif // defined(ENABLE_BATTERY_MONITORING) | |
| 24 #if defined(OS_MACOSX) | |
| 25 PlatformInit(); | |
| 26 #endif | |
| 27 } | |
| 28 | |
| 29 PowerMonitorDeviceSource::~PowerMonitorDeviceSource() { | |
| 30 #if defined(OS_MACOSX) | |
| 31 PlatformDestroy(); | |
| 32 #endif | |
| 33 } | |
| 34 | |
| 35 void PowerMonitorDeviceSource::BatteryCheck() { | |
| 36 ProcessPowerEvent(PowerMonitorSource::POWER_STATE_EVENT); | |
| 37 } | |
| 38 | |
| 39 } // namespace base | |
| OLD | NEW |