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 "base/android/scoped_java_ref.h" | 8 #include "base/android/scoped_java_ref.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 // Factory function. We'll listen for events for the lifetime of this object. | 31 // Factory function. We'll listen for events for the lifetime of this object. |
32 // Returns NULL on error. | 32 // Returns NULL on error. |
33 static DataFetcher* Create(); | 33 static DataFetcher* Create(); |
34 | 34 |
35 virtual ~DataFetcherImplAndroid(); | 35 virtual ~DataFetcherImplAndroid(); |
36 | 36 |
37 // Called from Java via JNI. | 37 // Called from Java via JNI. |
38 void GotOrientation(JNIEnv*, jobject, | 38 void GotOrientation(JNIEnv*, jobject, |
39 double alpha, double beta, double gamma); | 39 double alpha, double beta, double gamma); |
| 40 void GotAcceleration(JNIEnv*, jobject, |
| 41 double x, double y, double z); |
| 42 void GotAccelerationIncludingGravity(JNIEnv*, jobject, |
| 43 double x, double y, double z); |
| 44 void GotRotationRate(JNIEnv*, jobject, |
| 45 double alpha, double beta, double gamma); |
40 | 46 |
41 // Implementation of DataFetcher. | 47 // Implementation of DataFetcher. |
42 virtual const DeviceData* GetDeviceData(DeviceData::Type type) OVERRIDE; | 48 virtual const DeviceData* GetDeviceData(DeviceData::Type type) OVERRIDE; |
43 | 49 |
44 private: | 50 private: |
45 DataFetcherImplAndroid(); | 51 DataFetcherImplAndroid(); |
46 const Orientation* GetOrientation(); | 52 const Orientation* GetOrientation(); |
47 | 53 |
48 // Wrappers for JNI methods. | 54 // Wrappers for JNI methods. |
49 bool Start(int rate_in_milliseconds); | 55 // TODO(timvolodine): move the DeviceData::Type enum to the service class |
50 void Stop(); | 56 // once it is implemented. |
| 57 bool Start(DeviceData::Type event_type, int rate_in_milliseconds); |
| 58 void Stop(DeviceData::Type event_type); |
51 | 59 |
52 // Value returned by GetDeviceData. | 60 // Value returned by GetDeviceData. |
53 scoped_refptr<Orientation> current_orientation_; | 61 scoped_refptr<Orientation> current_orientation_; |
54 | 62 |
55 // 1-element buffer, written by GotOrientation, read by GetDeviceData. | 63 // 1-element buffer, written by GotOrientation, read by GetDeviceData. |
56 base::Lock next_orientation_lock_; | 64 base::Lock next_orientation_lock_; |
57 scoped_refptr<Orientation> next_orientation_; | 65 scoped_refptr<Orientation> next_orientation_; |
58 | 66 |
59 // The Java provider of orientation info. | 67 // The Java provider of orientation info. |
60 base::android::ScopedJavaGlobalRef<jobject> device_orientation_; | 68 base::android::ScopedJavaGlobalRef<jobject> device_orientation_; |
61 | 69 |
62 DISALLOW_COPY_AND_ASSIGN(DataFetcherImplAndroid); | 70 DISALLOW_COPY_AND_ASSIGN(DataFetcherImplAndroid); |
63 }; | 71 }; |
64 | 72 |
65 } // namespace content | 73 } // namespace content |
66 | 74 |
67 #endif // CHROME_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_ANDROID_H_ | 75 #endif // CHROME_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_ANDROID_H_ |
OLD | NEW |