OLD | NEW |
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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.h" | 5 #include "base/system_monitor.h" |
6 | 6 |
7 namespace base { | 7 namespace base { |
8 | 8 |
9 void SystemMonitor::ProcessWmPowerBroadcastMessage(int event_id) { | 9 void SystemMonitor::ProcessWmPowerBroadcastMessage(int event_id) { |
10 PowerEvent power_event; | 10 PowerEvent power_event; |
11 switch (event_id) { | 11 switch (event_id) { |
12 case PBT_APMPOWERSTATUSCHANGE: | 12 case PBT_APMPOWERSTATUSCHANGE: |
13 power_event = PowerStateEvent; | 13 power_event = POWER_STATE_EVENT; |
14 break; | 14 break; |
15 case PBT_APMRESUMEAUTOMATIC: | 15 case PBT_APMRESUMEAUTOMATIC: |
16 power_event = ResumeEvent; | 16 power_event = RESUME_EVENT; |
17 break; | 17 break; |
18 case PBT_APMSUSPEND: | 18 case PBT_APMSUSPEND: |
19 power_event = SuspendEvent; | 19 power_event = SUSPEND_EVENT; |
20 break; | 20 break; |
21 default: | 21 default: |
22 DCHECK(false); | 22 DCHECK(false); |
23 } | 23 } |
24 ProcessPowerMessage(power_event); | 24 ProcessPowerMessage(power_event); |
25 } | 25 } |
26 | 26 |
27 // Function to query the system to see if it is currently running on | 27 // Function to query the system to see if it is currently running on |
28 // battery power. Returns true if running on battery. | 28 // battery power. Returns true if running on battery. |
29 bool SystemMonitor::IsBatteryPower() { | 29 bool SystemMonitor::IsBatteryPower() { |
30 SYSTEM_POWER_STATUS status; | 30 SYSTEM_POWER_STATUS status; |
31 if (!GetSystemPowerStatus(&status)) { | 31 if (!GetSystemPowerStatus(&status)) { |
32 LOG(ERROR) << "GetSystemPowerStatus failed: " << GetLastError(); | 32 LOG(ERROR) << "GetSystemPowerStatus failed: " << GetLastError(); |
33 return false; | 33 return false; |
34 } | 34 } |
35 return (status.ACLineStatus == 0); | 35 return (status.ACLineStatus == 0); |
36 } | 36 } |
37 | 37 |
38 | 38 |
39 | 39 |
40 } // namespace base | 40 } // namespace base |
OLD | NEW |