OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_ANDROID_H_ | 5 #ifndef CHROME_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_ANDROID_H_ |
6 #define CHROME_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_ANDROID_H_ | 6 #define CHROME_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_ANDROID_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
12 #include "content/browser/device_orientation/data_fetcher.h" | 12 #include "content/browser/device_orientation/data_fetcher.h" |
13 #include "content/browser/device_orientation/device_data.h" | 13 #include "content/browser/device_orientation/device_data.h" |
14 | 14 |
15 namespace device_orientation { | 15 namespace content { |
16 | 16 |
17 class Orientation; | 17 class Orientation; |
18 | 18 |
19 // Android implementation of DeviceOrientation API. | 19 // Android implementation of DeviceOrientation API. |
20 | 20 |
21 // Android's SensorManager has a push API, whereas Chrome wants to pull data. | 21 // Android's SensorManager has a push API, whereas Chrome wants to pull data. |
22 // To fit them together, we store incoming sensor events in a 1-element buffer. | 22 // To fit them together, we store incoming sensor events in a 1-element buffer. |
23 // SensorManager calls SetOrientation() which pushes a new value (discarding the | 23 // SensorManager calls SetOrientation() which pushes a new value (discarding the |
24 // previous value if any). Chrome calls GetDeviceData() which reads the most | 24 // previous value if any). Chrome calls GetDeviceData() which reads the most |
25 // recent value. Repeated calls to GetDeviceData() will return the same value. | 25 // recent value. Repeated calls to GetDeviceData() will return the same value. |
(...skipping 27 matching lines...) Expand all Loading... |
53 // Value returned by GetDeviceData. | 53 // Value returned by GetDeviceData. |
54 scoped_refptr<Orientation> current_orientation_; | 54 scoped_refptr<Orientation> current_orientation_; |
55 | 55 |
56 // 1-element buffer, written by GotOrientation, read by GetDeviceData. | 56 // 1-element buffer, written by GotOrientation, read by GetDeviceData. |
57 base::Lock next_orientation_lock_; | 57 base::Lock next_orientation_lock_; |
58 scoped_refptr<Orientation> next_orientation_; | 58 scoped_refptr<Orientation> next_orientation_; |
59 | 59 |
60 DISALLOW_COPY_AND_ASSIGN(DataFetcherImplAndroid); | 60 DISALLOW_COPY_AND_ASSIGN(DataFetcherImplAndroid); |
61 }; | 61 }; |
62 | 62 |
63 } // namespace device_orientation | 63 } // namespace content |
64 | 64 |
65 #endif // CHROME_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_ANDROID_H_ | 65 #endif // CHROME_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_ANDROID_H_ |
OLD | NEW |