Save errno for logging before potentially overwriting it.
[chromium-blink-merge.git] / content / browser / device_orientation / orientation.h
blobb3ebd27c6e07308d2664b145d8f05bcf513d45e1
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_ORIENTATION_H_
6 #define CONTENT_BROWSER_DEVICE_ORIENTATION_ORIENTATION_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 Orientation : public DeviceData {
15 public:
16 // alpha, beta, gamma and absolute are the rotations around the axes as
17 // specified in http://dev.w3.org/geo/api/spec-source-orientation.html
19 // can_provide_{alpha,beta,gamma,absolute} is true if data can be provided
20 // for that variable.
21 CONTENT_EXPORT Orientation();
23 // From DeviceData.
24 virtual IPC::Message* CreateIPCMessage(int render_view_id) const OVERRIDE;
25 virtual bool ShouldFireEvent(const DeviceData* old_data) const OVERRIDE;
27 void set_alpha(double alpha) {
28 can_provide_alpha_ = true;
29 alpha_ = alpha;
31 bool can_provide_alpha() const { return can_provide_alpha_; }
32 double alpha() const { return alpha_; }
34 void set_beta(double beta) {
35 can_provide_beta_ = true;
36 beta_ = beta;
38 bool can_provide_beta() const { return can_provide_beta_; }
39 double beta() const { return beta_; }
41 void set_gamma(double gamma) {
42 can_provide_gamma_ = true;
43 gamma_ = gamma;
45 bool can_provide_gamma() const { return can_provide_gamma_; }
46 double gamma() const { return gamma_; }
48 void set_absolute(bool absolute) {
49 can_provide_absolute_ = true;
50 absolute_ = absolute;
52 bool can_provide_absolute() const { return can_provide_absolute_; }
53 bool absolute() const { return absolute_; }
55 private:
56 virtual ~Orientation();
58 static bool IsElementSignificantlyDifferent(bool can_provide_element1,
59 bool can_provide_element2, double element1, double element2);
61 double alpha_;
62 double beta_;
63 double gamma_;
64 bool absolute_;
65 bool can_provide_alpha_;
66 bool can_provide_beta_;
67 bool can_provide_gamma_;
68 bool can_provide_absolute_;
71 } // namespace content
73 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_ORIENTATION_H_