Chromium Code Reviews| 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..273bf65e4e808b1db49a7d7a3aa2ea05c213eb2d |
| --- /dev/null |
| +++ b/content/browser/device_orientation/device_data.h |
| @@ -0,0 +1,41 @@ |
| +// 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> |
| + |
| +namespace device_orientation { |
| +class DeviceData { |
| + public: |
| + enum DeviceDataType { |
| + kDeviceOrientationData, |
| + kNumberOfDeviceDataTypes |
| + }; |
| + virtual ~DeviceData() {} |
| + |
| + virtual DeviceData* Clone() const = 0; |
| + virtual bool IsEmpty() const = 0; |
| + virtual bool SignificantlyDifferentFrom(const DeviceData& other) = 0; |
| + DeviceDataType device_data_type() const { return device_data_type_; } |
| + |
| + static bool 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) |
|
Steve Block
2013/05/27 01:36:03
I'm not sure it makes sense for this to be in the
|
| + return true; |
| + if (can_provide_element1 && std::fabs(element1 - element2) >= kThreshold) |
| + return true; |
| + return false; |
| + } |
| + |
| + protected: |
| + DeviceDataType device_data_type_; |
| +}; |
| + |
| +} // namespace device_orientation |
| + |
| +#endif // CONTENT_BROWSER_DEVICE_ORIENTATION_DEVICE_DATA_H_ |