OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef DeviceLightDispatcher_h | 5 #ifndef DeviceLightDispatcher_h |
6 #define DeviceLightDispatcher_h | 6 #define DeviceLightDispatcher_h |
7 | 7 |
8 #include "core/frame/DeviceSensorEventDispatcher.h" | 8 #include "core/frame/DeviceEventDispatcherBase.h" |
9 #include "public/platform/WebDeviceLightListener.h" | 9 #include "public/platform/WebDeviceLightListener.h" |
10 #include "wtf/RefPtr.h" | 10 #include "wtf/RefPtr.h" |
11 | 11 |
12 namespace WebCore { | 12 namespace WebCore { |
13 | 13 |
14 class DeviceLightController; | 14 class DeviceLightController; |
15 | 15 |
16 // This class listens to device light data and dispatches it to all | 16 // This class listens to device light data and notifies all registered controlle
rs. |
17 // listening controllers | 17 class DeviceLightDispatcher FINAL : public DeviceEventDispatcherBase, public bli
nk::WebDeviceLightListener { |
18 class DeviceLightDispatcher FINAL : public DeviceSensorEventDispatcher, public b
link::WebDeviceLightListener { | |
19 public: | 18 public: |
20 static DeviceLightDispatcher& instance(); | 19 static DeviceLightDispatcher& instance(); |
21 | 20 |
22 double latestDeviceLightData() const; | 21 double latestDeviceLightData() const; |
23 | 22 |
24 // This method is called every time new device light data is available. | 23 // Inherited from WebDeviceLightListener. |
25 virtual void didChangeDeviceLight(double) OVERRIDE; | 24 virtual void didChangeDeviceLight(double) OVERRIDE; |
26 void addDeviceLightController(DeviceLightController*); | |
27 void removeDeviceLightController(DeviceLightController*); | |
28 | 25 |
29 private: | 26 private: |
30 DeviceLightDispatcher(); | 27 DeviceLightDispatcher(); |
31 virtual ~DeviceLightDispatcher(); | 28 virtual ~DeviceLightDispatcher(); |
32 | 29 |
| 30 // Inherited from DeviceEventDispatcherBase. |
33 virtual void startListening() OVERRIDE; | 31 virtual void startListening() OVERRIDE; |
34 virtual void stopListening() OVERRIDE; | 32 virtual void stopListening() OVERRIDE; |
35 | 33 |
36 double m_lastDeviceLightData; | 34 double m_lastDeviceLightData; |
37 }; | 35 }; |
38 | 36 |
39 } // namespace WebCore | 37 } // namespace WebCore |
40 | 38 |
41 #endif // DeviceLightDispatcher_h | 39 #endif // DeviceLightDispatcher_h |
OLD | NEW |