| 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 #include "content/browser/device_sensors/sensor_manager_android.h" | 5 #include "device/device_sensors/sensor_manager_android.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "content/browser/device_sensors/inertial_sensor_consts.h" | 13 #include "device/device_sensors/inertial_sensor_consts.h" |
| 14 #include "content/public/browser/browser_thread.h" | 14 //#include "content/public/browser/browser_thread.h" |
| 15 #include "jni/DeviceSensors_jni.h" | 15 //#include "jni/DeviceSensors_jni.h" |
| 16 | 16 |
| 17 using base::android::AttachCurrentThread; | 17 using base::android::AttachCurrentThread; |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 enum OrientationSensorType { | 21 enum OrientationSensorType { |
| 22 NOT_AVAILABLE = 0, | 22 NOT_AVAILABLE = 0, |
| 23 ROTATION_VECTOR = 1, | 23 ROTATION_VECTOR = 1, |
| 24 ACCELEROMETER_MAGNETIC = 2, | 24 ACCELEROMETER_MAGNETIC = 2, |
| 25 ORIENTATION_SENSOR_MAX = 3, | 25 ORIENTATION_SENSOR_MAX = 3, |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 void UpdateDeviceOrientationHistogram(OrientationSensorType type) { | 28 void UpdateDeviceOrientationHistogram(OrientationSensorType type) { |
| 29 UMA_HISTOGRAM_ENUMERATION("InertialSensor.DeviceOrientationSensorAndroid", | 29 UMA_HISTOGRAM_ENUMERATION("InertialSensor.DeviceOrientationSensorAndroid", |
| 30 type, | 30 type, ORIENTATION_SENSOR_MAX); |
| 31 ORIENTATION_SENSOR_MAX); | |
| 32 } | 31 } |
| 33 | 32 |
| 34 } // namespace | 33 } // namespace |
| 35 | 34 |
| 36 namespace content { | 35 namespace content { |
| 37 | 36 |
| 38 SensorManagerAndroid::SensorManagerAndroid() | 37 SensorManagerAndroid::SensorManagerAndroid() |
| 39 : number_active_device_motion_sensors_(0), | 38 : number_active_device_motion_sensors_(0), |
| 40 device_light_buffer_(nullptr), | 39 device_light_buffer_(nullptr), |
| 41 device_motion_buffer_(nullptr), | 40 device_motion_buffer_(nullptr), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 52 | 51 |
| 53 SensorManagerAndroid::~SensorManagerAndroid() { | 52 SensorManagerAndroid::~SensorManagerAndroid() { |
| 54 } | 53 } |
| 55 | 54 |
| 56 bool SensorManagerAndroid::Register(JNIEnv* env) { | 55 bool SensorManagerAndroid::Register(JNIEnv* env) { |
| 57 return RegisterNativesImpl(env); | 56 return RegisterNativesImpl(env); |
| 58 } | 57 } |
| 59 | 58 |
| 60 SensorManagerAndroid* SensorManagerAndroid::GetInstance() { | 59 SensorManagerAndroid* SensorManagerAndroid::GetInstance() { |
| 61 return Singleton<SensorManagerAndroid, | 60 return Singleton<SensorManagerAndroid, |
| 62 LeakySingletonTraits<SensorManagerAndroid> >::get(); | 61 LeakySingletonTraits<SensorManagerAndroid>>::get(); |
| 63 } | 62 } |
| 64 | 63 |
| 65 void SensorManagerAndroid::GotOrientation( | 64 void SensorManagerAndroid::GotOrientation(JNIEnv*, |
| 66 JNIEnv*, jobject, double alpha, double beta, double gamma) { | 65 jobject, |
| 66 double alpha, |
| 67 double beta, |
| 68 double gamma) { |
| 67 base::AutoLock autolock(orientation_buffer_lock_); | 69 base::AutoLock autolock(orientation_buffer_lock_); |
| 68 | 70 |
| 69 if (!device_orientation_buffer_) | 71 if (!device_orientation_buffer_) |
| 70 return; | 72 return; |
| 71 | 73 |
| 72 device_orientation_buffer_->seqlock.WriteBegin(); | 74 device_orientation_buffer_->seqlock.WriteBegin(); |
| 73 device_orientation_buffer_->data.alpha = alpha; | 75 device_orientation_buffer_->data.alpha = alpha; |
| 74 device_orientation_buffer_->data.hasAlpha = true; | 76 device_orientation_buffer_->data.hasAlpha = true; |
| 75 device_orientation_buffer_->data.beta = beta; | 77 device_orientation_buffer_->data.beta = beta; |
| 76 device_orientation_buffer_->data.hasBeta = true; | 78 device_orientation_buffer_->data.hasBeta = true; |
| 77 device_orientation_buffer_->data.gamma = gamma; | 79 device_orientation_buffer_->data.gamma = gamma; |
| 78 device_orientation_buffer_->data.hasGamma = true; | 80 device_orientation_buffer_->data.hasGamma = true; |
| 79 device_orientation_buffer_->seqlock.WriteEnd(); | 81 device_orientation_buffer_->seqlock.WriteEnd(); |
| 80 | 82 |
| 81 if (!is_orientation_buffer_ready_) { | 83 if (!is_orientation_buffer_ready_) { |
| 82 SetOrientationBufferReadyStatus(true); | 84 SetOrientationBufferReadyStatus(true); |
| 83 UpdateDeviceOrientationHistogram(is_using_backup_sensors_for_orientation_ | 85 UpdateDeviceOrientationHistogram(is_using_backup_sensors_for_orientation_ |
| 84 ? ACCELEROMETER_MAGNETIC : ROTATION_VECTOR); | 86 ? ACCELEROMETER_MAGNETIC |
| 87 : ROTATION_VECTOR); |
| 85 } | 88 } |
| 86 } | 89 } |
| 87 | 90 |
| 88 void SensorManagerAndroid::GotAcceleration( | 91 void SensorManagerAndroid::GotAcceleration(JNIEnv*, |
| 89 JNIEnv*, jobject, double x, double y, double z) { | 92 jobject, |
| 93 double x, |
| 94 double y, |
| 95 double z) { |
| 90 base::AutoLock autolock(motion_buffer_lock_); | 96 base::AutoLock autolock(motion_buffer_lock_); |
| 91 | 97 |
| 92 if (!device_motion_buffer_) | 98 if (!device_motion_buffer_) |
| 93 return; | 99 return; |
| 94 | 100 |
| 95 device_motion_buffer_->seqlock.WriteBegin(); | 101 device_motion_buffer_->seqlock.WriteBegin(); |
| 96 device_motion_buffer_->data.accelerationX = x; | 102 device_motion_buffer_->data.accelerationX = x; |
| 97 device_motion_buffer_->data.hasAccelerationX = true; | 103 device_motion_buffer_->data.hasAccelerationX = true; |
| 98 device_motion_buffer_->data.accelerationY = y; | 104 device_motion_buffer_->data.accelerationY = y; |
| 99 device_motion_buffer_->data.hasAccelerationY = true; | 105 device_motion_buffer_->data.hasAccelerationY = true; |
| 100 device_motion_buffer_->data.accelerationZ = z; | 106 device_motion_buffer_->data.accelerationZ = z; |
| 101 device_motion_buffer_->data.hasAccelerationZ = true; | 107 device_motion_buffer_->data.hasAccelerationZ = true; |
| 102 device_motion_buffer_->seqlock.WriteEnd(); | 108 device_motion_buffer_->seqlock.WriteEnd(); |
| 103 | 109 |
| 104 if (!is_motion_buffer_ready_) { | 110 if (!is_motion_buffer_ready_) { |
| 105 received_motion_data_[RECEIVED_MOTION_DATA_ACCELERATION] = 1; | 111 received_motion_data_[RECEIVED_MOTION_DATA_ACCELERATION] = 1; |
| 106 CheckMotionBufferReadyToRead(); | 112 CheckMotionBufferReadyToRead(); |
| 107 } | 113 } |
| 108 } | 114 } |
| 109 | 115 |
| 110 void SensorManagerAndroid::GotAccelerationIncludingGravity( | 116 void SensorManagerAndroid::GotAccelerationIncludingGravity(JNIEnv*, |
| 111 JNIEnv*, jobject, double x, double y, double z) { | 117 jobject, |
| 118 double x, |
| 119 double y, |
| 120 double z) { |
| 112 base::AutoLock autolock(motion_buffer_lock_); | 121 base::AutoLock autolock(motion_buffer_lock_); |
| 113 | 122 |
| 114 if (!device_motion_buffer_) | 123 if (!device_motion_buffer_) |
| 115 return; | 124 return; |
| 116 | 125 |
| 117 device_motion_buffer_->seqlock.WriteBegin(); | 126 device_motion_buffer_->seqlock.WriteBegin(); |
| 118 device_motion_buffer_->data.accelerationIncludingGravityX = x; | 127 device_motion_buffer_->data.accelerationIncludingGravityX = x; |
| 119 device_motion_buffer_->data.hasAccelerationIncludingGravityX = true; | 128 device_motion_buffer_->data.hasAccelerationIncludingGravityX = true; |
| 120 device_motion_buffer_->data.accelerationIncludingGravityY = y; | 129 device_motion_buffer_->data.accelerationIncludingGravityY = y; |
| 121 device_motion_buffer_->data.hasAccelerationIncludingGravityY = true; | 130 device_motion_buffer_->data.hasAccelerationIncludingGravityY = true; |
| 122 device_motion_buffer_->data.accelerationIncludingGravityZ = z; | 131 device_motion_buffer_->data.accelerationIncludingGravityZ = z; |
| 123 device_motion_buffer_->data.hasAccelerationIncludingGravityZ = true; | 132 device_motion_buffer_->data.hasAccelerationIncludingGravityZ = true; |
| 124 device_motion_buffer_->seqlock.WriteEnd(); | 133 device_motion_buffer_->seqlock.WriteEnd(); |
| 125 | 134 |
| 126 if (!is_motion_buffer_ready_) { | 135 if (!is_motion_buffer_ready_) { |
| 127 received_motion_data_[RECEIVED_MOTION_DATA_ACCELERATION_INCL_GRAVITY] = 1; | 136 received_motion_data_[RECEIVED_MOTION_DATA_ACCELERATION_INCL_GRAVITY] = 1; |
| 128 CheckMotionBufferReadyToRead(); | 137 CheckMotionBufferReadyToRead(); |
| 129 } | 138 } |
| 130 } | 139 } |
| 131 | 140 |
| 132 void SensorManagerAndroid::GotRotationRate( | 141 void SensorManagerAndroid::GotRotationRate(JNIEnv*, |
| 133 JNIEnv*, jobject, double alpha, double beta, double gamma) { | 142 jobject, |
| 143 double alpha, |
| 144 double beta, |
| 145 double gamma) { |
| 134 base::AutoLock autolock(motion_buffer_lock_); | 146 base::AutoLock autolock(motion_buffer_lock_); |
| 135 | 147 |
| 136 if (!device_motion_buffer_) | 148 if (!device_motion_buffer_) |
| 137 return; | 149 return; |
| 138 | 150 |
| 139 device_motion_buffer_->seqlock.WriteBegin(); | 151 device_motion_buffer_->seqlock.WriteBegin(); |
| 140 device_motion_buffer_->data.rotationRateAlpha = alpha; | 152 device_motion_buffer_->data.rotationRateAlpha = alpha; |
| 141 device_motion_buffer_->data.hasRotationRateAlpha = true; | 153 device_motion_buffer_->data.hasRotationRateAlpha = true; |
| 142 device_motion_buffer_->data.rotationRateBeta = beta; | 154 device_motion_buffer_->data.rotationRateBeta = beta; |
| 143 device_motion_buffer_->data.hasRotationRateBeta = true; | 155 device_motion_buffer_->data.hasRotationRateBeta = true; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 160 device_light_buffer_->seqlock.WriteBegin(); | 172 device_light_buffer_->seqlock.WriteBegin(); |
| 161 device_light_buffer_->data.value = value; | 173 device_light_buffer_->data.value = value; |
| 162 device_light_buffer_->seqlock.WriteEnd(); | 174 device_light_buffer_->seqlock.WriteEnd(); |
| 163 } | 175 } |
| 164 | 176 |
| 165 bool SensorManagerAndroid::Start(EventType event_type) { | 177 bool SensorManagerAndroid::Start(EventType event_type) { |
| 166 DCHECK(!device_sensors_.is_null()); | 178 DCHECK(!device_sensors_.is_null()); |
| 167 int rate_in_microseconds = (event_type == kTypeLight) | 179 int rate_in_microseconds = (event_type == kTypeLight) |
| 168 ? kLightSensorIntervalMicroseconds | 180 ? kLightSensorIntervalMicroseconds |
| 169 : kInertialSensorIntervalMicroseconds; | 181 : kInertialSensorIntervalMicroseconds; |
| 170 return Java_DeviceSensors_start(AttachCurrentThread(), | 182 return Java_DeviceSensors_start(AttachCurrentThread(), device_sensors_.obj(), |
| 171 device_sensors_.obj(), | |
| 172 reinterpret_cast<intptr_t>(this), | 183 reinterpret_cast<intptr_t>(this), |
| 173 static_cast<jint>(event_type), | 184 static_cast<jint>(event_type), |
| 174 rate_in_microseconds); | 185 rate_in_microseconds); |
| 175 } | 186 } |
| 176 | 187 |
| 177 void SensorManagerAndroid::Stop(EventType event_type) { | 188 void SensorManagerAndroid::Stop(EventType event_type) { |
| 178 DCHECK(!device_sensors_.is_null()); | 189 DCHECK(!device_sensors_.is_null()); |
| 179 Java_DeviceSensors_stop(AttachCurrentThread(), | 190 Java_DeviceSensors_stop(AttachCurrentThread(), device_sensors_.obj(), |
| 180 device_sensors_.obj(), | |
| 181 static_cast<jint>(event_type)); | 191 static_cast<jint>(event_type)); |
| 182 } | 192 } |
| 183 | 193 |
| 184 int SensorManagerAndroid::GetNumberActiveDeviceMotionSensors() { | 194 int SensorManagerAndroid::GetNumberActiveDeviceMotionSensors() { |
| 185 DCHECK(!device_sensors_.is_null()); | 195 DCHECK(!device_sensors_.is_null()); |
| 186 return Java_DeviceSensors_getNumberActiveDeviceMotionSensors( | 196 return Java_DeviceSensors_getNumberActiveDeviceMotionSensors( |
| 187 AttachCurrentThread(), device_sensors_.obj()); | 197 AttachCurrentThread(), device_sensors_.obj()); |
| 188 } | 198 } |
| 189 | 199 |
| 190 bool SensorManagerAndroid::isUsingBackupSensorsForOrientation() { | 200 bool SensorManagerAndroid::isUsingBackupSensorsForOrientation() { |
| 191 DCHECK(!device_sensors_.is_null()); | 201 DCHECK(!device_sensors_.is_null()); |
| 192 return Java_DeviceSensors_isUsingBackupSensorsForOrientation( | 202 return Java_DeviceSensors_isUsingBackupSensorsForOrientation( |
| 193 AttachCurrentThread(), device_sensors_.obj()); | 203 AttachCurrentThread(), device_sensors_.obj()); |
| 194 } | 204 } |
| 195 | 205 |
| 196 // ----- Shared memory API methods | 206 // ----- Shared memory API methods |
| 197 | 207 |
| 198 // --- Device Light | 208 // --- Device Light |
| 199 | 209 |
| 200 bool SensorManagerAndroid::StartFetchingDeviceLightData( | 210 bool SensorManagerAndroid::StartFetchingDeviceLightData( |
| 201 DeviceLightHardwareBuffer* buffer) { | 211 DeviceLightHardwareBuffer* buffer) { |
| 202 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 212 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 203 StartFetchingLightDataOnUI(buffer); | 213 StartFetchingLightDataOnUI(buffer); |
| 204 } else { | 214 } else { |
| 205 BrowserThread::PostTask( | 215 BrowserThread::PostTask( |
| 206 BrowserThread::UI, FROM_HERE, | 216 BrowserThread::UI, FROM_HERE, |
| 207 base::Bind(&SensorManagerAndroid::StartFetchingLightDataOnUI, | 217 base::Bind(&SensorManagerAndroid::StartFetchingLightDataOnUI, |
| 208 base::Unretained(this), | 218 base::Unretained(this), buffer)); |
| 209 buffer)); | |
| 210 } | 219 } |
| 211 return true; | 220 return true; |
| 212 } | 221 } |
| 213 | 222 |
| 214 void SensorManagerAndroid::StartFetchingLightDataOnUI( | 223 void SensorManagerAndroid::StartFetchingLightDataOnUI( |
| 215 DeviceLightHardwareBuffer* buffer) { | 224 DeviceLightHardwareBuffer* buffer) { |
| 216 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 225 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 217 DCHECK(buffer); | 226 DCHECK(buffer); |
| 218 if (is_shutdown_) | 227 if (is_shutdown_) |
| 219 return; | 228 return; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 // --- Device Motion | 275 // --- Device Motion |
| 267 | 276 |
| 268 bool SensorManagerAndroid::StartFetchingDeviceMotionData( | 277 bool SensorManagerAndroid::StartFetchingDeviceMotionData( |
| 269 DeviceMotionHardwareBuffer* buffer) { | 278 DeviceMotionHardwareBuffer* buffer) { |
| 270 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 279 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 271 StartFetchingMotionDataOnUI(buffer); | 280 StartFetchingMotionDataOnUI(buffer); |
| 272 } else { | 281 } else { |
| 273 BrowserThread::PostTask( | 282 BrowserThread::PostTask( |
| 274 BrowserThread::UI, FROM_HERE, | 283 BrowserThread::UI, FROM_HERE, |
| 275 base::Bind(&SensorManagerAndroid::StartFetchingMotionDataOnUI, | 284 base::Bind(&SensorManagerAndroid::StartFetchingMotionDataOnUI, |
| 276 base::Unretained(this), | 285 base::Unretained(this), buffer)); |
| 277 buffer)); | |
| 278 } | 286 } |
| 279 return true; | 287 return true; |
| 280 } | 288 } |
| 281 | 289 |
| 282 void SensorManagerAndroid::StartFetchingMotionDataOnUI( | 290 void SensorManagerAndroid::StartFetchingMotionDataOnUI( |
| 283 DeviceMotionHardwareBuffer* buffer) { | 291 DeviceMotionHardwareBuffer* buffer) { |
| 284 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 292 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 285 DCHECK(buffer); | 293 DCHECK(buffer); |
| 286 if (is_shutdown_) | 294 if (is_shutdown_) |
| 287 return; | 295 return; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 base::AutoLock autolock(motion_buffer_lock_); | 333 base::AutoLock autolock(motion_buffer_lock_); |
| 326 if (device_motion_buffer_) { | 334 if (device_motion_buffer_) { |
| 327 ClearInternalMotionBuffers(); | 335 ClearInternalMotionBuffers(); |
| 328 device_motion_buffer_ = nullptr; | 336 device_motion_buffer_ = nullptr; |
| 329 } | 337 } |
| 330 } | 338 } |
| 331 } | 339 } |
| 332 | 340 |
| 333 void SensorManagerAndroid::CheckMotionBufferReadyToRead() { | 341 void SensorManagerAndroid::CheckMotionBufferReadyToRead() { |
| 334 if (received_motion_data_[RECEIVED_MOTION_DATA_ACCELERATION] + | 342 if (received_motion_data_[RECEIVED_MOTION_DATA_ACCELERATION] + |
| 335 received_motion_data_[RECEIVED_MOTION_DATA_ACCELERATION_INCL_GRAVITY] + | 343 received_motion_data_ |
| 336 received_motion_data_[RECEIVED_MOTION_DATA_ROTATION_RATE] == | 344 [RECEIVED_MOTION_DATA_ACCELERATION_INCL_GRAVITY] + |
| 345 received_motion_data_[RECEIVED_MOTION_DATA_ROTATION_RATE] == |
| 337 number_active_device_motion_sensors_) { | 346 number_active_device_motion_sensors_) { |
| 338 device_motion_buffer_->seqlock.WriteBegin(); | 347 device_motion_buffer_->seqlock.WriteBegin(); |
| 339 device_motion_buffer_->data.interval = | 348 device_motion_buffer_->data.interval = |
| 340 kInertialSensorIntervalMicroseconds / 1000.; | 349 kInertialSensorIntervalMicroseconds / 1000.; |
| 341 device_motion_buffer_->seqlock.WriteEnd(); | 350 device_motion_buffer_->seqlock.WriteEnd(); |
| 342 SetMotionBufferReadyStatus(true); | 351 SetMotionBufferReadyStatus(true); |
| 343 | 352 |
| 344 UMA_HISTOGRAM_BOOLEAN("InertialSensor.AccelerometerAndroidAvailable", | 353 UMA_HISTOGRAM_BOOLEAN( |
| 354 "InertialSensor.AccelerometerAndroidAvailable", |
| 345 received_motion_data_[RECEIVED_MOTION_DATA_ACCELERATION] > 0); | 355 received_motion_data_[RECEIVED_MOTION_DATA_ACCELERATION] > 0); |
| 346 UMA_HISTOGRAM_BOOLEAN( | 356 UMA_HISTOGRAM_BOOLEAN( |
| 347 "InertialSensor.AccelerometerIncGravityAndroidAvailable", | 357 "InertialSensor.AccelerometerIncGravityAndroidAvailable", |
| 348 received_motion_data_[RECEIVED_MOTION_DATA_ACCELERATION_INCL_GRAVITY] | 358 received_motion_data_[RECEIVED_MOTION_DATA_ACCELERATION_INCL_GRAVITY] > |
| 349 > 0); | 359 0); |
| 350 UMA_HISTOGRAM_BOOLEAN("InertialSensor.GyroscopeAndroidAvailable", | 360 UMA_HISTOGRAM_BOOLEAN( |
| 361 "InertialSensor.GyroscopeAndroidAvailable", |
| 351 received_motion_data_[RECEIVED_MOTION_DATA_ROTATION_RATE] > 0); | 362 received_motion_data_[RECEIVED_MOTION_DATA_ROTATION_RATE] > 0); |
| 352 } | 363 } |
| 353 } | 364 } |
| 354 | 365 |
| 355 void SensorManagerAndroid::SetMotionBufferReadyStatus(bool ready) { | 366 void SensorManagerAndroid::SetMotionBufferReadyStatus(bool ready) { |
| 356 device_motion_buffer_->seqlock.WriteBegin(); | 367 device_motion_buffer_->seqlock.WriteBegin(); |
| 357 device_motion_buffer_->data.allAvailableSensorsAreActive = ready; | 368 device_motion_buffer_->data.allAvailableSensorsAreActive = ready; |
| 358 device_motion_buffer_->seqlock.WriteEnd(); | 369 device_motion_buffer_->seqlock.WriteEnd(); |
| 359 is_motion_buffer_ready_ = ready; | 370 is_motion_buffer_ready_ = ready; |
| 360 } | 371 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 377 } | 388 } |
| 378 | 389 |
| 379 bool SensorManagerAndroid::StartFetchingDeviceOrientationData( | 390 bool SensorManagerAndroid::StartFetchingDeviceOrientationData( |
| 380 DeviceOrientationHardwareBuffer* buffer) { | 391 DeviceOrientationHardwareBuffer* buffer) { |
| 381 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 392 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 382 StartFetchingOrientationDataOnUI(buffer); | 393 StartFetchingOrientationDataOnUI(buffer); |
| 383 } else { | 394 } else { |
| 384 BrowserThread::PostTask( | 395 BrowserThread::PostTask( |
| 385 BrowserThread::UI, FROM_HERE, | 396 BrowserThread::UI, FROM_HERE, |
| 386 base::Bind(&SensorManagerAndroid::StartFetchingOrientationDataOnUI, | 397 base::Bind(&SensorManagerAndroid::StartFetchingOrientationDataOnUI, |
| 387 base::Unretained(this), | 398 base::Unretained(this), buffer)); |
| 388 buffer)); | |
| 389 } | 399 } |
| 390 return true; | 400 return true; |
| 391 } | 401 } |
| 392 | 402 |
| 393 void SensorManagerAndroid::StartFetchingOrientationDataOnUI( | 403 void SensorManagerAndroid::StartFetchingOrientationDataOnUI( |
| 394 DeviceOrientationHardwareBuffer* buffer) { | 404 DeviceOrientationHardwareBuffer* buffer) { |
| 395 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 405 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 396 DCHECK(buffer); | 406 DCHECK(buffer); |
| 397 if (is_shutdown_) | 407 if (is_shutdown_) |
| 398 return; | 408 return; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 } | 454 } |
| 445 } | 455 } |
| 446 } | 456 } |
| 447 | 457 |
| 448 void SensorManagerAndroid::Shutdown() { | 458 void SensorManagerAndroid::Shutdown() { |
| 449 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 459 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 450 is_shutdown_ = true; | 460 is_shutdown_ = true; |
| 451 } | 461 } |
| 452 | 462 |
| 453 } // namespace content | 463 } // namespace content |
| OLD | NEW |