OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2017 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 |
11 * copyright notice, this list of conditions and the following disclaimer | 11 * copyright notice, this list of conditions and the following disclaimer |
12 * in the documentation and/or other materials provided with the | 12 * in the documentation and/or other materials provided with the |
13 * distribution. | 13 * distribution. |
14 * * Neither the name of Google Inc. nor the names of its | 14 * * Neither the name of Google Inc. nor the names of its |
15 * contributors may be used to endorse or promote products derived from | 15 * contributors may be used to endorse or promote products derived from |
16 * this software without specific prior written permission. | 16 * this software without specific prior written permission. |
17 * | 17 * |
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef DeviceMotionDispatcher_h | 31 #ifndef WebDeviceMotionData_h |
32 #define DeviceMotionDispatcher_h | 32 #define WebDeviceMotionData_h |
33 | 33 |
34 #include "core/frame/PlatformEventDispatcher.h" | 34 #include <string.h> |
35 #include "platform/heap/Handle.h" | |
36 #include "platform/wtf/RefPtr.h" | |
37 #include "public/platform/modules/device_orientation/WebDeviceMotionListener.h" | |
38 | |
39 namespace device { | |
40 class MotionData; | |
timvolodine
2017/05/23 12:33:40
I think this was introduced previously to get rid
juncai
2017/05/23 21:33:55
Since the //device/sensors directory will be remov
timvolodine
2017/05/24 15:30:16
The WebDevice*Data classes were explicitly removed
juncai
2017/05/26 02:38:53
These POD definitions will eventually be removed w
| |
41 } | |
42 | 35 |
43 namespace blink { | 36 namespace blink { |
44 | 37 |
45 class DeviceMotionData; | 38 class WebDeviceMotionData { |
39 public: | |
40 WebDeviceMotionData() | |
41 : has_acceleration_x(false), | |
42 has_acceleration_y(false), | |
43 has_acceleration_z(false), | |
44 has_acceleration_including_gravity_x(false), | |
45 has_acceleration_including_gravity_y(false), | |
46 has_acceleration_including_gravity_z(false), | |
47 has_rotation_rate_alpha(false), | |
48 has_rotation_rate_beta(false), | |
49 has_rotation_rate_gamma(false) {} | |
50 WebDeviceMotionData(const WebDeviceMotionData& other) = default; | |
51 ~WebDeviceMotionData() {} | |
46 | 52 |
47 // This class listens to device motion data and notifies all registered | 53 double acceleration_x; |
48 // controllers. | 54 double acceleration_y; |
49 class DeviceMotionDispatcher final | 55 double acceleration_z; |
50 : public GarbageCollectedFinalized<DeviceMotionDispatcher>, | |
51 public PlatformEventDispatcher, | |
52 public WebDeviceMotionListener { | |
53 USING_GARBAGE_COLLECTED_MIXIN(DeviceMotionDispatcher); | |
54 | 56 |
55 public: | 57 double acceleration_including_gravity_x; |
56 static DeviceMotionDispatcher& Instance(); | 58 double acceleration_including_gravity_y; |
57 ~DeviceMotionDispatcher() override; | 59 double acceleration_including_gravity_z; |
58 | 60 |
59 // Note that the returned object is owned by this class. | 61 double rotation_rate_alpha; |
60 // FIXME: make the return value const, see crbug.com/233174. | 62 double rotation_rate_beta; |
61 DeviceMotionData* LatestDeviceMotionData(); | 63 double rotation_rate_gamma; |
62 | 64 |
63 // Inherited from WebDeviceMotionListener. | 65 double interval; |
64 void DidChangeDeviceMotion(const device::MotionData&) override; | |
65 | 66 |
66 DECLARE_VIRTUAL_TRACE(); | 67 bool has_acceleration_x : 1; |
68 bool has_acceleration_y : 1; | |
69 bool has_acceleration_z : 1; | |
67 | 70 |
68 private: | 71 bool has_acceleration_including_gravity_x : 1; |
69 DeviceMotionDispatcher(); | 72 bool has_acceleration_including_gravity_y : 1; |
73 bool has_acceleration_including_gravity_z : 1; | |
70 | 74 |
71 // Inherited from PlatformEventDispatcher. | 75 bool has_rotation_rate_alpha : 1; |
72 void StartListening() override; | 76 bool has_rotation_rate_beta : 1; |
73 void StopListening() override; | 77 bool has_rotation_rate_gamma : 1; |
74 | |
75 Member<DeviceMotionData> last_device_motion_data_; | |
76 }; | 78 }; |
77 | 79 |
78 } // namespace blink | 80 } // namespace blink |
79 | 81 |
80 #endif // DeviceMotionDispatcher_h | 82 #endif // WebDeviceMotionData_h |
OLD | NEW |