Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_DEVICE_ORIENTATION_DEVICE_DATA_H_ | |
| 6 #define CONTENT_BROWSER_DEVICE_ORIENTATION_DEVICE_DATA_H_ | |
| 7 | |
| 8 #include <cmath> | |
| 9 | |
| 10 namespace device_orientation { | |
| 11 class DeviceData { | |
| 12 public: | |
| 13 enum DeviceDataType { | |
| 14 kDeviceOrientationData, | |
| 15 kNumberOfDeviceDataTypes | |
| 16 }; | |
| 17 virtual ~DeviceData() {} | |
| 18 | |
| 19 virtual DeviceData* Clone() const = 0; | |
| 20 virtual bool IsEmpty() const = 0; | |
| 21 virtual bool SignificantlyDifferentFrom(const DeviceData& other) = 0; | |
| 22 DeviceDataType device_data_type() const { return device_data_type_; } | |
| 23 | |
| 24 static bool IsElementSignificantlyDifferent(bool can_provide_element1, | |
| 25 bool can_provide_element2, double element1, double element2) { | |
| 26 const double kThreshold = 0.1; | |
| 27 | |
| 28 if (can_provide_element1 != can_provide_element2) | |
|
Steve Block
2013/05/27 01:36:03
I'm not sure it makes sense for this to be in the
| |
| 29 return true; | |
| 30 if (can_provide_element1 && std::fabs(element1 - element2) >= kThreshold) | |
| 31 return true; | |
| 32 return false; | |
| 33 } | |
| 34 | |
| 35 protected: | |
| 36 DeviceDataType device_data_type_; | |
| 37 }; | |
| 38 | |
| 39 } // namespace device_orientation | |
| 40 | |
| 41 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_DEVICE_DATA_H_ | |
| OLD | NEW |