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 "platform/wtf/RefPtr.h" | 36 #include "platform/wtf/RefPtr.h" |
37 #include "public/platform/modules/device_orientation/WebDeviceMotionListener.h" | 37 #include "public/platform/modules/device_orientation/WebDeviceMotionListener.h" |
38 | 38 |
39 namespace device { | |
40 class MotionData; | |
41 } | |
42 | |
43 namespace blink { | 39 namespace blink { |
44 | 40 |
45 class DeviceMotionData; | 41 class DeviceMotionData; |
| 42 class WebDeviceMotionData; |
46 | 43 |
47 // This class listens to device motion data and notifies all registered | 44 // This class listens to device motion data and notifies all registered |
48 // controllers. | 45 // controllers. |
49 class DeviceMotionDispatcher final | 46 class DeviceMotionDispatcher final |
50 : public GarbageCollectedFinalized<DeviceMotionDispatcher>, | 47 : public GarbageCollectedFinalized<DeviceMotionDispatcher>, |
51 public PlatformEventDispatcher, | 48 public PlatformEventDispatcher, |
52 public WebDeviceMotionListener { | 49 public WebDeviceMotionListener { |
53 USING_GARBAGE_COLLECTED_MIXIN(DeviceMotionDispatcher); | 50 USING_GARBAGE_COLLECTED_MIXIN(DeviceMotionDispatcher); |
54 | 51 |
55 public: | 52 public: |
56 static DeviceMotionDispatcher& Instance(); | 53 static DeviceMotionDispatcher& Instance(); |
57 ~DeviceMotionDispatcher() override; | 54 ~DeviceMotionDispatcher() override; |
58 | 55 |
59 // Note that the returned object is owned by this class. | 56 // Note that the returned object is owned by this class. |
60 // FIXME: make the return value const, see crbug.com/233174. | 57 // FIXME: make the return value const, see crbug.com/233174. |
61 DeviceMotionData* LatestDeviceMotionData(); | 58 DeviceMotionData* LatestDeviceMotionData(); |
62 | 59 |
63 // Inherited from WebDeviceMotionListener. | 60 // Inherited from WebDeviceMotionListener. |
64 void DidChangeDeviceMotion(const device::MotionData&) override; | 61 void DidChangeDeviceMotion(const WebDeviceMotionData&) override; |
65 | 62 |
66 DECLARE_VIRTUAL_TRACE(); | 63 DECLARE_VIRTUAL_TRACE(); |
67 | 64 |
68 private: | 65 private: |
69 DeviceMotionDispatcher(); | 66 DeviceMotionDispatcher(); |
70 | 67 |
71 // Inherited from PlatformEventDispatcher. | 68 // Inherited from PlatformEventDispatcher. |
72 void StartListening() override; | 69 void StartListening() override; |
73 void StopListening() override; | 70 void StopListening() override; |
74 | 71 |
75 Member<DeviceMotionData> last_device_motion_data_; | 72 Member<DeviceMotionData> last_device_motion_data_; |
76 }; | 73 }; |
77 | 74 |
78 } // namespace blink | 75 } // namespace blink |
79 | 76 |
80 #endif // DeviceMotionDispatcher_h | 77 #endif // DeviceMotionDispatcher_h |
OLD | NEW |