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

Unified Diff: base/power_monitor/power_monitor_win.cc

Issue 10959020: SystemMonitor refactoring: move power state monitor into a separate class called PowerMonitor (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: make HWNDMessageHandler as a friend class of PowerMonitor Created 8 years, 2 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_win.cc
diff --git a/base/power_monitor/power_monitor_win.cc b/base/power_monitor/power_monitor_win.cc
new file mode 100644
index 0000000000000000000000000000000000000000..81c58562766a9b95e1fe6297c0dc2f08e998a2eb
--- /dev/null
+++ b/base/power_monitor/power_monitor_win.cc
@@ -0,0 +1,20 @@
+// Copyright (c) 2011 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.h"
+
+namespace base {
+
+// Function to query the system to see if it is currently running on
+// battery power. Returns true if running on battery.
+bool PowerMonitor::IsBatteryPower() {
+ SYSTEM_POWER_STATUS status;
+ if (!GetSystemPowerStatus(&status)) {
+ DLOG(ERROR) << "GetSystemPowerStatus failed: " << GetLastError();
+ return false;
+ }
+ return (status.ACLineStatus == 0);
+}
+
+} // namespace base

Powered by Google App Engine
This is Rietveld 408576698