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

Unified Diff: content/common/power_monitor_message_filter.cc

Issue 17074009: Created multi-process-friendly PowerMonitor interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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.cc
diff --git a/content/common/power_monitor_message_filter.cc b/content/common/power_monitor_message_filter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..caca4148a17e30c1c59ee8f3b0819ce50fa56c50
--- /dev/null
+++ b/content/common/power_monitor_message_filter.cc
@@ -0,0 +1,43 @@
+// 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.
+
+#include "content/common/power_monitor_message_filter.h"
+
+#include "content/common/power_monitor_client.h"
+#include "content/common/power_monitor_messages.h"
+
+namespace content {
+
+PowerMonitorMessageFilter::PowerMonitorMessageFilter()
+ : client_(PowerMonitorClient::Get()) {
+}
+
+PowerMonitorMessageFilter::~PowerMonitorMessageFilter() {
+}
+
+bool PowerMonitorMessageFilter::OnMessageReceived(const IPC::Message& message) {
+ bool msg_is_ok = true;
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP_EX(PowerMonitorMessageFilter, message, msg_is_ok)
+ IPC_MESSAGE_HANDLER(PowerMonitorMsg_PowerStateChange, OnPowerStateChange)
+ IPC_MESSAGE_HANDLER(PowerMonitorMsg_Suspend, OnSuspend)
+ IPC_MESSAGE_HANDLER(PowerMonitorMsg_Resume, OnResume)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP_EX()
+ return handled;
+}
+
+void PowerMonitorMessageFilter::OnPowerStateChange(bool on_battery_power) {
+ client_->NotifyPowerStateChange(on_battery_power);
+}
+
+void PowerMonitorMessageFilter::OnSuspend() {
+ client_->NotifySuspend();
+}
+
+void PowerMonitorMessageFilter::OnResume() {
+ client_->NotifyResume();
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698