Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Unified Diff: base/power_monitor/power_monitor_device_source.cc

Issue 17074009: Created multi-process-friendly PowerMonitor interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing windows unit test errors Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..0a3997517ec2e1d11edddfb6f98bf34ede69c8db
--- /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/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,
+ &PowerMonitorDeviceSource::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
« no previous file with comments | « base/power_monitor/power_monitor_device_source.h ('k') | base/power_monitor/power_monitor_device_source_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698