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

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

Issue 2688383002: [ScreenOrientation] Merge mojo interface ScreenOrientationListener into ScreenOrientation
Patch Set: Address comments from mlamouri@ Created 3 years, 10 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
« no previous file with comments | « content/browser/screen_orientation/screen_orientation_provider.h ('k') | content/renderer/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/screen_orientation/screen_orientation_provider.cc
diff --git a/content/browser/screen_orientation/screen_orientation_provider.cc b/content/browser/screen_orientation/screen_orientation_provider.cc
index 1ab00dfa12866d15c41d0cb815ce0091f08d72af..4fa0cfa110a3e8501353867fabfa2e662ba8fdc7 100644
--- a/content/browser/screen_orientation/screen_orientation_provider.cc
+++ b/content/browser/screen_orientation/screen_orientation_provider.cc
@@ -13,6 +13,10 @@
#include "content/public/browser/web_contents.h"
#include "third_party/WebKit/public/platform/modules/screen_orientation/WebLockOrientationError.h"
+#if defined(OS_ANDROID)
+#include "content/browser/screen_orientation/screen_orientation_delegate_android.h"
+#endif
+
namespace content {
using device::mojom::ScreenOrientationLockResult;
@@ -24,7 +28,12 @@ ScreenOrientationProvider::ScreenOrientationProvider(WebContents* web_contents)
lock_applied_(false),
bindings_(web_contents, this) {}
-ScreenOrientationProvider::~ScreenOrientationProvider() = default;
+ScreenOrientationProvider::~ScreenOrientationProvider() {
+#if defined(OS_ANDROID)
+ if (accurate_listener_count_ > 0)
+ ScreenOrientationDelegateAndroid::StopAccurateListening();
+#endif
+}
void ScreenOrientationProvider::LockOrientation(
blink::WebScreenOrientationLockType orientation,
@@ -95,6 +104,23 @@ void ScreenOrientationProvider::UnlockOrientation() {
lock_applied_ = false;
}
+void ScreenOrientationProvider::StartAccurateListen() {
+#if defined(OS_ANDROID)
+ ++accurate_listener_count_;
+ if (accurate_listener_count_ == 1)
+ ScreenOrientationDelegateAndroid::StartAccurateListening();
+#endif
+}
+
+void ScreenOrientationProvider::StopAccurateListen() {
+#if defined(OS_ANDROID)
+ DCHECK(accurate_listener_count_ > 0);
+ --accurate_listener_count_;
+ if (accurate_listener_count_ == 0)
+ ScreenOrientationDelegateAndroid::StopAccurateListening();
+#endif
+}
+
void ScreenOrientationProvider::OnOrientationChange() {
if (!pending_lock_orientation_.has_value())
return;
« no previous file with comments | « content/browser/screen_orientation/screen_orientation_provider.h ('k') | content/renderer/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698