| 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 #ifndef SERVICES_DEVICE_PUBLIC_CPP_POWER_MONITOR_POWER_MONITOR_BROADCAST_SOURCE_
H_ | 5 #ifndef SERVICES_DEVICE_PUBLIC_CPP_POWER_MONITOR_POWER_MONITOR_BROADCAST_SOURCE_
H_ |
| 6 #define SERVICES_DEVICE_PUBLIC_CPP_POWER_MONITOR_POWER_MONITOR_BROADCAST_SOURCE_
H_ | 6 #define SERVICES_DEVICE_PUBLIC_CPP_POWER_MONITOR_POWER_MONITOR_BROADCAST_SOURCE_
H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/power_monitor/power_monitor_source.h" | 9 #include "base/power_monitor/power_monitor_source.h" |
| 10 #include "mojo/public/cpp/bindings/binding.h" | 10 #include "mojo/public/cpp/bindings/binding.h" |
| 11 #include "services/device/public/interfaces/power_monitor.mojom.h" | 11 #include "services/device/public/interfaces/power_monitor.mojom.h" |
| 12 #include "services/service_manager/public/cpp/interface_provider.h" | 12 |
| 13 namespace service_manager { |
| 14 class Connector; |
| 15 } |
| 13 | 16 |
| 14 namespace device { | 17 namespace device { |
| 15 | 18 |
| 16 // Receives state changes from Power Monitor through mojo, and relays them to | 19 // Receives state changes from Power Monitor through mojo, and relays them to |
| 17 // the PowerMonitor of the current process. | 20 // the PowerMonitor of the current process. |
| 18 class PowerMonitorBroadcastSource : public base::PowerMonitorSource, | 21 class PowerMonitorBroadcastSource : public base::PowerMonitorSource, |
| 19 public device::mojom::PowerMonitorClient { | 22 public device::mojom::PowerMonitorClient { |
| 20 public: | 23 public: |
| 21 explicit PowerMonitorBroadcastSource( | 24 explicit PowerMonitorBroadcastSource(service_manager::Connector* connector); |
| 22 service_manager::InterfaceProvider* interface_provider); | |
| 23 ~PowerMonitorBroadcastSource() override; | 25 ~PowerMonitorBroadcastSource() override; |
| 24 | 26 |
| 25 void PowerStateChange(bool on_battery_power) override; | 27 void PowerStateChange(bool on_battery_power) override; |
| 26 void Suspend() override; | 28 void Suspend() override; |
| 27 void Resume() override; | 29 void Resume() override; |
| 28 | 30 |
| 29 private: | 31 private: |
| 30 bool IsOnBatteryPowerImpl() override; | 32 bool IsOnBatteryPowerImpl() override; |
| 31 bool last_reported_battery_power_state_; | 33 bool last_reported_battery_power_state_; |
| 32 mojo::Binding<device::mojom::PowerMonitorClient> binding_; | 34 mojo::Binding<device::mojom::PowerMonitorClient> binding_; |
| 33 | 35 |
| 34 DISALLOW_COPY_AND_ASSIGN(PowerMonitorBroadcastSource); | 36 DISALLOW_COPY_AND_ASSIGN(PowerMonitorBroadcastSource); |
| 35 }; | 37 }; |
| 36 | 38 |
| 37 } // namespace device | 39 } // namespace device |
| 38 | 40 |
| 39 #endif // SERVICES_DEVICE_PUBLIC_CPP_POWER_MONITOR_POWER_MONITOR_BROADCAST_SOUR
CE_H_ | 41 #endif // SERVICES_DEVICE_PUBLIC_CPP_POWER_MONITOR_POWER_MONITOR_BROADCAST_SOUR
CE_H_ |
| OLD | NEW |