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

Unified Diff: third_party/WebKit/Source/modules/device_orientation/DeviceOrientationDispatcher.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/DeviceOrientationDispatcher.cpp
diff --git a/third_party/WebKit/Source/modules/device_orientation/DeviceOrientationDispatcher.cpp b/third_party/WebKit/Source/modules/device_orientation/DeviceOrientationDispatcher.cpp
index bc997d8ed10ca7c0df767df68fb103c5d4dfd657..7b62cfe52f0dff7da26985c3946ef5f3abfc089f 100644
--- a/third_party/WebKit/Source/modules/device_orientation/DeviceOrientationDispatcher.cpp
+++ b/third_party/WebKit/Source/modules/device_orientation/DeviceOrientationDispatcher.cpp
@@ -35,15 +35,32 @@
#include "modules/device_orientation/DeviceOrientationData.h"
#include "public/platform/Platform.h"
+namespace {
+
+blink::WebPlatformEventType getWebPlatformEventType(bool absolute)
Rick Byers 2015/10/22 16:00:52 nit: make this a private const method of the class
timvolodine 2015/10/27 16:38:35 Done.
+{
+ return (absolute) ? blink::WebPlatformEventTypeDeviceOrientationAbsolute : blink::WebPlatformEventTypeDeviceOrientation;
+}
+
+} // namespace
+
namespace blink {
-DeviceOrientationDispatcher& DeviceOrientationDispatcher::instance()
+template<>
+DeviceOrientationDispatcher& DeviceOrientationDispatcher::instance<true>()
+{
+ DEFINE_STATIC_LOCAL(Persistent<DeviceOrientationDispatcher>, deviceOrientationAbsoluteDispatcher, (new DeviceOrientationDispatcher(true)));
Rick Byers 2015/10/22 16:00:52 rather than use template specialization here, woul
timvolodine 2015/10/27 16:38:35 yes, looks like using a template is a bit of overk
+ return *deviceOrientationAbsoluteDispatcher;
+}
+
+template<>
+DeviceOrientationDispatcher& DeviceOrientationDispatcher::instance<false>()
{
- DEFINE_STATIC_LOCAL(Persistent<DeviceOrientationDispatcher>, deviceOrientationDispatcher, (new DeviceOrientationDispatcher()));
+ DEFINE_STATIC_LOCAL(Persistent<DeviceOrientationDispatcher>, deviceOrientationDispatcher, (new DeviceOrientationDispatcher(false)));
return *deviceOrientationDispatcher;
}
-DeviceOrientationDispatcher::DeviceOrientationDispatcher()
+DeviceOrientationDispatcher::DeviceOrientationDispatcher(bool absolute) : m_absolute(absolute)
{
}
@@ -59,12 +76,12 @@ DEFINE_TRACE(DeviceOrientationDispatcher)
void DeviceOrientationDispatcher::startListening()
{
- Platform::current()->startListening(WebPlatformEventTypeDeviceOrientation, this);
+ Platform::current()->startListening(getWebPlatformEventType(m_absolute), this);
}
void DeviceOrientationDispatcher::stopListening()
{
- Platform::current()->stopListening(WebPlatformEventTypeDeviceOrientation);
+ Platform::current()->stopListening(getWebPlatformEventType(m_absolute));
m_lastDeviceOrientationData.clear();
}

Powered by Google App Engine
This is Rietveld 408576698