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 CONTENT_CHILD_POWER_MONITOR_BROADCAST_SOURCE_H_ | 5 #ifndef CONTENT_CHILD_POWER_MONITOR_BROADCAST_SOURCE_H_ |
6 #define CONTENT_CHILD_POWER_MONITOR_BROADCAST_SOURCE_H_ | 6 #define CONTENT_CHILD_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 "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
11 #include "ipc/ipc_channel.h" | 11 #include "device/power_monitor/public/interfaces/power_monitor.mojom.h" |
12 | 12 #include "mojo/public/cpp/bindings/binding.h" |
13 namespace IPC { | |
14 class MessageFilter; | |
15 } | |
16 | 13 |
17 namespace content { | 14 namespace content { |
18 | 15 |
19 class PowerMessageFilter; | |
20 | |
21 // Receives Power Monitor IPC messages sent from the browser process and relays | 16 // Receives Power Monitor IPC messages sent from the browser process and relays |
22 // them to the PowerMonitor of the current process. | 17 // them to the PowerMonitor of the current process. |
23 class CONTENT_EXPORT PowerMonitorBroadcastSource : | 18 class CONTENT_EXPORT PowerMonitorBroadcastSource |
24 public base::PowerMonitorSource { | 19 : public base::PowerMonitorSource, |
| 20 NON_EXPORTED_BASE(public device::mojom::PowerMonitorClient) { |
25 public: | 21 public: |
26 explicit PowerMonitorBroadcastSource(); | 22 explicit PowerMonitorBroadcastSource(); |
27 ~PowerMonitorBroadcastSource() override; | 23 ~PowerMonitorBroadcastSource() override; |
28 | 24 |
29 IPC::MessageFilter* GetMessageFilter(); | 25 void PowerStateChange(bool on_battery_power) override; |
| 26 void Suspend() override; |
| 27 void Resume() override; |
30 | 28 |
31 private: | 29 private: |
32 friend class PowerMessageFilter; | |
33 | |
34 bool IsOnBatteryPowerImpl() override; | 30 bool IsOnBatteryPowerImpl() override; |
35 | |
36 void OnPowerStateChange(bool on_battery_power); | |
37 void OnSuspend(); | |
38 void OnResume(); | |
39 | |
40 bool last_reported_battery_power_state_; | 31 bool last_reported_battery_power_state_; |
41 scoped_refptr<PowerMessageFilter> message_filter_; | 32 mojo::Binding<device::mojom::PowerMonitorClient> binding_; |
42 | 33 |
43 DISALLOW_COPY_AND_ASSIGN(PowerMonitorBroadcastSource); | 34 DISALLOW_COPY_AND_ASSIGN(PowerMonitorBroadcastSource); |
44 }; | 35 }; |
45 | 36 |
46 } // namespace content | 37 } // namespace content |
47 | 38 |
48 #endif // CONTENT_CHILD_POWER_MONITOR_BROADCAST_SOURCE_H_ | 39 #endif // CONTENT_CHILD_POWER_MONITOR_BROADCAST_SOURCE_H_ |
OLD | NEW |