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 "config.h" | |
6 #include "modules/device_light/DeviceLightDispatcher.h" | |
7 | |
8 #include "modules/device_light/DeviceLightController.h" | |
9 #include "modules/device_orientation/DeviceSensorEventDispatcher.h" | |
10 #include "public/platform/Platform.h" | |
11 #include "wtf/TemporaryChange.h" | |
12 | |
13 namespace WebCore { | |
14 | |
15 DeviceLightDispatcher& DeviceLightDispatcher::instance() | |
16 { | |
17 DEFINE_STATIC_LOCAL(DeviceLightDispatcher, deviceLightDispatcher, ()); | |
18 return deviceLightDispatcher; | |
19 } | |
20 | |
21 DeviceLightDispatcher::DeviceLightDispatcher() | |
22 { | |
23 } | |
24 | |
25 DeviceLightDispatcher::~DeviceLightDispatcher() | |
26 { | |
27 } | |
28 | |
29 | |
30 void DeviceLightDispatcher::addDeviceLightController(DeviceLightController* cont roller) | |
31 { | |
32 addController(controller); | |
33 } | |
34 | |
35 void DeviceLightDispatcher::removeDeviceLightController(DeviceLightController* c ontroller) | |
36 { | |
37 removeController(controller); | |
38 } | |
39 | |
40 void DeviceLightDispatcher::startListening() | |
41 { | |
42 blink::Platform::current()->setDeviceLightListener(this); | |
43 } | |
44 | |
45 void DeviceLightDispatcher::stopListening() | |
46 { | |
47 blink::Platform::current()->setDeviceLightListener(0); | |
48 } | |
49 | |
50 void DeviceLightDispatcher::didChangeDeviceLight(const double& value) | |
51 { | |
52 m_lastDeviceLightData = value; | |
53 | |
54 { | |
55 TemporaryChange<bool> changeIsDispatching(m_isDispatching, true); | |
56 // Don't fire controllers removed or added during event dispatch. | |
57 size_t size = m_controllers.size(); | |
58 for (size_t i = 0; i < size; ++i) { | |
59 if (m_controllers[i]) | |
60 static_cast<DeviceLightController*>(m_controllers[i])->didChange DeviceLight(m_lastDeviceLightData); | |
61 } | |
62 } | |
63 | |
64 if (m_needsPurge) | |
65 purgeControllers(); | |
66 } | |
67 | |
68 double DeviceLightDispatcher::latestDeviceLightData() | |
Inactive
2014/03/07 19:29:52
can be const
riju_
2014/03/10 16:17:26
On Mac try bot it showed -> error: 'const' type qu
| |
69 { | |
70 return m_lastDeviceLightData; | |
71 } | |
72 | |
73 } // namespace WebCore | |
OLD | NEW |