Index: content/common/power_monitor_message_filter.h |
diff --git a/content/common/power_monitor_message_filter.h b/content/common/power_monitor_message_filter.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..cf7a7b9b7a33e345d5567fb7bfd54fce32401019 |
--- /dev/null |
+++ b/content/common/power_monitor_message_filter.h |
@@ -0,0 +1,57 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_COMMON_POWER_MONITOR_MESSAGE_FILTER_H_ |
Ken Russell (switch to Gerrit)
2013/06/27 13:08:23
This file and the .cc should be named power_monito
|
+#define CONTENT_COMMON_POWER_MONITOR_MESSAGE_FILTER_H_ |
+ |
+#include "base/power_monitor/power_monitor_source.h" |
+ |
+#include "ipc/ipc_channel.h" |
+#include "ipc/ipc_channel_proxy.h" |
+ |
+namespace content { |
+ |
+class PowerMonitorBroadcastSource : public base::PowerMonitorSource { |
+ public: |
+ PowerMonitorBroadcastSource(); |
+ virtual ~PowerMonitorBroadcastSource(); |
+ |
+ IPC::ChannelProxy::MessageFilter* MessageFilter(); |
+ |
+ private: |
+ friend class PowerMonitorMessageFilter; |
+ |
+ class PowerMessageFilter : public IPC::ChannelProxy::MessageFilter { |
+ public: |
+ PowerMessageFilter(PowerMonitorBroadcastSource* source); |
+ |
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
+ |
+ private: |
+ friend class base::RefCounted<PowerMessageFilter>; |
+ |
+ virtual ~PowerMessageFilter(); |
+ |
+ void OnPowerStateChange(bool on_battery_power); |
+ void OnSuspend(); |
+ void OnResume(); |
+ |
+ PowerMonitorBroadcastSource* source_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(PowerMessageFilter); |
+ }; |
+ |
+ virtual bool IsBatteryPower() OVERRIDE; |
+ |
+ void OnPowerStateChange(bool on_battery_power); |
+ void OnSuspend(); |
+ void OnResume(); |
+ |
+ bool on_battery_power_; |
+ PowerMessageFilter* message_filter_; |
vandebo (ex-Chrome)
2013/06/26 21:40:33
scoped_ptr, or just direct member?
bajones
2013/06/26 22:37:22
See comments re: AddFilter()
|
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_COMMON_POWER_MONITOR_MESSAGE_FILTER_H_ |