Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1046)

Unified Diff: content/common/power_monitor_message_filter.h

Issue 17074009: Created multi-process-friendly PowerMonitor interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Uber-refactor Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_

Powered by Google App Engine
This is Rietveld 408576698