| Index: content/browser/device_orientation/sensor_manager_android.cc
|
| diff --git a/content/browser/device_orientation/sensor_manager_android.cc b/content/browser/device_orientation/sensor_manager_android.cc
|
| index cec2c5e6a5eaba9bc30fc4d99fc09ac0b74fde53..77afb71abc3119b927c2fef8261c6832c2ed4c13 100644
|
| --- a/content/browser/device_orientation/sensor_manager_android.cc
|
| +++ b/content/browser/device_orientation/sensor_manager_android.cc
|
| @@ -26,8 +26,10 @@ namespace content {
|
|
|
| SensorManagerAndroid::SensorManagerAndroid()
|
| : number_active_device_motion_sensors_(0),
|
| + device_light_buffer_(NULL),
|
| device_motion_buffer_(NULL),
|
| device_orientation_buffer_(NULL),
|
| + is_light_buffer_ready_(false),
|
| is_motion_buffer_ready_(false),
|
| is_orientation_buffer_ready_(false) {
|
| memset(received_motion_data_, 0, sizeof(received_motion_data_));
|
| @@ -137,6 +139,23 @@ void SensorManagerAndroid::GotRotationRate(
|
| }
|
| }
|
|
|
| +void SensorManagerAndroid::GotLight(
|
| + JNIEnv*, jobject, double value) {
|
| + base::AutoLock autolock(light_buffer_lock_);
|
| +
|
| + if (!device_light_buffer_)
|
| + return;
|
| +
|
| + device_light_buffer_->seqlock.WriteBegin();
|
| + device_light_buffer_->data = value;
|
| +
|
| + device_light_buffer_->seqlock.WriteEnd();
|
| +
|
| + if (!is_light_buffer_ready_) {
|
| + SetLightBufferReadyStatus(true);
|
| + }
|
| +}
|
| +
|
| bool SensorManagerAndroid::Start(EventType event_type) {
|
| DCHECK(!device_orientation_.is_null());
|
| return Java_DeviceMotionAndOrientation_start(
|
| @@ -161,6 +180,45 @@ int SensorManagerAndroid::GetNumberActiveDeviceMotionSensors() {
|
|
|
| // ----- Shared memory API methods
|
|
|
| +// --- Device Light
|
| +
|
| +bool SensorManagerAndroid::StartFetchingDeviceLightData(
|
| + DeviceLightHardwareBuffer* buffer) {
|
| + DCHECK(buffer);
|
| + {
|
| + base::AutoLock autolock(light_buffer_lock_);
|
| + device_light_buffer_ = buffer;
|
| + ClearInternalLightBuffers();
|
| + }
|
| + bool success = Start(kTypeLight);
|
| + {
|
| + base::AutoLock autolock(light_buffer_lock_);
|
| + // If Start() was unsuccessful then set the buffer ready flag to true
|
| + // to start firing all-null events.
|
| + SetLightBufferReadyStatus(!success);
|
| + }
|
| + return success;
|
| +}
|
| +
|
| +void SensorManagerAndroid::StopFetchingDeviceLightData() {
|
| + Stop(kTypeLight);
|
| + {
|
| + base::AutoLock autolock(light_buffer_lock_);
|
| + if (device_light_buffer_) {
|
| + ClearInternalLightBuffers();
|
| + device_light_buffer_ = NULL;
|
| + }
|
| + }
|
| +}
|
| +
|
| +void SensorManagerAndroid::SetLightBufferReadyStatus(bool ready) {
|
| + is_light_buffer_ready_ = ready;
|
| +}
|
| +
|
| +void SensorManagerAndroid::ClearInternalLightBuffers() {
|
| + SetLightBufferReadyStatus(false);
|
| +}
|
| +
|
| // --- Device Motion
|
|
|
| bool SensorManagerAndroid::StartFetchingDeviceMotionData(
|
|
|