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

Unified Diff: third_party/WebKit/Source/modules/device_orientation/DeviceOrientationAbsoluteDispatcher.cpp

Issue 1416123002: Absolute Device Orientation API: blink implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 2 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: third_party/WebKit/Source/modules/device_orientation/DeviceOrientationAbsoluteDispatcher.cpp
diff --git a/third_party/WebKit/Source/modules/device_orientation/DeviceOrientationAbsoluteDispatcher.cpp b/third_party/WebKit/Source/modules/device_orientation/DeviceOrientationAbsoluteDispatcher.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f6f2f56bc66d9a2272c2661249ea0f2585aab0ad
--- /dev/null
+++ b/third_party/WebKit/Source/modules/device_orientation/DeviceOrientationAbsoluteDispatcher.cpp
@@ -0,0 +1,56 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
Rick Byers 2015/10/21 18:54:46 Ditto on code duplication from DeviceOrientationDi
timvolodine 2015/10/22 15:06:28 Done.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "modules/device_orientation/DeviceOrientationAbsoluteDispatcher.h"
+
+#include "modules/device_orientation/DeviceOrientationAbsoluteController.h"
+#include "modules/device_orientation/DeviceOrientationData.h"
+#include "public/platform/Platform.h"
+
+namespace blink {
+
+DeviceOrientationAbsoluteDispatcher& DeviceOrientationAbsoluteDispatcher::instance()
+{
+ DEFINE_STATIC_LOCAL(Persistent<DeviceOrientationAbsoluteDispatcher>, deviceOrientationAbsoluteDispatcher, (new DeviceOrientationAbsoluteDispatcher()));
+ return *deviceOrientationAbsoluteDispatcher;
+}
+
+DeviceOrientationAbsoluteDispatcher::DeviceOrientationAbsoluteDispatcher()
+{
+}
+
+DeviceOrientationAbsoluteDispatcher::~DeviceOrientationAbsoluteDispatcher()
+{
+}
+
+DEFINE_TRACE(DeviceOrientationAbsoluteDispatcher)
+{
+ visitor->trace(m_lastDeviceOrientationData);
+ PlatformEventDispatcher::trace(visitor);
+}
+
+void DeviceOrientationAbsoluteDispatcher::startListening()
+{
+ Platform::current()->startListening(WebPlatformEventDeviceOrientationAbsolute, this);
+}
+
+void DeviceOrientationAbsoluteDispatcher::stopListening()
+{
+ Platform::current()->stopListening(WebPlatformEventDeviceOrientationAbsolute);
+ m_lastDeviceOrientationData.clear();
+}
+
+void DeviceOrientationAbsoluteDispatcher::didChangeDeviceOrientation(const WebDeviceOrientationData& motion)
+{
+ m_lastDeviceOrientationData = DeviceOrientationData::create(motion);
+ notifyControllers();
+}
+
+DeviceOrientationData* DeviceOrientationAbsoluteDispatcher::latestDeviceOrientationData()
+{
+ return m_lastDeviceOrientationData.get();
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698