Index: third_party/WebKit/public/platform/modules/device_orientation/WebDeviceMotionData.h |
diff --git a/third_party/WebKit/Source/modules/device_orientation/DeviceMotionDispatcher.h b/third_party/WebKit/public/platform/modules/device_orientation/WebDeviceMotionData.h |
similarity index 51% |
copy from third_party/WebKit/Source/modules/device_orientation/DeviceMotionDispatcher.h |
copy to third_party/WebKit/public/platform/modules/device_orientation/WebDeviceMotionData.h |
index 97b0f61fae8dde69e4fe428c28d509cde0463be5..ebce512e5bbf8c420ec8bffb2e2fa33c61469b8d 100644 |
--- a/third_party/WebKit/Source/modules/device_orientation/DeviceMotionDispatcher.h |
+++ b/third_party/WebKit/public/platform/modules/device_orientation/WebDeviceMotionData.h |
@@ -1,5 +1,5 @@ |
/* |
- * Copyright (C) 2013 Google Inc. All rights reserved. |
+ * Copyright (C) 2017 Google Inc. All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions are |
@@ -28,53 +28,60 @@ |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
-#ifndef DeviceMotionDispatcher_h |
-#define DeviceMotionDispatcher_h |
+#ifndef WebDeviceMotionData_h |
+#define WebDeviceMotionData_h |
-#include "core/frame/PlatformEventDispatcher.h" |
-#include "platform/heap/Handle.h" |
-#include "platform/wtf/RefPtr.h" |
-#include "public/platform/modules/device_orientation/WebDeviceMotionListener.h" |
- |
-namespace device { |
-class MotionData; |
-} |
+#include <string.h> |
namespace blink { |
-class DeviceMotionData; |
- |
-// This class listens to device motion data and notifies all registered |
-// controllers. |
-class DeviceMotionDispatcher final |
- : public GarbageCollectedFinalized<DeviceMotionDispatcher>, |
- public PlatformEventDispatcher, |
- public WebDeviceMotionListener { |
- USING_GARBAGE_COLLECTED_MIXIN(DeviceMotionDispatcher); |
+#pragma pack(push, 1) |
+class WebDeviceMotionData { |
public: |
- static DeviceMotionDispatcher& Instance(); |
- ~DeviceMotionDispatcher() override; |
+ WebDeviceMotionData() { |
+ // Make sure to zero out the memory so that there are no uninitialized bits. |
+ // This object is used in the shared memory buffer and is memory copied by |
+ // two processes. Valgrind will complain if we copy around memory that is |
+ // only partially initialized. |
+ memset(this, 0, sizeof(*this)); |
Reilly Grant (use Gerrit)
2017/05/19 20:20:11
This structure is no longer used for a shared buff
juncai
2017/05/20 00:55:02
Fixed it in a new CL:
https://codereview.chromium.
|
+ } |
+ WebDeviceMotionData(const WebDeviceMotionData& other) = default; |
+ ~WebDeviceMotionData() {} |
+ |
+ double acceleration_x; |
+ double acceleration_y; |
+ double acceleration_z; |
- // Note that the returned object is owned by this class. |
- // FIXME: make the return value const, see crbug.com/233174. |
- DeviceMotionData* LatestDeviceMotionData(); |
+ double acceleration_including_gravity_x; |
+ double acceleration_including_gravity_y; |
+ double acceleration_including_gravity_z; |
- // Inherited from WebDeviceMotionListener. |
- void DidChangeDeviceMotion(const device::MotionData&) override; |
+ double rotation_rate_alpha; |
+ double rotation_rate_beta; |
+ double rotation_rate_gamma; |
- DECLARE_VIRTUAL_TRACE(); |
+ double interval; |
- private: |
- DeviceMotionDispatcher(); |
+ bool has_acceleration_x : 1; |
+ bool has_acceleration_y : 1; |
+ bool has_acceleration_z : 1; |
- // Inherited from PlatformEventDispatcher. |
- void StartListening() override; |
- void StopListening() override; |
+ bool has_acceleration_including_gravity_x : 1; |
+ bool has_acceleration_including_gravity_y : 1; |
+ bool has_acceleration_including_gravity_z : 1; |
- Member<DeviceMotionData> last_device_motion_data_; |
+ bool has_rotation_rate_alpha : 1; |
+ bool has_rotation_rate_beta : 1; |
+ bool has_rotation_rate_gamma : 1; |
}; |
+static_assert(sizeof(WebDeviceMotionData) == |
+ (10 * sizeof(double) + 2 * sizeof(char)), |
+ "WebDeviceMotionData has wrong size"); |
+ |
+#pragma pack(pop) |
+ |
} // namespace blink |
-#endif // DeviceMotionDispatcher_h |
+#endif // WebDeviceMotionData_h |