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

Side by Side Diff: base/system_monitor/system_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: Revert using Singleton pattern for PowerMonitor Created 8 years, 1 month 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2011 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.
4
5 #include "base/system_monitor/system_monitor.h"
6
7 namespace base {
8
9 void SystemMonitor::ProcessWmPowerBroadcastMessage(int event_id) {
10 PowerEvent power_event;
11 switch (event_id) {
12 case PBT_APMPOWERSTATUSCHANGE: // The power status changed.
13 power_event = POWER_STATE_EVENT;
14 break;
15 case PBT_APMRESUMEAUTOMATIC: // Resume from suspend.
16 //case PBT_APMRESUMESUSPEND: // User-initiated resume from suspend.
17 // We don't notify for this latter event
18 // because if it occurs it is always sent as a
19 // second event after PBT_APMRESUMEAUTOMATIC.
20 power_event = RESUME_EVENT;
21 break;
22 case PBT_APMSUSPEND: // System has been suspended.
23 power_event = SUSPEND_EVENT;
24 break;
25 default:
26 return;
27
28 // Other Power Events:
29 // PBT_APMBATTERYLOW - removed in Vista.
30 // PBT_APMOEMEVENT - removed in Vista.
31 // PBT_APMQUERYSUSPEND - removed in Vista.
32 // PBT_APMQUERYSUSPENDFAILED - removed in Vista.
33 // PBT_APMRESUMECRITICAL - removed in Vista.
34 // PBT_POWERSETTINGCHANGE - user changed the power settings.
35 }
36 ProcessPowerMessage(power_event);
37 }
38
39 // Function to query the system to see if it is currently running on
40 // battery power. Returns true if running on battery.
41 bool SystemMonitor::IsBatteryPower() {
42 SYSTEM_POWER_STATUS status;
43 if (!GetSystemPowerStatus(&status)) {
44 DLOG(ERROR) << "GetSystemPowerStatus failed: " << GetLastError();
45 return false;
46 }
47 return (status.ACLineStatus == 0);
48 }
49
50 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698