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

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

Issue 2578503002: [DeviceService] Mojofy left screen orientation IPC messages. (Closed)
Patch Set: Address nits from blundell@ Created 4 years 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_listener_android.cc
diff --git a/content/browser/screen_orientation/screen_orientation_listener_android.cc b/content/browser/screen_orientation/screen_orientation_listener_android.cc
new file mode 100644
index 0000000000000000000000000000000000000000..850e89e5b9fb509d99fb202917a7658d8337794a
--- /dev/null
+++ b/content/browser/screen_orientation/screen_orientation_listener_android.cc
@@ -0,0 +1,46 @@
+// 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_listener_android.h"
+
+#include "base/message_loop/message_loop.h"
+#include "content/browser/screen_orientation/screen_orientation_delegate_android.h"
+#include "content/common/screen_orientation_messages.h"
+
+namespace content {
+
+ScreenOrientationListenerAndroid::ScreenOrientationListenerAndroid()
+ : BrowserMessageFilter(ScreenOrientationMsgStart),
+ BrowserAssociatedInterface<device::mojom::ScreenOrientationListener>(
+ this,
+ this),
+ listeners_count_(0) {}
+
+ScreenOrientationListenerAndroid::~ScreenOrientationListenerAndroid() {
+ DCHECK(base::MessageLoopForIO::IsCurrent());
+ if (listeners_count_ > 0)
+ ScreenOrientationDelegateAndroid::StopAccurateListening();
+}
+
+bool ScreenOrientationListenerAndroid::OnMessageReceived(
+ const IPC::Message& message) {
+ return false;
+}
+
+void ScreenOrientationListenerAndroid::Start() {
+ DCHECK(base::MessageLoopForIO::IsCurrent());
+ ++listeners_count_;
+ if (listeners_count_ == 1)
+ ScreenOrientationDelegateAndroid::StartAccurateListening();
+}
+
+void ScreenOrientationListenerAndroid::Stop() {
+ DCHECK(base::MessageLoopForIO::IsCurrent());
+ DCHECK(listeners_count_ > 0);
+ --listeners_count_;
+ if (listeners_count_ == 0)
+ ScreenOrientationDelegateAndroid::StopAccurateListening();
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698