Roll src/third_party/skia f4e5995:23d4320
[chromium-blink-merge.git] / base / power_monitor / power_monitor_device_source.cc
blob0a3997517ec2e1d11edddfb6f98bf34ede69c8db
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"
9 namespace base {
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)
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
29 PowerMonitorDeviceSource::~PowerMonitorDeviceSource() {
30 #if defined(OS_MACOSX)
31 PlatformDestroy();
32 #endif
35 void PowerMonitorDeviceSource::BatteryCheck() {
36 ProcessPowerEvent(PowerMonitorSource::POWER_STATE_EVENT);
39 } // namespace base