OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_DEVICE_ORIENTATION_MOTION_H_ |
| 6 #define CONTENT_BROWSER_DEVICE_ORIENTATION_MOTION_H_ |
| 7 |
| 8 #include "base/compiler_specific.h" |
| 9 #include "content/browser/device_orientation/device_data.h" |
| 10 #include "content/common/content_export.h" |
| 11 |
| 12 namespace content { |
| 13 |
| 14 class Motion : public DeviceData { |
| 15 public: |
| 16 // acceleration_x, acceleration_y, and acceleration_z are the accelerations |
| 17 // excluding gravity along the axes specified in |
| 18 // http://dev.w3.org/geo/api/spec-source-orientation.html |
| 19 |
| 20 // acceleration_including_gravity_x, acceleration_including_gravity_y, and |
| 21 // acceleration_including_gravity_z are the accelerations including gravity |
| 22 // along the same axes as above |
| 23 |
| 24 // rotation_rate_alpha, rotation_rate_beta, and rotataion_rate_gamma are the |
| 25 // rotations around the same axes as above |
| 26 |
| 27 // interval is the time interval at which data is obtained from the hardware, |
| 28 // as specified in the document referenced above |
| 29 |
| 30 // can_provide_{acceleration_x, acceleration_y, acceleration_z, |
| 31 // acceleration_including_gravity_x, acceleration_including_gravity_y, |
| 32 // acceleration_including_gravity_z, rotation_rate_alpha, rotation_rate_beta, |
| 33 // rotation_rate_gamma, interval} is true if data can be provided for that |
| 34 // variable |
| 35 CONTENT_EXPORT Motion(); |
| 36 |
| 37 // From DeviceData. |
| 38 virtual IPC::Message* CreateIPCMessage(int render_view_id) const OVERRIDE; |
| 39 virtual bool ShouldFireEvent(const DeviceData* old_data) const OVERRIDE; |
| 40 |
| 41 void set_acceleration_x(double acceleration_x) { |
| 42 can_provide_acceleration_x_ = true; |
| 43 acceleration_x_ = acceleration_x; |
| 44 } |
| 45 bool can_provide_acceleration_x() const { |
| 46 return can_provide_acceleration_x_; |
| 47 } |
| 48 double acceleration_x() const { return acceleration_x_; } |
| 49 |
| 50 void set_acceleration_y(double acceleration_y) { |
| 51 can_provide_acceleration_y_ = true; |
| 52 acceleration_y_ = acceleration_y; |
| 53 } |
| 54 bool can_provide_acceleration_y() const { |
| 55 return can_provide_acceleration_y_; |
| 56 } |
| 57 double acceleration_y() const { return acceleration_y_; } |
| 58 |
| 59 void set_acceleration_z(double acceleration_z) { |
| 60 can_provide_acceleration_z_ = true; |
| 61 acceleration_z_ = acceleration_z; |
| 62 } |
| 63 bool can_provide_acceleration_z() const { |
| 64 return can_provide_acceleration_z_; |
| 65 } |
| 66 double acceleration_z() const { return acceleration_z_; } |
| 67 |
| 68 void set_acceleration_including_gravity_x( |
| 69 double acceleration_including_gravity_x) { |
| 70 can_provide_acceleration_including_gravity_x_ = true; |
| 71 acceleration_including_gravity_x_ = acceleration_including_gravity_x; |
| 72 } |
| 73 bool can_provide_acceleration_including_gravity_x() const { |
| 74 return can_provide_acceleration_x_; |
| 75 } |
| 76 double acceleration_including_gravity_x() const { |
| 77 return acceleration_including_gravity_x_; |
| 78 } |
| 79 |
| 80 void set_acceleration_including_gravity_y( |
| 81 double acceleration_including_gravity_y) { |
| 82 can_provide_acceleration_including_gravity_y_ = true; |
| 83 acceleration_including_gravity_y_ = acceleration_including_gravity_y; |
| 84 } |
| 85 bool can_provide_acceleration_including_gravity_y() const { |
| 86 return can_provide_acceleration_y_; |
| 87 } |
| 88 double acceleration_including_gravity_y() const { |
| 89 return acceleration_including_gravity_y_; |
| 90 } |
| 91 |
| 92 void set_acceleration_including_gravity_z( |
| 93 double acceleration_including_gravity_z) { |
| 94 can_provide_acceleration_including_gravity_z_ = true; |
| 95 acceleration_including_gravity_z_ = acceleration_including_gravity_z; |
| 96 } |
| 97 bool can_provide_acceleration_including_gravity_z() const { |
| 98 return can_provide_acceleration_z_; |
| 99 } |
| 100 double acceleration_including_gravity_z() const { |
| 101 return acceleration_including_gravity_z_; |
| 102 } |
| 103 |
| 104 void set_rotation_rate_alpha(double rotation_rate_alpha) { |
| 105 can_provide_rotation_rate_alpha_ = true; |
| 106 rotation_rate_alpha_ = rotation_rate_alpha; |
| 107 } |
| 108 bool can_provide_rotation_rate_alpha() const { |
| 109 return can_provide_rotation_rate_alpha_; |
| 110 } |
| 111 double rotation_rate_alpha() const { return rotation_rate_alpha_; } |
| 112 |
| 113 void set_rotation_rate_beta(double rotation_rate_beta) { |
| 114 can_provide_rotation_rate_beta_ = true; |
| 115 rotation_rate_beta_ = rotation_rate_beta; |
| 116 } |
| 117 bool can_provide_rotation_rate_beta() const { |
| 118 return can_provide_rotation_rate_beta_; |
| 119 } |
| 120 double rotation_rate_beta() const { return rotation_rate_beta_; } |
| 121 |
| 122 void set_rotation_rate_gamma(double rotation_rate_gamma) { |
| 123 can_provide_rotation_rate_gamma_ = true; |
| 124 rotation_rate_gamma_ = rotation_rate_gamma; |
| 125 } |
| 126 bool can_provide_rotation_rate_gamma() const { |
| 127 return can_provide_rotation_rate_gamma_; |
| 128 } |
| 129 double rotation_rate_gamma() const { return rotation_rate_gamma_; } |
| 130 |
| 131 void set_interval(double interval) { |
| 132 can_provide_interval_ = true; |
| 133 interval_ = interval; |
| 134 } |
| 135 bool can_provide_interval() const { return can_provide_interval_; } |
| 136 double interval() const { return interval_; } |
| 137 |
| 138 private: |
| 139 virtual ~Motion(); |
| 140 |
| 141 double acceleration_x_; |
| 142 double acceleration_y_; |
| 143 double acceleration_z_; |
| 144 double acceleration_including_gravity_x_; |
| 145 double acceleration_including_gravity_y_; |
| 146 double acceleration_including_gravity_z_; |
| 147 double rotation_rate_alpha_; |
| 148 double rotation_rate_beta_; |
| 149 double rotation_rate_gamma_; |
| 150 double interval_; |
| 151 bool can_provide_acceleration_x_; |
| 152 bool can_provide_acceleration_y_; |
| 153 bool can_provide_acceleration_z_; |
| 154 bool can_provide_acceleration_including_gravity_x_; |
| 155 bool can_provide_acceleration_including_gravity_y_; |
| 156 bool can_provide_acceleration_including_gravity_z_; |
| 157 bool can_provide_rotation_rate_alpha_; |
| 158 bool can_provide_rotation_rate_beta_; |
| 159 bool can_provide_rotation_rate_gamma_; |
| 160 bool can_provide_interval_; |
| 161 }; |
| 162 |
| 163 } // namespace content |
| 164 |
| 165 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_MOTION_H_ |
OLD | NEW |