Chromium Code Reviews| 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 |