| Index: base/power_monitor/power_monitor_device_source.cc
|
| diff --git a/base/power_monitor/power_monitor_device_source.cc b/base/power_monitor/power_monitor_device_source.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..7405be12b05f423a44a503f16ee670242ec2aa93
|
| --- /dev/null
|
| +++ b/base/power_monitor/power_monitor_device_source.cc
|
| @@ -0,0 +1,39 @@
|
| +// Copyright 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "base/power_monitor/power_monitor_device_source.h"
|
| +
|
| +#include "base/time.h"
|
| +
|
| +namespace base {
|
| +
|
| +#if defined(ENABLE_BATTERY_MONITORING)
|
| +// The amount of time (in ms) to wait before running the initial
|
| +// battery check.
|
| +static int kDelayedBatteryCheckMs = 10 * 1000;
|
| +#endif // defined(ENABLE_BATTERY_MONITORING)
|
| +
|
| +PowerMonitorDeviceSource::PowerMonitorDeviceSource() {
|
| + DCHECK(MessageLoop::current());
|
| +#if defined(ENABLE_BATTERY_MONITORING)
|
| + delayed_battery_check_.Start(FROM_HERE,
|
| + base::TimeDelta::FromMilliseconds(kDelayedBatteryCheckMs), this,
|
| + &PowerMonitorSource::BatteryCheck);
|
| +#endif // defined(ENABLE_BATTERY_MONITORING)
|
| +#if defined(OS_MACOSX)
|
| + PlatformInit();
|
| +#endif
|
| +}
|
| +
|
| +PowerMonitorDeviceSource::~PowerMonitorDeviceSource() {
|
| +#if defined(OS_MACOSX)
|
| + PlatformDestroy();
|
| +#endif
|
| +}
|
| +
|
| +void PowerMonitorDeviceSource::BatteryCheck() {
|
| + ProcessPowerEvent(PowerMonitorSource::POWER_STATE_EVENT);
|
| +}
|
| +
|
| +} // namespace base
|
|
|