OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_COMMON_POWER_MONITOR_BROADCAST_SOURCE_H_ | |
6 #define CONTENT_COMMON_POWER_MONITOR_BROADCAST_SOURCE_H_ | |
7 | |
8 #include "base/memory/weak_ptr.h" | |
9 #include "base/power_monitor/power_monitor_source.h" | |
10 #include "ipc/ipc_channel.h" | |
11 #include "ipc/ipc_channel_proxy.h" | |
12 | |
13 namespace content { | |
14 | |
15 class PowerMonitorBroadcastSource : public base::PowerMonitorSource { | |
vandebo (ex-Chrome)
2013/07/09 22:22:08
Definitely need a comment on this class. It's a P
| |
16 public: | |
17 PowerMonitorBroadcastSource(); | |
18 virtual ~PowerMonitorBroadcastSource(); | |
19 | |
20 IPC::ChannelProxy::MessageFilter* MessageFilter(); | |
21 | |
22 private: | |
23 friend class PowerMonitorMessageFilter; | |
24 | |
25 class PowerMessageFilter : public IPC::ChannelProxy::MessageFilter { | |
26 public: | |
27 explicit PowerMessageFilter( | |
28 base::WeakPtr<PowerMonitorBroadcastSource> source); | |
29 | |
30 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
31 | |
32 private: | |
33 friend class base::RefCounted<PowerMessageFilter>; | |
34 | |
35 virtual ~PowerMessageFilter(); | |
36 | |
37 void OnPowerStateChange(bool on_battery_power); | |
38 void OnSuspend(); | |
39 void OnResume(); | |
40 | |
41 base::WeakPtr<PowerMonitorBroadcastSource> source_; | |
42 | |
43 DISALLOW_COPY_AND_ASSIGN(PowerMessageFilter); | |
44 }; | |
45 | |
46 virtual bool IsBatteryPower() OVERRIDE; | |
47 | |
48 void OnPowerStateChange(bool on_battery_power); | |
49 void OnSuspend(); | |
50 void OnResume(); | |
51 | |
52 bool on_battery_power_; | |
vandebo (ex-Chrome)
2013/07/09 22:22:08
Oh man, this is confusing... Is there a name that
| |
53 scoped_refptr<PowerMessageFilter> message_filter_; | |
54 base::WeakPtrFactory<PowerMonitorBroadcastSource> weak_factory_; | |
55 }; | |
56 | |
57 } // namespace content | |
58 | |
59 #endif // CONTENT_COMMON_POWER_MONITOR_MESSAGE_FILTER_H_ | |
OLD | NEW |