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

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

Issue 1190293002: Have ScreenOrientationController use a timer for async event dispatch again (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add clarifying comment to test Created 5 years, 6 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 740ee7569069062affffba763454fb9425d9b38a..0820474f073e7db10f66ec4a4058887cf10b4a33 100644
--- a/Source/modules/screen_orientation/ScreenOrientationController.cpp
+++ b/Source/modules/screen_orientation/ScreenOrientationController.cpp
@@ -5,8 +5,6 @@
#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/FrameHost.h"
#include "core/frame/FrameView.h"
@@ -42,7 +40,7 @@ ScreenOrientationController::ScreenOrientationController(LocalFrame& frame, WebS
: LocalFrameLifecycleObserver(&frame)
, PlatformEventController(frame.page())
, m_client(client)
- , m_isDispatchingEvent(false)
+ , m_dispatchEventTimer(this, &ScreenOrientationController::dispatchEventTimerFired)
{
}
@@ -140,12 +138,8 @@ void ScreenOrientationController::notifyOrientationChanged()
}
// Notify current orientation object.
- if (!m_isDispatchingEvent) {
- if (Document* document = frame()->document()) {
- document->postTask(FROM_HERE, createSameThreadTask(&ScreenOrientationController::dispatchChangeEvent, this));
- m_isDispatchingEvent = true;
- }
- }
+ if (!m_dispatchEventTimer.isActive())
+ m_dispatchEventTimer.startOneShot(0, FROM_HERE);
haraken 2015/06/19 11:04:15 Would you help me understand why the new code is s
sof 2015/06/19 11:08:27 This controller owns the timer, so it'll be finali
haraken 2015/06/19 11:11:40 Ah, makes sense. LGTM.
// ... and child frames, if they have a ScreenOrientationController.
for (size_t i = 0; i < childFrames.size(); ++i) {
@@ -178,9 +172,8 @@ void ScreenOrientationController::unlock()
m_client->unlockOrientation();
}
-void ScreenOrientationController::dispatchChangeEvent()
+void ScreenOrientationController::dispatchEventTimerFired(Timer<ScreenOrientationController>*)
{
- 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