Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(411)

Side by Side Diff: content/browser/device_orientation/orientation.h

Issue 10755002: Refactors DeviceOrientation to make it more extensible (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_DEVICE_ORIENTATION_ORIENTATION_H_ 5 #ifndef CONTENT_BROWSER_DEVICE_ORIENTATION_ORIENTATION_H_
6 #define CONTENT_BROWSER_DEVICE_ORIENTATION_ORIENTATION_H_ 6 #define CONTENT_BROWSER_DEVICE_ORIENTATION_ORIENTATION_H_
7 7
8 #include "base/compiler_specific.h"
9 #include "content/browser/device_orientation/device_data.h"
10
8 namespace device_orientation { 11 namespace device_orientation {
9 class Orientation { 12 class Orientation : public DeviceData {
10 public: 13 public:
11 // alpha, beta, gamma and absolute are the rotations around the axes as 14 // alpha, beta, gamma and absolute are the rotations around the axes as
12 // specified in http://dev.w3.org/geo/api/spec-source-orientation.html 15 // specified in http://dev.w3.org/geo/api/spec-source-orientation.html
13 // 16 //
14 // can_provide_{alpha,beta,gamma,absolute} is true if data can be provided 17 // can_provide_{alpha,beta,gamma,absolute} is true if data can be provided
15 // for that variable. 18 // for that variable.
16 19
17 Orientation() 20 Orientation()
18 : can_provide_alpha_(false), 21 : can_provide_alpha_(false),
19 can_provide_beta_(false), 22 can_provide_beta_(false),
20 can_provide_gamma_(false), 23 can_provide_gamma_(false),
21 can_provide_absolute_(false) { 24 can_provide_absolute_(false) {
22 } 25 device_data_type_ = DeviceData::kDeviceOrientationData;
23 Orientation(const Orientation& orientation)
24 : alpha_(orientation.alpha()),
25 beta_(orientation.beta()),
26 gamma_(orientation.gamma()),
27 absolute_(orientation.absolute()),
28 can_provide_alpha_(orientation.can_provide_alpha()),
29 can_provide_beta_(orientation.can_provide_beta()),
30 can_provide_gamma_(orientation.can_provide_gamma()),
31 can_provide_absolute_(orientation.can_provide_absolute()) {
32 }
33 void operator=(const Orientation& source) {
34 alpha_ = source.alpha();
35 beta_ = source.beta();
36 gamma_ = source.gamma();
37 absolute_ = source.absolute();
38 can_provide_alpha_ = source.can_provide_alpha();
39 can_provide_beta_ = source.can_provide_beta();
40 can_provide_gamma_ = source.can_provide_gamma();
41 can_provide_absolute_ = source.can_provide_absolute();
42 } 26 }
43 27
44 static Orientation Empty() { return Orientation(); } 28 static Orientation Empty() { return Orientation(); }
45 29
46 bool is_empty() const { 30 virtual DeviceData* Clone() const OVERRIDE;
47 return !can_provide_alpha_ && !can_provide_beta_ && !can_provide_gamma_ 31 virtual bool IsEmpty() const OVERRIDE;
48 && !can_provide_absolute_; 32 virtual bool SignificantlyDifferentFrom(const DeviceData& other) OVERRIDE;
49 }
50 33
51 void set_alpha(double alpha) { 34 void set_alpha(double alpha) {
52 can_provide_alpha_ = true; 35 can_provide_alpha_ = true;
53 alpha_ = alpha; 36 alpha_ = alpha;
54 } 37 }
55 bool can_provide_alpha() const { return can_provide_alpha_; } 38 bool can_provide_alpha() const { return can_provide_alpha_; }
56 double alpha() const { return alpha_; } 39 double alpha() const { return alpha_; }
57 40
58 void set_beta(double beta) { 41 void set_beta(double beta) {
59 can_provide_beta_ = true; 42 can_provide_beta_ = true;
(...skipping 23 matching lines...) Expand all
83 bool absolute_; 66 bool absolute_;
84 bool can_provide_alpha_; 67 bool can_provide_alpha_;
85 bool can_provide_beta_; 68 bool can_provide_beta_;
86 bool can_provide_gamma_; 69 bool can_provide_gamma_;
87 bool can_provide_absolute_; 70 bool can_provide_absolute_;
88 }; 71 };
89 72
90 } // namespace device_orientation 73 } // namespace device_orientation
91 74
92 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_ORIENTATION_H_ 75 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_ORIENTATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698