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

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

Issue 10755002: Refactors DeviceOrientation to make it more extensible (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Handles null device_data in observer 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/device_data.cc
diff --git a/content/browser/device_orientation/device_data.cc b/content/browser/device_orientation/device_data.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d52bf9ea2bc89866ec8d72bb23a3bdec04a12f8f
--- /dev/null
+++ b/content/browser/device_orientation/device_data.cc
@@ -0,0 +1,22 @@
+// 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 <cmath>
+
+#include "content/browser/device_orientation/device_data.h"
+
+namespace device_orientation {
+
+bool DeviceData::IsElementSignificantlyDifferent(bool can_provide_element1,
+ bool can_provide_element2, double element1, double element2) {
+ const double kThreshold = 0.1;
+
+ if (can_provide_element1 != can_provide_element2)
+ return true;
+ if (can_provide_element1 && std::fabs(element1 - element2) >= kThreshold)
+ return true;
+ return false;
+}
+
+} // namespace device_orientation

Powered by Google App Engine
This is Rietveld 408576698