Index: content/browser/device_orientation/device_data.h |
diff --git a/content/browser/device_orientation/device_data.h b/content/browser/device_orientation/device_data.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3e9fa84c466ac39d8ab2420ff3a6a05b7200dc28 |
--- /dev/null |
+++ b/content/browser/device_orientation/device_data.h |
@@ -0,0 +1,37 @@ |
+// 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. |
+ |
+#ifndef CONTENT_BROWSER_DEVICE_ORIENTATION_DEVICE_DATA_H_ |
+#define CONTENT_BROWSER_DEVICE_ORIENTATION_DEVICE_DATA_H_ |
+ |
+#include <cmath> |
bulach
2012/07/12 10:43:27
nit: best to move this (and the method implementat
aousterh
2012/07/12 17:13:57
Done.
|
+ |
+namespace device_orientation { |
bulach
2012/07/12 10:43:27
nit: add a \n here..
aousterh
2012/07/12 17:13:57
Done.
|
+class DeviceData { |
+ public: |
+ enum DeviceDataType { |
bulach
2012/07/12 10:43:27
nit: since it's already scoped to DeviceData, it'd
aousterh
2012/07/12 17:13:57
Done.
|
+ kDeviceOrientationData, |
bulach
2012/07/12 10:43:27
nit: also, the enum values are normally named as k
aousterh
2012/07/12 17:13:57
Done.
|
+ kNumberOfDeviceDataTypes |
+ }; |
+ virtual ~DeviceData() {} |
+ |
+ virtual DeviceData* Clone() const = 0; |
+ virtual bool IsEmpty() const = 0; |
+ virtual bool SignificantlyDifferentFrom(const DeviceData& other) = 0; |
+ |
+ static bool IsElementSignificantlyDifferent(bool can_provide_element1, |
bulach
2012/07/12 10:43:27
nit: as above, probably best to move this to the .
aousterh
2012/07/12 17:13:57
Done.
|
+ 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 |
+ |
+#endif // CONTENT_BROWSER_DEVICE_ORIENTATION_DEVICE_DATA_H_ |