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

Side by Side 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: Update patch per vandebo's comments 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/system_monitor/system_monitor.h" 5 #include "base/power_monitor/power_monitor.h"
6 6
7 namespace base { 7 namespace base {
8 8 void PowerMonitor::ProcessWmPowerBroadcastMessage(int event_id) {
vandebo (ex-Chrome) 2012/10/11 20:49:57 nit: blank line after namespace.
Hongbo Min 2012/10/12 14:43:53 Done.
9 void SystemMonitor::ProcessWmPowerBroadcastMessage(int event_id) {
10 PowerEvent power_event; 9 PowerEvent power_event;
11 switch (event_id) { 10 switch (event_id) {
12 case PBT_APMPOWERSTATUSCHANGE: // The power status changed. 11 case PBT_APMPOWERSTATUSCHANGE: // The power status changed.
13 power_event = POWER_STATE_EVENT; 12 power_event = POWER_STATE_EVENT;
14 break; 13 break;
15 case PBT_APMRESUMEAUTOMATIC: // Resume from suspend. 14 case PBT_APMRESUMEAUTOMATIC: // Resume from suspend.
16 //case PBT_APMRESUMESUSPEND: // User-initiated resume from suspend. 15 //case PBT_APMRESUMESUSPEND: // User-initiated resume from suspend.
17 // We don't notify for this latter event 16 // We don't notify for this latter event
18 // because if it occurs it is always sent as a 17 // because if it occurs it is always sent as a
19 // second event after PBT_APMRESUMEAUTOMATIC. 18 // second event after PBT_APMRESUMEAUTOMATIC.
(...skipping 11 matching lines...) Expand all
31 // PBT_APMQUERYSUSPEND - removed in Vista. 30 // PBT_APMQUERYSUSPEND - removed in Vista.
32 // PBT_APMQUERYSUSPENDFAILED - removed in Vista. 31 // PBT_APMQUERYSUSPENDFAILED - removed in Vista.
33 // PBT_APMRESUMECRITICAL - removed in Vista. 32 // PBT_APMRESUMECRITICAL - removed in Vista.
34 // PBT_POWERSETTINGCHANGE - user changed the power settings. 33 // PBT_POWERSETTINGCHANGE - user changed the power settings.
35 } 34 }
36 ProcessPowerMessage(power_event); 35 ProcessPowerMessage(power_event);
37 } 36 }
38 37
39 // Function to query the system to see if it is currently running on 38 // Function to query the system to see if it is currently running on
40 // battery power. Returns true if running on battery. 39 // battery power. Returns true if running on battery.
41 bool SystemMonitor::IsBatteryPower() { 40 bool PowerMonitor::IsBatteryPower() {
42 SYSTEM_POWER_STATUS status; 41 SYSTEM_POWER_STATUS status;
43 if (!GetSystemPowerStatus(&status)) { 42 if (!GetSystemPowerStatus(&status)) {
44 DLOG(ERROR) << "GetSystemPowerStatus failed: " << GetLastError(); 43 DLOG(ERROR) << "GetSystemPowerStatus failed: " << GetLastError();
45 return false; 44 return false;
46 } 45 }
47 return (status.ACLineStatus == 0); 46 return (status.ACLineStatus == 0);
48 } 47 }
49 48
50 } // namespace base 49 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698