OLD | NEW |
(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/power_monitor/power_monitor.h" |
| 6 |
| 7 namespace base { |
| 8 |
| 9 // Function to query the system to see if it is currently running on |
| 10 // battery power. Returns true if running on battery. |
| 11 bool PowerMonitor::IsBatteryPower() { |
| 12 SYSTEM_POWER_STATUS status; |
| 13 if (!GetSystemPowerStatus(&status)) { |
| 14 DLOG(ERROR) << "GetSystemPowerStatus failed: " << GetLastError(); |
| 15 return false; |
| 16 } |
| 17 return (status.ACLineStatus == 0); |
| 18 } |
| 19 |
| 20 } // namespace base |
OLD | NEW |