blob: 2a42e90ec80b5584112d3c2823994fa15b8c1f81 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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 = POWER_STATE_EVENT;
break;
case PBT_APMRESUMEAUTOMATIC:
power_event = RESUME_EVENT;
break;
case PBT_APMSUSPEND:
power_event = SUSPEND_EVENT;
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
|