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

Unified Diff: content/browser/device_orientation/orientation.cc

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 side-by-side diff with in-line comments
Download patch
Index: content/browser/device_orientation/orientation.cc
diff --git a/content/browser/device_orientation/orientation.cc b/content/browser/device_orientation/orientation.cc
new file mode 100644
index 0000000000000000000000000000000000000000..eabbfbaa1bf65773a0c56b1d0b616b55795219aa
--- /dev/null
+++ b/content/browser/device_orientation/orientation.cc
@@ -0,0 +1,50 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/device_orientation/orientation.h"
+
+namespace device_orientation {
+
+DeviceData* Orientation::Clone() const {
+ Orientation* orientation = new Orientation();
bulach 2012/07/12 10:43:27 nit: odd indentation, remove one space from 10-19
aousterh 2012/07/12 17:13:57 Done.
+ orientation->alpha_ = alpha_;
+ orientation->beta_ = beta_;
+ orientation->gamma_ = gamma_;
+ orientation->absolute_ = absolute_;
+ orientation->can_provide_alpha_ = can_provide_alpha_;
+ orientation->can_provide_beta_ = can_provide_beta_;
+ orientation->can_provide_gamma_ = can_provide_gamma_;
+ orientation->can_provide_absolute_ = can_provide_absolute_;
+ return orientation;
+}
+
+bool Orientation::IsEmpty() const {
+ return !can_provide_alpha_ && !can_provide_beta_ && !can_provide_gamma_
+ && !can_provide_absolute_;
bulach 2012/07/12 10:43:27 nit: I think the && needs to be in the previous li
aousterh 2012/07/12 17:13:57 Done.
+}
+
+// Returns true if two orientations are considered different enough that
+// observers should be notified of the new orientation.
+bool Orientation::SignificantlyDifferentFrom(
+ const DeviceData& other_device_data) {
+ const Orientation& other_orientation =
+ static_cast<const Orientation&>(other_device_data);
+
+ return IsElementSignificantlyDifferent(can_provide_alpha_,
+ other_orientation.can_provide_alpha(),
+ alpha_,
+ other_orientation.alpha()) ||
+ IsElementSignificantlyDifferent(can_provide_beta_,
+ other_orientation.can_provide_beta(),
+ beta_,
+ other_orientation.beta()) ||
+ IsElementSignificantlyDifferent(can_provide_gamma_,
+ other_orientation.can_provide_gamma(),
+ gamma_,
+ other_orientation.gamma()) ||
+ (can_provide_absolute_ != other_orientation.can_provide_absolute() ||
bulach 2012/07/12 10:43:27 nit: no need for this parens.
aousterh 2012/07/12 17:13:57 Done.
+ absolute_ != other_orientation.absolute());
+}
+
+}; // namespace device_orientation
bulach 2012/07/12 10:43:27 nit: remove the ;
aousterh 2012/07/12 17:13:57 Done.

Powered by Google App Engine
This is Rietveld 408576698