OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CONTENT_BROWSER_DEVICE_SENSORS_SENSOR_MANAGER_ANDROID_H_ | 5 #ifndef DEVICE_DEVICE_SENSORS_SENSOR_MANAGER_ANDROID_H_ |
6 #define CONTENT_BROWSER_DEVICE_SENSORS_SENSOR_MANAGER_ANDROID_H_ | 6 #define DEVICE_DEVICE_SENSORS_SENSOR_MANAGER_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" |
11 #include "content/common/content_export.h" | 11 #include "device/device_sensors/device_light_hardware_buffer.h" |
12 #include "content/common/device_sensors/device_light_hardware_buffer.h" | 12 #include "device/device_sensors/device_motion_hardware_buffer.h" |
13 #include "content/common/device_sensors/device_motion_hardware_buffer.h" | 13 #include "device/device_sensors/device_orientation_hardware_buffer.h" |
14 #include "content/common/device_sensors/device_orientation_hardware_buffer.h" | 14 #include "device/device_sensors/device_sensors_export.h" |
15 | 15 |
16 template<typename T> struct DefaultSingletonTraits; | 16 template <typename T> |
| 17 struct DefaultSingletonTraits; |
17 | 18 |
18 namespace content { | 19 namespace device { |
19 | 20 |
20 // Android implementation of Device {Motion|Orientation|Light} API. | 21 // Android implementation of Device {Motion|Orientation|Light} API. |
21 // | 22 // |
22 // Android's SensorManager has a push API, so when Got*() methods are called | 23 // Android's SensorManager has a push API, so when Got*() methods are called |
23 // by the system the browser process puts the received data into a shared | 24 // by the system the browser process puts the received data into a shared |
24 // memory buffer, which is read by the renderer processes. | 25 // memory buffer, which is read by the renderer processes. |
25 class CONTENT_EXPORT SensorManagerAndroid { | 26 class DEVICE_SENSORS_EXPORT SensorManagerAndroid { |
26 public: | 27 public: |
27 // Must be called at startup, before GetInstance(). | 28 // Must be called at startup, before GetInstance(). |
28 static bool Register(JNIEnv* env); | 29 static bool Register(JNIEnv* env); |
29 | 30 |
30 // Needs to be thread-safe, because accessed from different threads. | 31 // Needs to be thread-safe, because accessed from different threads. |
31 static SensorManagerAndroid* GetInstance(); | 32 static SensorManagerAndroid* GetInstance(); |
32 | 33 |
33 // Called from Java via JNI. | 34 // Called from Java via JNI. |
34 void GotLight(JNIEnv*, jobject, double value); | 35 void GotLight(JNIEnv*, jobject, double value); |
35 void GotOrientation(JNIEnv*, jobject, | 36 void GotOrientation(JNIEnv*, |
36 double alpha, double beta, double gamma); | 37 jobject, |
37 void GotAcceleration(JNIEnv*, jobject, | 38 double alpha, |
38 double x, double y, double z); | 39 double beta, |
39 void GotAccelerationIncludingGravity(JNIEnv*, jobject, | 40 double gamma); |
40 double x, double y, double z); | 41 void GotAcceleration(JNIEnv*, jobject, double x, double y, double z); |
41 void GotRotationRate(JNIEnv*, jobject, | 42 void GotAccelerationIncludingGravity(JNIEnv*, |
42 double alpha, double beta, double gamma); | 43 jobject, |
| 44 double x, |
| 45 double y, |
| 46 double z); |
| 47 void GotRotationRate(JNIEnv*, |
| 48 jobject, |
| 49 double alpha, |
| 50 double beta, |
| 51 double gamma); |
43 | 52 |
44 // Shared memory related methods. | 53 // Shared memory related methods. |
45 bool StartFetchingDeviceLightData(DeviceLightHardwareBuffer* buffer); | 54 bool StartFetchingDeviceLightData(DeviceLightHardwareBuffer* buffer); |
46 void StopFetchingDeviceLightData(); | 55 void StopFetchingDeviceLightData(); |
47 | 56 |
48 bool StartFetchingDeviceMotionData(DeviceMotionHardwareBuffer* buffer); | 57 bool StartFetchingDeviceMotionData(DeviceMotionHardwareBuffer* buffer); |
49 void StopFetchingDeviceMotionData(); | 58 void StopFetchingDeviceMotionData(); |
50 | 59 |
51 bool StartFetchingDeviceOrientationData( | 60 bool StartFetchingDeviceOrientationData( |
52 DeviceOrientationHardwareBuffer* buffer); | 61 DeviceOrientationHardwareBuffer* buffer); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 base::Lock light_buffer_lock_; | 123 base::Lock light_buffer_lock_; |
115 base::Lock motion_buffer_lock_; | 124 base::Lock motion_buffer_lock_; |
116 base::Lock orientation_buffer_lock_; | 125 base::Lock orientation_buffer_lock_; |
117 | 126 |
118 bool is_using_backup_sensors_for_orientation_; | 127 bool is_using_backup_sensors_for_orientation_; |
119 bool is_shutdown_; | 128 bool is_shutdown_; |
120 | 129 |
121 DISALLOW_COPY_AND_ASSIGN(SensorManagerAndroid); | 130 DISALLOW_COPY_AND_ASSIGN(SensorManagerAndroid); |
122 }; | 131 }; |
123 | 132 |
124 } // namespace content | 133 } // namespace device |
125 | 134 |
126 #endif // CONTENT_BROWSER_DEVICE_SENSORS_SENSOR_MANAGER_ANDROID_H_ | 135 #endif // DEVICE_DEVICE_SENSORS_SENSOR_MANAGER_ANDROID_H_ |
OLD | NEW |