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

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

Issue 1089523002: ScreenOrientationController: task-based dispatching of change events. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 8 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 | « Source/modules/screen_orientation/ScreenOrientationController.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/screen_orientation/ScreenOrientationController.cpp
diff --git a/Source/modules/screen_orientation/ScreenOrientationController.cpp b/Source/modules/screen_orientation/ScreenOrientationController.cpp
index 9ea7c471dd53915318dc6d82c784382414c527a7..0d0a0d0396143418cf56f3a977e499a0db74149f 100644
--- a/Source/modules/screen_orientation/ScreenOrientationController.cpp
+++ b/Source/modules/screen_orientation/ScreenOrientationController.cpp
@@ -5,6 +5,8 @@
#include "config.h"
#include "modules/screen_orientation/ScreenOrientationController.h"
+#include "core/dom/Document.h"
+#include "core/dom/ExecutionContextTask.h"
#include "core/events/Event.h"
#include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h"
@@ -38,7 +40,7 @@ ScreenOrientationController::ScreenOrientationController(LocalFrame& frame, WebS
: LocalFrameLifecycleObserver(&frame)
, PlatformEventController(frame.page())
, m_client(client)
- , m_dispatchEventTimer(this, &ScreenOrientationController::dispatchEventTimerFired)
+ , m_isDispatchingEvent(false)
{
}
@@ -135,8 +137,12 @@ void ScreenOrientationController::notifyOrientationChanged()
}
// Notify current orientation object.
- if (!m_dispatchEventTimer.isActive())
- m_dispatchEventTimer.startOneShot(0, FROM_HERE);
+ if (!m_isDispatchingEvent) {
+ if (Document* document = frame()->document()) {
+ document->postTask(FROM_HERE, createSameThreadTask(&ScreenOrientationController::dispatchChangeEvent, this));
alex clarke (OOO till 29th) 2015/04/15 09:27:32 FYI the blink scheduler team are thinking of addin
+ m_isDispatchingEvent = true;
+ }
+ }
// ... and child frames, if they have a ScreenOrientationController.
for (size_t i = 0; i < childFrames.size(); ++i) {
@@ -169,8 +175,9 @@ void ScreenOrientationController::unlock()
m_client->unlockOrientation();
}
-void ScreenOrientationController::dispatchEventTimerFired(Timer<ScreenOrientationController>*)
+void ScreenOrientationController::dispatchChangeEvent()
{
+ m_isDispatchingEvent = false;
if (!m_orientation)
return;
m_orientation->dispatchEvent(Event::create(EventTypeNames::change));
« no previous file with comments | « Source/modules/screen_orientation/ScreenOrientationController.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698