1 // Copyright 2014 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 #include "base/power_monitor/power_monitor_device_source.h" 7 #include "base/power_monitor/power_monitor_source.h" 8 9 namespace base { 10 11 namespace { 12 13 // The most-recently-seen power source. 14 bool g_on_battery = false; 15 16 } // namespace 17 18 // static SetPowerSource(bool on_battery)19void PowerMonitorDeviceSource::SetPowerSource(bool on_battery) { 20 if (on_battery != g_on_battery) { 21 g_on_battery = on_battery; 22 ProcessPowerEvent(POWER_STATE_EVENT); 23 } 24 } 25 26 // static HandleSystemSuspending()27void PowerMonitorDeviceSource::HandleSystemSuspending() { 28 ProcessPowerEvent(SUSPEND_EVENT); 29 } 30 31 // static HandleSystemResumed()32void PowerMonitorDeviceSource::HandleSystemResumed() { 33 ProcessPowerEvent(RESUME_EVENT); 34 } 35 IsOnBatteryPowerImpl()36bool PowerMonitorDeviceSource::IsOnBatteryPowerImpl() { 37 return g_on_battery; 38 } 39 40 } // namespace base 41