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_CHILD_POWER_MONITOR_BROADCAST_SOURCE_H_ |
| 6 #define CONTENT_CHILD_POWER_MONITOR_BROADCAST_SOURCE_H_ |
| 7 |
| 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/power_monitor/power_monitor_source.h" |
| 11 #include "content/common/content_export.h" |
| 12 #include "ipc/ipc_channel.h" |
| 13 #include "ipc/ipc_channel_proxy.h" |
| 14 |
| 15 namespace content { |
| 16 |
| 17 // Receives Power Monitor IPC messages sent from the browser process and relays |
| 18 // them to the PowerMonitor of the current process. |
| 19 class CONTENT_EXPORT PowerMonitorBroadcastSource : |
| 20 public base::PowerMonitorSource { |
| 21 public: |
| 22 explicit PowerMonitorBroadcastSource( |
| 23 scoped_refptr<base::MessageLoopProxy> message_loop); |
| 24 virtual ~PowerMonitorBroadcastSource(); |
| 25 |
| 26 IPC::ChannelProxy::MessageFilter* GetMessageFilter(); |
| 27 |
| 28 private: |
| 29 friend class PowerMessageFilter; |
| 30 |
| 31 virtual bool IsOnBatteryPowerImpl() OVERRIDE; |
| 32 |
| 33 void OnPowerStateChange(bool on_battery_power); |
| 34 void OnSuspend(); |
| 35 void OnResume(); |
| 36 |
| 37 bool last_reported_battery_power_state_; |
| 38 scoped_refptr<IPC::ChannelProxy::MessageFilter> message_filter_; |
| 39 base::WeakPtrFactory<PowerMonitorBroadcastSource> weak_factory_; |
| 40 |
| 41 DISALLOW_COPY_AND_ASSIGN(PowerMonitorBroadcastSource); |
| 42 }; |
| 43 |
| 44 } // namespace content |
| 45 |
| 46 #endif // CONTENT_CHILD_POWER_MONITOR_MESSAGE_FILTER_H_ |
OLD | NEW |