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

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: Moves construction of DeviceData objects out of ProviderImpl 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 {
bulach 2012/07/12 10:43:27 nit: add a \n here, and the following line needs t
aousterh 2012/07/12 17:13:57 Done.
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 : alpha_(0), 21 : alpha_(0),
19 beta_(0), 22 beta_(0),
20 gamma_(0), 23 gamma_(0),
21 absolute_(false), 24 absolute_(false),
aousterh 2012/07/11 20:11:25 Somehow those initializations accidentally got add
aousterh 2012/07/12 17:13:57 Done.
22 can_provide_alpha_(false), 25 can_provide_alpha_(false),
23 can_provide_beta_(false), 26 can_provide_beta_(false),
24 can_provide_gamma_(false), 27 can_provide_gamma_(false),
25 can_provide_absolute_(false) { 28 can_provide_absolute_(false) {
26 } 29 }
27 Orientation(const Orientation& orientation)
28 : alpha_(orientation.alpha()),
29 beta_(orientation.beta()),
30 gamma_(orientation.gamma()),
31 absolute_(orientation.absolute()),
32 can_provide_alpha_(orientation.can_provide_alpha()),
33 can_provide_beta_(orientation.can_provide_beta()),
34 can_provide_gamma_(orientation.can_provide_gamma()),
35 can_provide_absolute_(orientation.can_provide_absolute()) {
36 }
37 void operator=(const Orientation& source) {
38 alpha_ = source.alpha();
39 beta_ = source.beta();
40 gamma_ = source.gamma();
41 absolute_ = source.absolute();
42 can_provide_alpha_ = source.can_provide_alpha();
43 can_provide_beta_ = source.can_provide_beta();
44 can_provide_gamma_ = source.can_provide_gamma();
45 can_provide_absolute_ = source.can_provide_absolute();
46 }
47 30
48 static Orientation Empty() { return Orientation(); } 31 static Orientation Empty() { return Orientation(); }
bulach 2012/07/12 10:43:27 nit: I think we could remove this and just use Ori
aousterh 2012/07/12 17:13:57 Done.
49 32
50 bool is_empty() const { 33 virtual DeviceData* Clone() const OVERRIDE;
51 return !can_provide_alpha_ && !can_provide_beta_ && !can_provide_gamma_ 34 virtual bool IsEmpty() const OVERRIDE;
52 && !can_provide_absolute_; 35 virtual bool SignificantlyDifferentFrom(const DeviceData& other) OVERRIDE;
53 }
54 36
55 void set_alpha(double alpha) { 37 void set_alpha(double alpha) {
56 can_provide_alpha_ = true; 38 can_provide_alpha_ = true;
57 alpha_ = alpha; 39 alpha_ = alpha;
58 } 40 }
59 bool can_provide_alpha() const { return can_provide_alpha_; } 41 bool can_provide_alpha() const { return can_provide_alpha_; }
60 double alpha() const { return alpha_; } 42 double alpha() const { return alpha_; }
61 43
62 void set_beta(double beta) { 44 void set_beta(double beta) {
63 can_provide_beta_ = true; 45 can_provide_beta_ = true;
(...skipping 23 matching lines...) Expand all
87 bool absolute_; 69 bool absolute_;
88 bool can_provide_alpha_; 70 bool can_provide_alpha_;
89 bool can_provide_beta_; 71 bool can_provide_beta_;
90 bool can_provide_gamma_; 72 bool can_provide_gamma_;
91 bool can_provide_absolute_; 73 bool can_provide_absolute_;
92 }; 74 };
93 75
94 } // namespace device_orientation 76 } // namespace device_orientation
95 77
96 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_ORIENTATION_H_ 78 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_ORIENTATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698