OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 18 matching lines...) Expand all Loading... |
29 */ | 29 */ |
30 | 30 |
31 #ifndef DeviceMotionDispatcher_h | 31 #ifndef DeviceMotionDispatcher_h |
32 #define DeviceMotionDispatcher_h | 32 #define DeviceMotionDispatcher_h |
33 | 33 |
34 #include "core/frame/PlatformEventDispatcher.h" | 34 #include "core/frame/PlatformEventDispatcher.h" |
35 #include "platform/heap/Handle.h" | 35 #include "platform/heap/Handle.h" |
36 #include "public/platform/modules/device_orientation/WebDeviceMotionListener.h" | 36 #include "public/platform/modules/device_orientation/WebDeviceMotionListener.h" |
37 #include "wtf/RefPtr.h" | 37 #include "wtf/RefPtr.h" |
38 | 38 |
| 39 namespace device { |
| 40 class MotionData; |
| 41 } |
| 42 |
39 namespace blink { | 43 namespace blink { |
40 | 44 |
41 class DeviceMotionData; | 45 class DeviceMotionData; |
42 class WebDeviceMotionData; | |
43 | 46 |
44 // This class listens to device motion data and notifies all registered | 47 // This class listens to device motion data and notifies all registered |
45 // controllers. | 48 // controllers. |
46 class DeviceMotionDispatcher final | 49 class DeviceMotionDispatcher final |
47 : public GarbageCollectedFinalized<DeviceMotionDispatcher>, | 50 : public GarbageCollectedFinalized<DeviceMotionDispatcher>, |
48 public PlatformEventDispatcher, | 51 public PlatformEventDispatcher, |
49 public WebDeviceMotionListener { | 52 public WebDeviceMotionListener { |
50 USING_GARBAGE_COLLECTED_MIXIN(DeviceMotionDispatcher); | 53 USING_GARBAGE_COLLECTED_MIXIN(DeviceMotionDispatcher); |
51 | 54 |
52 public: | 55 public: |
53 static DeviceMotionDispatcher& instance(); | 56 static DeviceMotionDispatcher& instance(); |
54 ~DeviceMotionDispatcher() override; | 57 ~DeviceMotionDispatcher() override; |
55 | 58 |
56 // Note that the returned object is owned by this class. | 59 // Note that the returned object is owned by this class. |
57 // FIXME: make the return value const, see crbug.com/233174. | 60 // FIXME: make the return value const, see crbug.com/233174. |
58 DeviceMotionData* latestDeviceMotionData(); | 61 DeviceMotionData* latestDeviceMotionData(); |
59 | 62 |
60 // Inherited from WebDeviceMotionListener. | 63 // Inherited from WebDeviceMotionListener. |
61 void didChangeDeviceMotion(const WebDeviceMotionData&) override; | 64 void didChangeDeviceMotion(const device::MotionData&) override; |
62 | 65 |
63 DECLARE_VIRTUAL_TRACE(); | 66 DECLARE_VIRTUAL_TRACE(); |
64 | 67 |
65 private: | 68 private: |
66 DeviceMotionDispatcher(); | 69 DeviceMotionDispatcher(); |
67 | 70 |
68 // Inherited from PlatformEventDispatcher. | 71 // Inherited from PlatformEventDispatcher. |
69 void startListening() override; | 72 void startListening() override; |
70 void stopListening() override; | 73 void stopListening() override; |
71 | 74 |
72 Member<DeviceMotionData> m_lastDeviceMotionData; | 75 Member<DeviceMotionData> m_lastDeviceMotionData; |
73 }; | 76 }; |
74 | 77 |
75 } // namespace blink | 78 } // namespace blink |
76 | 79 |
77 #endif // DeviceMotionDispatcher_h | 80 #endif // DeviceMotionDispatcher_h |
OLD | NEW |