Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/data_fetcher_shared_memory.h" | 5 #include "content/browser/device_sensors/data_fetcher_shared_memory.h" |
| 6 | 6 |
| 7 #include "content/browser/device_sensors/sensor_manager_chromeos.h" | 7 #include "content/browser/device_sensors/sensor_manager_chromeos.h" |
| 8 | 8 |
| 9 namespace content { | 9 namespace content { |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 | 21 |
| 22 switch (consumer_type) { | 22 switch (consumer_type) { |
| 23 case CONSUMER_TYPE_MOTION: | 23 case CONSUMER_TYPE_MOTION: |
| 24 sensor_manager_->StartFetchingDeviceMotionData( | 24 sensor_manager_->StartFetchingDeviceMotionData( |
| 25 static_cast<DeviceMotionHardwareBuffer*>(buffer)); | 25 static_cast<DeviceMotionHardwareBuffer*>(buffer)); |
| 26 return true; | 26 return true; |
| 27 case CONSUMER_TYPE_ORIENTATION: | 27 case CONSUMER_TYPE_ORIENTATION: |
| 28 sensor_manager_->StartFetchingDeviceOrientationData( | 28 sensor_manager_->StartFetchingDeviceOrientationData( |
| 29 static_cast<DeviceOrientationHardwareBuffer*>(buffer)); | 29 static_cast<DeviceOrientationHardwareBuffer*>(buffer)); |
| 30 return true; | 30 return true; |
| 31 case CONSUMER_TYPE_ORIENTATION_ABSOLUTE: | 31 case CONSUMER_TYPE_ORIENTATION_ABSOLUTE: { |
| 32 orientation_absolute_buffer_ = | |
| 33 static_cast<DeviceOrientationHardwareBuffer*>(buffer); | |
| 34 // Absolute device orientation not available on Chrome OS, let the | |
| 35 // implementation fire an all-null event to signal this to blink. | |
| 36 orientation_absolute_buffer_->seqlock.WriteBegin(); | |
| 37 orientation_absolute_buffer_->data.absolute = true; | |
| 38 orientation_absolute_buffer_->data.allAvailableSensorsAreActive = true; | |
| 39 orientation_absolute_buffer_->seqlock.WriteEnd(); | |
| 40 return false; | |
| 41 } | |
| 32 case CONSUMER_TYPE_LIGHT: | 42 case CONSUMER_TYPE_LIGHT: |
| 33 NOTIMPLEMENTED(); | 43 NOTIMPLEMENTED(); |
| 34 return false; | 44 return false; |
| 35 } | 45 } |
| 36 NOTREACHED(); | 46 NOTREACHED(); |
| 37 return false; | 47 return false; |
| 38 } | 48 } |
| 39 | 49 |
| 40 bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type) { | 50 bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type) { |
| 41 switch (consumer_type) { | 51 switch (consumer_type) { |
| 42 case CONSUMER_TYPE_MOTION: | 52 case CONSUMER_TYPE_MOTION: |
| 43 return sensor_manager_->StopFetchingDeviceMotionData(); | 53 return sensor_manager_->StopFetchingDeviceMotionData(); |
| 44 case CONSUMER_TYPE_ORIENTATION: | 54 case CONSUMER_TYPE_ORIENTATION: |
| 45 return sensor_manager_->StopFetchingDeviceOrientationData(); | 55 return sensor_manager_->StopFetchingDeviceOrientationData(); |
| 46 case CONSUMER_TYPE_ORIENTATION_ABSOLUTE: | 56 case CONSUMER_TYPE_ORIENTATION_ABSOLUTE: |
| 57 // Even though absolute device orientation is not available on Chrome OS, | |
| 58 // properly cleanup, and fire an all-null event to blink. | |
|
timvolodine
2016/05/09 18:20:41
there is no "fire event" here, maybe just remove t
jonross
2016/05/10 18:01:08
Done.
| |
| 59 if (orientation_absolute_buffer_) { | |
| 60 orientation_absolute_buffer_->seqlock.WriteBegin(); | |
| 61 orientation_absolute_buffer_->data.allAvailableSensorsAreActive = false; | |
| 62 orientation_absolute_buffer_->seqlock.WriteEnd(); | |
| 63 orientation_absolute_buffer_ = nullptr; | |
| 64 } | |
| 65 return true; | |
| 47 case CONSUMER_TYPE_LIGHT: | 66 case CONSUMER_TYPE_LIGHT: |
| 48 NOTIMPLEMENTED(); | 67 NOTIMPLEMENTED(); |
| 49 return false; | 68 return false; |
| 50 } | 69 } |
| 51 NOTREACHED(); | 70 NOTREACHED(); |
| 52 return false; | 71 return false; |
| 53 } | 72 } |
| 54 | 73 |
| 55 } // namespace content | 74 } // namespace content |
| OLD | NEW |