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

Unified Diff: content/browser/screen_orientation/screen_orientation_message_filter_android.cc

Issue 398013002: Poll for Display rotation on Android 4.0 and 4.1 when needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: call ScreenOrientationListener on UI thread Created 6 years, 4 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/browser/screen_orientation/screen_orientation_message_filter_android.cc
diff --git a/content/browser/screen_orientation/screen_orientation_message_filter_android.cc b/content/browser/screen_orientation/screen_orientation_message_filter_android.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3a7831b2df03891b929ea0f22d997a658260f3cd
--- /dev/null
+++ b/content/browser/screen_orientation/screen_orientation_message_filter_android.cc
@@ -0,0 +1,49 @@
+// Copyright 2014 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/browser/screen_orientation/screen_orientation_message_filter_android.h"
+
+#include "content/browser/screen_orientation/screen_orientation_provider_android.h"
+#include "content/common/screen_orientation_messages.h"
+
+namespace content {
+
+ScreenOrientationMessageFilterAndroid::ScreenOrientationMessageFilterAndroid()
+ : BrowserMessageFilter(ScreenOrientationMsgStart)
+ , listeners_count_(0) {
+}
+
+ScreenOrientationMessageFilterAndroid::~ScreenOrientationMessageFilterAndroid()
+{
+ if (listeners_count_ > 0)
+ ScreenOrientationProviderAndroid::StopAccurateListening();
+}
+
+bool ScreenOrientationMessageFilterAndroid::OnMessageReceived(
+ const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(ScreenOrientationMessageFilterAndroid, message)
+ IPC_MESSAGE_HANDLER(ScreenOrientationHostMsg_StartListening,
+ OnStartListening)
+ IPC_MESSAGE_HANDLER(ScreenOrientationHostMsg_StopListening,
+ OnStopListening)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void ScreenOrientationMessageFilterAndroid::OnStartListening() {
+ ++listeners_count_;
+ if (listeners_count_ == 1)
+ ScreenOrientationProviderAndroid::StartAccurateListening();
+}
+
+void ScreenOrientationMessageFilterAndroid::OnStopListening() {
+ DCHECK(listeners_count_ > 0);
+ --listeners_count_;
+ if (listeners_count_ == 0)
+ ScreenOrientationProviderAndroid::StopAccurateListening();
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698