Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 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_source.h" | |
| 6 | |
| 7 #include "base/power_monitor/power_monitor.h" | |
| 8 | |
| 9 namespace base { | |
| 10 | |
| 11 PowerMonitorSource::PowerMonitorSource() | |
| 12 : battery_in_use_(false), | |
| 13 suspended_(false) { | |
| 14 } | |
| 15 | |
| 16 PowerMonitorSource::~PowerMonitorSource() { | |
| 17 | |
|
apatrick_chromium
2013/07/01 23:59:58
nit: extra newline
| |
| 18 } | |
| 19 | |
| 20 bool PowerMonitorSource::IsBatteryPower() { | |
| 21 NOTIMPLEMENTED(); | |
| 22 return false; | |
| 23 } | |
| 24 | |
| 25 void PowerMonitorSource::ProcessPowerEvent(PowerEvent event_id) { | |
| 26 PowerMonitor* monitor = PowerMonitor::Get(); | |
| 27 | |
| 28 // Suppress duplicate notifications. Some platforms may | |
| 29 // send multiple notifications of the same event. | |
| 30 switch (event_id) { | |
| 31 case POWER_STATE_EVENT: | |
| 32 { | |
| 33 bool on_battery = IsBatteryPower(); | |
| 34 if (on_battery != battery_in_use_) { | |
| 35 battery_in_use_ = on_battery; | |
| 36 if (monitor) | |
| 37 monitor->NotifyPowerStateChange(on_battery); | |
| 38 } | |
| 39 } | |
| 40 break; | |
| 41 case RESUME_EVENT: | |
| 42 if (suspended_) { | |
| 43 suspended_ = false; | |
| 44 if (monitor) | |
| 45 monitor->NotifyResume(); | |
| 46 } | |
| 47 break; | |
| 48 case SUSPEND_EVENT: | |
| 49 if (!suspended_) { | |
| 50 suspended_ = true; | |
| 51 if (monitor) | |
| 52 monitor->NotifySuspend(); | |
| 53 } | |
| 54 break; | |
| 55 } | |
| 56 } | |
| 57 | |
| 58 } // namespace base | |
| OLD | NEW |