Save errno for logging before potentially overwriting it.
[chromium-blink-merge.git] / content / browser / device_orientation / motion.h
blob8027254b994a0e6ccff4385bce4e2e705bb7b98c
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.
5 #ifndef CONTENT_BROWSER_DEVICE_ORIENTATION_MOTION_H_
6 #define CONTENT_BROWSER_DEVICE_ORIENTATION_MOTION_H_
8 #include "base/compiler_specific.h"
9 #include "content/browser/device_orientation/device_data.h"
10 #include "content/common/content_export.h"
12 namespace content {
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
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
24 // rotation_rate_alpha, rotation_rate_beta, and rotataion_rate_gamma are the
25 // rotations around the same axes as above
27 // interval is the time interval at which data is obtained from the hardware,
28 // as specified in the document referenced above
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();
37 // From DeviceData.
38 virtual IPC::Message* CreateIPCMessage(int render_view_id) const OVERRIDE;
39 virtual bool ShouldFireEvent(const DeviceData* old_data) const OVERRIDE;
41 void set_acceleration_x(double acceleration_x) {
42 can_provide_acceleration_x_ = true;
43 acceleration_x_ = acceleration_x;
45 bool can_provide_acceleration_x() const {
46 return can_provide_acceleration_x_;
48 double acceleration_x() const { return acceleration_x_; }
50 void set_acceleration_y(double acceleration_y) {
51 can_provide_acceleration_y_ = true;
52 acceleration_y_ = acceleration_y;
54 bool can_provide_acceleration_y() const {
55 return can_provide_acceleration_y_;
57 double acceleration_y() const { return acceleration_y_; }
59 void set_acceleration_z(double acceleration_z) {
60 can_provide_acceleration_z_ = true;
61 acceleration_z_ = acceleration_z;
63 bool can_provide_acceleration_z() const {
64 return can_provide_acceleration_z_;
66 double acceleration_z() const { return acceleration_z_; }
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;
73 bool can_provide_acceleration_including_gravity_x() const {
74 return can_provide_acceleration_x_;
76 double acceleration_including_gravity_x() const {
77 return acceleration_including_gravity_x_;
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;
85 bool can_provide_acceleration_including_gravity_y() const {
86 return can_provide_acceleration_y_;
88 double acceleration_including_gravity_y() const {
89 return acceleration_including_gravity_y_;
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;
97 bool can_provide_acceleration_including_gravity_z() const {
98 return can_provide_acceleration_z_;
100 double acceleration_including_gravity_z() const {
101 return acceleration_including_gravity_z_;
104 void set_rotation_rate_alpha(double rotation_rate_alpha) {
105 can_provide_rotation_rate_alpha_ = true;
106 rotation_rate_alpha_ = rotation_rate_alpha;
108 bool can_provide_rotation_rate_alpha() const {
109 return can_provide_rotation_rate_alpha_;
111 double rotation_rate_alpha() const { return rotation_rate_alpha_; }
113 void set_rotation_rate_beta(double rotation_rate_beta) {
114 can_provide_rotation_rate_beta_ = true;
115 rotation_rate_beta_ = rotation_rate_beta;
117 bool can_provide_rotation_rate_beta() const {
118 return can_provide_rotation_rate_beta_;
120 double rotation_rate_beta() const { return rotation_rate_beta_; }
122 void set_rotation_rate_gamma(double rotation_rate_gamma) {
123 can_provide_rotation_rate_gamma_ = true;
124 rotation_rate_gamma_ = rotation_rate_gamma;
126 bool can_provide_rotation_rate_gamma() const {
127 return can_provide_rotation_rate_gamma_;
129 double rotation_rate_gamma() const { return rotation_rate_gamma_; }
131 void set_interval(double interval) {
132 can_provide_interval_ = true;
133 interval_ = interval;
135 bool can_provide_interval() const { return can_provide_interval_; }
136 double interval() const { return interval_; }
138 private:
139 virtual ~Motion();
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_;
163 } // namespace content
165 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_MOTION_H_