Index: content/browser/device_orientation/motion.h |
diff --git a/content/browser/device_orientation/motion.h b/content/browser/device_orientation/motion.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4dbc5d96bc09f4097dc59c39953e01c285158f14 |
--- /dev/null |
+++ b/content/browser/device_orientation/motion.h |
@@ -0,0 +1,161 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_BROWSER_DEVICE_ORIENTATION_MOTION_H_ |
+#define CONTENT_BROWSER_DEVICE_ORIENTATION_MOTION_H_ |
+ |
+namespace device_orientation { |
+class Motion { |
+ public: |
+ // acceleration_x, acceleration_y, and acceleration_z are the accelerations |
+ // excluding gravity along the axes specified in |
+ // http://dev.w3.org/geo/api/spec-source-orientation.html |
+ |
+ // acceleration_including_gravity_x, acceleration_including_gravity_y, and |
+ // acceleration_including_gravity_z are the accelerations including gravity |
+ // along the same axes as above |
+ |
+ // rotation_rate_alpha, rotation_rate_beta, and rotataion_rate_gamma are the |
+ // rotations around the same axes as above |
+ |
+ // interval is the time interval at which data is obtained from the hardware, |
+ // as specified in the document referenced above |
+ |
+ // can_provide_{acceleration_x, acceleration_y, acceleration_z, |
+ // acceleration_including_gravity_x, acceleration_including_gravity_y, |
+ // acceleration_including_gravity_z, rotation_rate_alpha, rotation_rate_beta, |
+ // rotation_rate_gamma, interval} is true if data can be provided for that |
+ // variable |
+ |
+ Motion(); |
+ Motion(const Motion&); |
bulach
2012/07/02 12:47:56
is this copy constructor necessary? if possible, i
aousterh
2012/07/04 13:31:55
The copy constructor is used in device_orientation
|
+ |
+ static Motion Empty() { return Motion(); } |
+ |
+ bool IsEmpty() const { |
+ return !can_provide_acceleration_x_ && !can_provide_acceleration_y_ && |
+ !can_provide_acceleration_z_ && |
+ !can_provide_acceleration_including_gravity_x_ && |
+ !can_provide_acceleration_including_gravity_y_ && |
+ !can_provide_acceleration_including_gravity_z_ && |
+ !can_provide_rotation_rate_alpha_ && |
+ !can_provide_rotation_rate_beta_ && |
+ !can_provide_rotation_rate_gamma_ && |
+ !can_provide_interval_; |
+ } |
+ |
+ void setAccelerationX(double accelerationX) { |
bulach
2012/07/02 12:47:56
nit: wrong case, needs to s/set/Set/ and s/can/Can
aousterh
2012/07/04 13:31:55
Done.
|
+ can_provide_acceleration_x_ = true; |
+ acceleration_x_ = accelerationX; |
+ } |
+ bool canProvideAccelerationX() const { return can_provide_acceleration_x_; } |
+ double accelerationX() const { return acceleration_x_; } |
+ |
+ void setAccelerationY(double accelerationY) { |
+ can_provide_acceleration_y_ = true; |
+ acceleration_y_ = accelerationY; |
+ } |
+ bool canProvideAccelerationY() const { return can_provide_acceleration_y_; } |
+ double accelerationY() const { return acceleration_y_; } |
+ |
+ void setAccelerationZ(double accelerationZ) { |
+ can_provide_acceleration_z_ = true; |
+ acceleration_z_ = accelerationZ; |
+ } |
+ bool canProvideAccelerationZ() const { return can_provide_acceleration_z_; } |
+ double accelerationZ() const { return acceleration_z_; } |
+ |
+ void setAccelerationIncludingGravityX(double accelerationIncludingGravityX) { |
+ can_provide_acceleration_including_gravity_x_ = true; |
+ acceleration_including_gravity_x_ = accelerationIncludingGravityX; |
+ } |
+ bool canProvideAccelerationIncludingGravityX() const { |
+ return can_provide_acceleration_x_; |
+ } |
+ double accelerationIncludingGravityX() const { |
+ return acceleration_including_gravity_x_; |
+ } |
+ |
+ void setAccelerationIncludingGravityY(double accelerationIncludingGravityY) { |
+ can_provide_acceleration_including_gravity_y_ = true; |
+ acceleration_including_gravity_y_ = accelerationIncludingGravityY; |
+ } |
+ bool canProvideAccelerationIncludingGravityY() const { |
+ return can_provide_acceleration_y_; |
+ } |
+ double accelerationIncludingGravityY() const { |
+ return acceleration_including_gravity_y_; |
+ } |
+ |
+ void setAccelerationIncludingGravityZ(double accelerationIncludingGravityZ) { |
+ can_provide_acceleration_including_gravity_z_ = true; |
+ acceleration_including_gravity_z_ = accelerationIncludingGravityZ; |
+ } |
+ bool canProvideAccelerationIncludingGravityZ() const { |
+ return can_provide_acceleration_z_; |
+ } |
+ double accelerationIncludingGravityZ() const { |
+ return acceleration_including_gravity_z_; |
+ } |
+ |
+ void setRotationRateAlpha(double rotationRateAlpha) { |
+ can_provide_rotation_rate_alpha_ = true; |
+ rotation_rate_alpha_ = rotationRateAlpha; |
+ } |
+ bool canProvideRotationRateAlpha() const { |
+ return can_provide_rotation_rate_alpha_; |
+ } |
+ double rotationRateAlpha() const { return rotation_rate_alpha_; } |
+ |
+ void setRotationRateBeta(double rotationRateBeta) { |
+ can_provide_rotation_rate_beta_ = true; |
+ rotation_rate_beta_ = rotationRateBeta; |
+ } |
+ bool canProvideRotationRateBeta() const { |
+ return can_provide_rotation_rate_beta_; |
+ } |
+ double rotationRateBeta() const { return rotation_rate_beta_; } |
+ |
+ void setRotationRateGamma(double rotationRateGamma) { |
+ can_provide_rotation_rate_gamma_ = true; |
+ rotation_rate_gamma_ = rotationRateGamma; |
+ } |
+ bool canProvideRotationRateGamma() const { |
+ return can_provide_rotation_rate_gamma_; |
+ } |
+ double rotationRateGamma() const { return rotation_rate_gamma_; } |
+ |
+ void setInterval(double interval) { |
+ can_provide_interval_ = true; |
+ interval_ = interval; |
+ } |
+ bool canProvideInterval() const { return can_provide_interval_; } |
+ double interval() const { return interval_; } |
+ |
+ private: |
+ double acceleration_x_; |
+ double acceleration_y_; |
+ double acceleration_z_; |
+ double acceleration_including_gravity_x_; |
+ double acceleration_including_gravity_y_; |
+ double acceleration_including_gravity_z_; |
+ double rotation_rate_alpha_; |
+ double rotation_rate_beta_; |
+ double rotation_rate_gamma_; |
+ double interval_; |
+ bool can_provide_acceleration_x_; |
+ bool can_provide_acceleration_y_; |
+ bool can_provide_acceleration_z_; |
+ bool can_provide_acceleration_including_gravity_x_; |
+ bool can_provide_acceleration_including_gravity_y_; |
+ bool can_provide_acceleration_including_gravity_z_; |
+ bool can_provide_rotation_rate_alpha_; |
+ bool can_provide_rotation_rate_beta_; |
+ bool can_provide_rotation_rate_gamma_; |
+ bool can_provide_interval_; |
+}; |
+ |
+} // namespace device_orientation |
+ |
+#endif // CONTENT_BROWSER_DEVICE_ORIENTATION_MOTION_H_ |