summaryrefslogtreecommitdiffstats
path: root/base/system_monitor_win.cc
diff options
context:
space:
mode:
authormbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-25 18:46:11 +0000
committermbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-25 18:46:11 +0000
commita20e82fa0c45fee5515a2ebfc46f38dc65446ef7 (patch)
tree3d14c292858f52cee26ee431410849499f7fcc52 /base/system_monitor_win.cc
parentf9ef79b3c3f5e6a1b00909b30692d47ba92925e6 (diff)
downloadchromium_src-a20e82fa0c45fee5515a2ebfc46f38dc65446ef7.zip
chromium_src-a20e82fa0c45fee5515a2ebfc46f38dc65446ef7.tar.gz
chromium_src-a20e82fa0c45fee5515a2ebfc46f38dc65446ef7.tar.bz2
Implement a SystemMonitor class for monitoring system status
changes. For now, this is just implementing power changes (e.g. battery/AC power changes). This CL just contains this class; the hooking into Chrome will come in a separate CL, but I've tested the basics already. Review URL: http://codereview.chromium.org/4051 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2593 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/system_monitor_win.cc')
-rw-r--r--base/system_monitor_win.cc40
1 files changed, 40 insertions, 0 deletions
diff --git a/base/system_monitor_win.cc b/base/system_monitor_win.cc
new file mode 100644
index 0000000..0603797
--- /dev/null
+++ b/base/system_monitor_win.cc
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 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/system_monitor.h"
+
+namespace base {
+
+void SystemMonitor::ProcessWmPowerBroadcastMessage(int event_id) {
+ PowerEvent power_event;
+ switch (event_id) {
+ case PBT_APMPOWERSTATUSCHANGE:
+ power_event = PowerStateEvent;
+ break;
+ case PBT_APMRESUMEAUTOMATIC:
+ power_event = ResumeEvent;
+ break;
+ case PBT_APMSUSPEND:
+ power_event = SuspendEvent;
+ break;
+ default:
+ DCHECK(false);
+ }
+ ProcessPowerMessage(power_event);
+}
+
+// Function to query the system to see if it is currently running on
+// battery power. Returns true if running on battery.
+bool SystemMonitor::IsBatteryPower() {
+ SYSTEM_POWER_STATUS status;
+ if (!GetSystemPowerStatus(&status)) {
+ LOG(ERROR) << "GetSystemPowerStatus failed: " << GetLastError();
+ return false;
+ }
+ return (status.ACLineStatus == 0);
+}
+
+
+
+} // namespace base \ No newline at end of file