OLD | NEW |
---|---|
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 #ifndef CONTENT_BROWSER_POWER_MONITOR_MESSAGE_BROADCASTER_H_ | 5 #ifndef CONTENT_BROWSER_POWER_MONITOR_MESSAGE_BROADCASTER_H_ |
6 #define CONTENT_BROWSER_POWER_MONITOR_MESSAGE_BROADCASTER_H_ | 6 #define CONTENT_BROWSER_POWER_MONITOR_MESSAGE_BROADCASTER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/power_monitor/power_observer.h" | 9 #include "base/power_monitor/power_observer.h" |
10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
11 | 11 #include "device/power_monitor/public/interfaces/power_monitor.mojom.h" |
12 namespace IPC { | |
13 class Sender; | |
14 } | |
15 | 12 |
16 namespace content { | 13 namespace content { |
17 | 14 |
18 // A class used to monitor the power state change and communicate it to child | 15 // A class used to monitor the power state change and communicate it to child |
19 // processes via IPC. | 16 // processes via IPC. |
20 class CONTENT_EXPORT PowerMonitorMessageBroadcaster | 17 class CONTENT_EXPORT PowerMonitorMessageBroadcaster |
21 : public base::PowerObserver { | 18 : public base::PowerObserver { |
22 public: | 19 public: |
23 explicit PowerMonitorMessageBroadcaster(IPC::Sender* sender); | 20 explicit PowerMonitorMessageBroadcaster(); |
24 ~PowerMonitorMessageBroadcaster() override; | 21 ~PowerMonitorMessageBroadcaster() override; |
25 | 22 |
26 // Implement PowerObserver. | 23 // Implement PowerObserver. |
27 void OnPowerStateChange(bool on_battery_power) override; | 24 void OnPowerStateChange(bool on_battery_power) override; |
28 void OnSuspend() override; | 25 void OnSuspend() override; |
29 void OnResume() override; | 26 void OnResume() override; |
30 | 27 |
31 void Init(); | 28 void Init(device::mojom::PowerMonitorClientPtr& power_monitor_client); |
blundell
2016/10/20 22:42:22
You can do this communication via mojo, i.e.:
Add
ke.he
2016/10/24 06:54:39
Yes it's better to add a "SetClient(PowerMontiorCl
ke.he
2016/10/24 11:32:02
Sorry the uploaded cl is branched, the latest one
| |
32 | 29 |
33 private: | 30 private: |
34 IPC::Sender* sender_; | 31 device::mojom::PowerMonitorClientPtr power_monitor_client_; |
35 | 32 |
36 DISALLOW_COPY_AND_ASSIGN(PowerMonitorMessageBroadcaster); | 33 DISALLOW_COPY_AND_ASSIGN(PowerMonitorMessageBroadcaster); |
37 }; | 34 }; |
38 | 35 |
39 } // namespace content | 36 } // namespace content |
40 | 37 |
41 #endif // CONTENT_BROWSER_POWER_MONITOR_MESSAGE_BROADCASTER_H_ | 38 #endif // CONTENT_BROWSER_POWER_MONITOR_MESSAGE_BROADCASTER_H_ |
OLD | NEW |