| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "modules/device_light/DeviceLightDispatcher.h" | |
| 6 | |
| 7 #include "modules/device_light/DeviceLightController.h" | |
| 8 #include "public/platform/Platform.h" | |
| 9 | |
| 10 namespace blink { | |
| 11 | |
| 12 DeviceLightDispatcher& DeviceLightDispatcher::instance() { | |
| 13 DEFINE_STATIC_LOCAL(DeviceLightDispatcher, deviceLightDispatcher, | |
| 14 (new DeviceLightDispatcher)); | |
| 15 return deviceLightDispatcher; | |
| 16 } | |
| 17 | |
| 18 DeviceLightDispatcher::DeviceLightDispatcher() : m_lastDeviceLightData(-1) {} | |
| 19 | |
| 20 DeviceLightDispatcher::~DeviceLightDispatcher() {} | |
| 21 | |
| 22 DEFINE_TRACE(DeviceLightDispatcher) { | |
| 23 PlatformEventDispatcher::trace(visitor); | |
| 24 } | |
| 25 | |
| 26 void DeviceLightDispatcher::startListening() { | |
| 27 Platform::current()->startListening(WebPlatformEventTypeDeviceLight, this); | |
| 28 } | |
| 29 | |
| 30 void DeviceLightDispatcher::stopListening() { | |
| 31 Platform::current()->stopListening(WebPlatformEventTypeDeviceLight); | |
| 32 m_lastDeviceLightData = -1; | |
| 33 } | |
| 34 | |
| 35 void DeviceLightDispatcher::didChangeDeviceLight(double value) { | |
| 36 m_lastDeviceLightData = value; | |
| 37 notifyControllers(); | |
| 38 } | |
| 39 | |
| 40 double DeviceLightDispatcher::latestDeviceLightData() const { | |
| 41 return m_lastDeviceLightData; | |
| 42 } | |
| 43 | |
| 44 } // namespace blink | |
| OLD | NEW |