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.
5 #include "base/power_monitor/power_monitor_device_source.h"
7 #include "base/time/time.h"
11 #if defined(ENABLE_BATTERY_MONITORING)
12 // The amount of time (in ms) to wait before running the initial
14 static int kDelayedBatteryCheckMs
= 10 * 1000;
15 #endif // defined(ENABLE_BATTERY_MONITORING)
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)
29 PowerMonitorDeviceSource::~PowerMonitorDeviceSource() {
30 #if defined(OS_MACOSX)
35 void PowerMonitorDeviceSource::BatteryCheck() {
36 ProcessPowerEvent(PowerMonitorSource::POWER_STATE_EVENT
);