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

Side by Side Diff: content/browser/device_orientation/device_data.h

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 unified diff | Download patch
OLDNEW
(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>
bulach 2012/07/12 10:43:27 nit: best to move this (and the method implementat
aousterh 2012/07/12 17:13:57 Done.
9
10 namespace device_orientation {
bulach 2012/07/12 10:43:27 nit: add a \n here..
aousterh 2012/07/12 17:13:57 Done.
11 class DeviceData {
12 public:
13 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.
14 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.
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
23 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.
24 bool can_provide_element2, double element1, double element2) {
25 const double kThreshold = 0.1;
26
27 if (can_provide_element1 != can_provide_element2)
28 return true;
29 if (can_provide_element1 && std::fabs(element1 - element2) >= kThreshold)
30 return true;
31 return false;
32 }
33 };
34
35 } // namespace device_orientation
36
37 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_DEVICE_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698