| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "device/power_monitor/public/cpp/power_monitor_broadcast_source.h" | 5 #include "device/power_monitor/public/cpp/power_monitor_broadcast_source.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "mojo/public/cpp/bindings/binding.h" | 9 #include "mojo/public/cpp/bindings/binding.h" |
| 10 | 10 |
| 11 namespace device { | 11 namespace device { |
| 12 | 12 |
| 13 PowerMonitorBroadcastSource::PowerMonitorBroadcastSource( | 13 PowerMonitorBroadcastSource::PowerMonitorBroadcastSource( |
| 14 service_manager::InterfaceProvider* interface_provider) | 14 service_manager::InterfaceProvider* interface_provider) |
| 15 : last_reported_battery_power_state_(false), binding_(this) { | 15 : last_reported_battery_power_state_(false), binding_(this) { |
| 16 if (interface_provider) { | 16 if (interface_provider) { |
| 17 device::mojom::PowerMonitorPtr power_monitor; | 17 device::mojom::PowerMonitorPtr power_monitor; |
| 18 interface_provider->GetInterface(mojo::GetProxy(&power_monitor)); | 18 interface_provider->GetInterface(mojo::MakeRequest(&power_monitor)); |
| 19 power_monitor->SetClient(binding_.CreateInterfacePtrAndBind()); | 19 power_monitor->SetClient(binding_.CreateInterfacePtrAndBind()); |
| 20 } | 20 } |
| 21 } | 21 } |
| 22 | 22 |
| 23 PowerMonitorBroadcastSource::~PowerMonitorBroadcastSource() {} | 23 PowerMonitorBroadcastSource::~PowerMonitorBroadcastSource() {} |
| 24 | 24 |
| 25 bool PowerMonitorBroadcastSource::IsOnBatteryPowerImpl() { | 25 bool PowerMonitorBroadcastSource::IsOnBatteryPowerImpl() { |
| 26 return last_reported_battery_power_state_; | 26 return last_reported_battery_power_state_; |
| 27 } | 27 } |
| 28 | 28 |
| 29 void PowerMonitorBroadcastSource::PowerStateChange(bool on_battery_power) { | 29 void PowerMonitorBroadcastSource::PowerStateChange(bool on_battery_power) { |
| 30 last_reported_battery_power_state_ = on_battery_power; | 30 last_reported_battery_power_state_ = on_battery_power; |
| 31 ProcessPowerEvent(PowerMonitorSource::POWER_STATE_EVENT); | 31 ProcessPowerEvent(PowerMonitorSource::POWER_STATE_EVENT); |
| 32 } | 32 } |
| 33 | 33 |
| 34 void PowerMonitorBroadcastSource::Suspend() { | 34 void PowerMonitorBroadcastSource::Suspend() { |
| 35 ProcessPowerEvent(PowerMonitorSource::SUSPEND_EVENT); | 35 ProcessPowerEvent(PowerMonitorSource::SUSPEND_EVENT); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void PowerMonitorBroadcastSource::Resume() { | 38 void PowerMonitorBroadcastSource::Resume() { |
| 39 ProcessPowerEvent(PowerMonitorSource::RESUME_EVENT); | 39 ProcessPowerEvent(PowerMonitorSource::RESUME_EVENT); |
| 40 } | 40 } |
| 41 | 41 |
| 42 } // namespace device | 42 } // namespace device |
| OLD | NEW |