Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(750)

Side by Side Diff: base/power_monitor/power_monitor_source.cc

Issue 2351593004: Implement base::PowerMonitor::IsOnBatteryPower() for OSX. (Closed)
Patch Set: Invert setter. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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/power_monitor/power_monitor_source.h" 5 #include "base/power_monitor/power_monitor_source.h"
6 6
7 #include "base/power_monitor/power_monitor.h" 7 #include "base/power_monitor/power_monitor.h"
8 #include "build/build_config.h"
8 9
9 namespace base { 10 namespace base {
10 11
11 PowerMonitorSource::PowerMonitorSource() 12 PowerMonitorSource::PowerMonitorSource() {}
12 : on_battery_power_(false), 13 PowerMonitorSource::~PowerMonitorSource() {}
13 suspended_(false) {
14 }
15
16 PowerMonitorSource::~PowerMonitorSource() {
17 }
18 14
19 bool PowerMonitorSource::IsOnBatteryPower() { 15 bool PowerMonitorSource::IsOnBatteryPower() {
20 AutoLock auto_lock(battery_lock_); 16 AutoLock auto_lock(battery_lock_);
21 return on_battery_power_; 17 return on_battery_power_;
22 } 18 }
23 19
24 void PowerMonitorSource::ProcessPowerEvent(PowerEvent event_id) { 20 void PowerMonitorSource::ProcessPowerEvent(PowerEvent event_id) {
25 PowerMonitor* monitor = PowerMonitor::Get(); 21 PowerMonitor* monitor = PowerMonitor::Get();
26 if (!monitor) 22 if (!monitor)
27 return; 23 return;
(...skipping 28 matching lines...) Expand all
56 break; 52 break;
57 case SUSPEND_EVENT: 53 case SUSPEND_EVENT:
58 if (!source->suspended_) { 54 if (!source->suspended_) {
59 source->suspended_ = true; 55 source->suspended_ = true;
60 monitor->NotifySuspend(); 56 monitor->NotifySuspend();
61 } 57 }
62 break; 58 break;
63 } 59 }
64 } 60 }
65 61
62 void PowerMonitorSource::SetInitialOnBatteryPowerState(bool on_battery_power) {
63 // Must only be called before a monitor exists, otherwise the caller should
64 // have just used a normal ProcessPowerEvent(POWER_STATE_EVENT) call.
65 DCHECK(!PowerMonitor::Get());
66 on_battery_power_ = on_battery_power;
67 }
68
66 } // namespace base 69 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698