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

Unified Diff: Source/modules/screen_orientation/ScreenOrientationController.cpp

Issue 419643008: Make Screen Orientation use Platform Events in order to handle polling. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@platform_events
Patch Set: rebase Created 6 years, 5 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: Source/modules/screen_orientation/ScreenOrientationController.cpp
diff --git a/Source/modules/screen_orientation/ScreenOrientationController.cpp b/Source/modules/screen_orientation/ScreenOrientationController.cpp
index bc0564bc05c15bace8d11c0b2622735bd1faaa26..b469dd755d273671e64b9cd4e331ef4d479ccee1 100644
--- a/Source/modules/screen_orientation/ScreenOrientationController.cpp
+++ b/Source/modules/screen_orientation/ScreenOrientationController.cpp
@@ -10,6 +10,7 @@
#include "core/frame/LocalFrame.h"
#include "core/page/Page.h"
#include "modules/screen_orientation/ScreenOrientation.h"
+#include "modules/screen_orientation/ScreenOrientationDispatcher.h"
#include "platform/LayoutTestSupport.h"
#include "platform/PlatformScreen.h"
#include "public/platform/WebScreenOrientationClient.h"
@@ -40,7 +41,7 @@ ScreenOrientationController* ScreenOrientationController::from(LocalFrame& frame
}
ScreenOrientationController::ScreenOrientationController(LocalFrame& frame, blink::WebScreenOrientationClient* client)
- : PageLifecycleObserver(frame.page())
+ : PlatformEventController(frame.page())
, m_client(client)
, m_frame(frame)
, m_dispatchEventTimer(this, &ScreenOrientationController::dispatchEventTimerFired)
@@ -96,6 +97,8 @@ void ScreenOrientationController::updateOrientation()
void ScreenOrientationController::pageVisibilityChanged()
{
+ notifyDispatcher();
+
if (!m_orientation || !page() || page()->visibilityState() != PageVisibilityStateVisible)
return;
@@ -147,6 +150,7 @@ void ScreenOrientationController::setOrientation(ScreenOrientation* orientation)
m_orientation = orientation;
if (m_orientation)
updateOrientation();
+ notifyDispatcher();
}
void ScreenOrientationController::lock(blink::WebScreenOrientationLockType orientation, blink::WebLockOrientationCallback* callback)
@@ -173,6 +177,34 @@ void ScreenOrientationController::dispatchEventTimerFired(Timer<ScreenOrientatio
m_orientation->dispatchEvent(Event::create(EventTypeNames::change));
}
+void ScreenOrientationController::didUpdateData()
+{
+ // Do nothing.
+}
+
+void ScreenOrientationController::registerWithDispatcher()
+{
+ ScreenOrientationDispatcher::instance().addController(this);
+}
+
+void ScreenOrientationController::unregisterWithDispatcher()
+{
+ ScreenOrientationDispatcher::instance().removeController(this);
+}
+
+bool ScreenOrientationController::hasLastData()
+{
+ return true;
+}
+
+void ScreenOrientationController::notifyDispatcher()
+{
+ if (m_orientation && page()->visibilityState() == PageVisibilityStateVisible)
+ startUpdating();
+ else
+ stopUpdating();
+}
+
void ScreenOrientationController::trace(Visitor* visitor)
{
visitor->trace(m_orientation);

Powered by Google App Engine
This is Rietveld 408576698