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

Unified Diff: Source/modules/device_orientation/DeviceMotionDispatcher.cpp

Issue 315023006: Revert of Generalize and refactor DeviceSensorEvent* architecture to support multi-event type targets. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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
Index: Source/modules/device_orientation/DeviceMotionDispatcher.cpp
diff --git a/Source/modules/device_orientation/DeviceMotionDispatcher.cpp b/Source/modules/device_orientation/DeviceMotionDispatcher.cpp
index de89684be386bcc2324134d2d1b1645c43024180..00efc88d654af576347692862def7ad2b7359c9c 100644
--- a/Source/modules/device_orientation/DeviceMotionDispatcher.cpp
+++ b/Source/modules/device_orientation/DeviceMotionDispatcher.cpp
@@ -34,6 +34,7 @@
#include "modules/device_orientation/DeviceMotionController.h"
#include "modules/device_orientation/DeviceMotionData.h"
#include "public/platform/Platform.h"
+#include "wtf/TemporaryChange.h"
namespace WebCore {
@@ -51,6 +52,16 @@
{
}
+void DeviceMotionDispatcher::addDeviceMotionController(DeviceMotionController* controller)
+{
+ addController(controller);
+}
+
+void DeviceMotionDispatcher::removeDeviceMotionController(DeviceMotionController* controller)
+{
+ removeController(controller);
+}
+
void DeviceMotionDispatcher::startListening()
{
blink::Platform::current()->setDeviceMotionListener(this);
@@ -65,7 +76,19 @@
void DeviceMotionDispatcher::didChangeDeviceMotion(const blink::WebDeviceMotionData& motion)
{
m_lastDeviceMotionData = DeviceMotionData::create(motion);
- notifyControllers();
+
+ {
+ TemporaryChange<bool> changeIsDispatching(m_isDispatching, true);
+ // Don't fire controllers removed or added during event dispatch.
+ size_t size = m_controllers.size();
+ for (size_t i = 0; i < size; ++i) {
+ if (m_controllers[i])
+ static_cast<DeviceMotionController*>(m_controllers[i])->didChangeDeviceMotion(m_lastDeviceMotionData.get());
+ }
+ }
+
+ if (m_needsPurge)
+ purgeControllers();
}
DeviceMotionData* DeviceMotionDispatcher::latestDeviceMotionData()

Powered by Google App Engine
This is Rietveld 408576698