| 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 if (orientation_absolute_buffer_) { |
| 58 orientation_absolute_buffer_->seqlock.WriteBegin(); |
| 59 orientation_absolute_buffer_->data.allAvailableSensorsAreActive = false; |
| 60 orientation_absolute_buffer_->seqlock.WriteEnd(); |
| 61 orientation_absolute_buffer_ = nullptr; |
| 62 } |
| 63 return true; |
| 47 case CONSUMER_TYPE_LIGHT: | 64 case CONSUMER_TYPE_LIGHT: |
| 48 NOTIMPLEMENTED(); | 65 NOTIMPLEMENTED(); |
| 49 return false; | 66 return false; |
| 50 } | 67 } |
| 51 NOTREACHED(); | 68 NOTREACHED(); |
| 52 return false; | 69 return false; |
| 53 } | 70 } |
| 54 | 71 |
| 55 } // namespace content | 72 } // namespace content |
| OLD | NEW |