Chromium Code Reviews| 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 "data_fetcher_shared_memory.h" | 5 #include "data_fetcher_shared_memory.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "content/public/browser/sensor_manager.h" | |
| 9 | 10 |
| 10 namespace { | 11 namespace { |
| 11 | 12 |
| 12 static bool SetMotionBuffer(content::DeviceMotionHardwareBuffer* buffer, | 13 static bool SetMotionBuffer(content::DeviceMotionHardwareBuffer* buffer, |
| 13 bool enabled) { | 14 bool enabled) { |
| 14 if (!buffer) | 15 if (!buffer) |
| 15 return false; | 16 return false; |
| 16 buffer->seqlock.WriteBegin(); | 17 buffer->seqlock.WriteBegin(); |
| 17 buffer->data.allAvailableSensorsAreActive = enabled; | 18 buffer->data.allAvailableSensorsAreActive = enabled; |
| 18 buffer->seqlock.WriteEnd(); | 19 buffer->seqlock.WriteEnd(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 switch (consumer_type) { | 57 switch (consumer_type) { |
| 57 case CONSUMER_TYPE_MOTION: | 58 case CONSUMER_TYPE_MOTION: |
| 58 motion_buffer_ = static_cast<DeviceMotionHardwareBuffer*>(buffer); | 59 motion_buffer_ = static_cast<DeviceMotionHardwareBuffer*>(buffer); |
| 59 UMA_HISTOGRAM_BOOLEAN("InertialSensor.MotionDefaultAvailable", false); | 60 UMA_HISTOGRAM_BOOLEAN("InertialSensor.MotionDefaultAvailable", false); |
| 60 return SetMotionBuffer(motion_buffer_, true); | 61 return SetMotionBuffer(motion_buffer_, true); |
| 61 case CONSUMER_TYPE_ORIENTATION: | 62 case CONSUMER_TYPE_ORIENTATION: |
| 62 orientation_buffer_ = | 63 orientation_buffer_ = |
| 63 static_cast<DeviceOrientationHardwareBuffer*>(buffer); | 64 static_cast<DeviceOrientationHardwareBuffer*>(buffer); |
| 64 UMA_HISTOGRAM_BOOLEAN("InertialSensor.OrientationDefaultAvailable", | 65 UMA_HISTOGRAM_BOOLEAN("InertialSensor.OrientationDefaultAvailable", |
| 65 false); | 66 false); |
| 67 SensorManager::GetInstance()->StartFetchingDeviceOrientationData( | |
|
timvolodine
2014/11/06 02:53:47
this line shouldn't be here. the purpose of _defau
jonross
2014/11/06 18:18:52
Done.
| |
| 68 orientation_buffer_); | |
| 66 return SetOrientationBuffer(orientation_buffer_, true); | 69 return SetOrientationBuffer(orientation_buffer_, true); |
| 67 case CONSUMER_TYPE_LIGHT: | 70 case CONSUMER_TYPE_LIGHT: |
| 68 light_buffer_ = static_cast<DeviceLightHardwareBuffer*>(buffer); | 71 light_buffer_ = static_cast<DeviceLightHardwareBuffer*>(buffer); |
| 69 return SetLightBuffer(light_buffer_, | 72 return SetLightBuffer(light_buffer_, |
| 70 std::numeric_limits<double>::infinity()); | 73 std::numeric_limits<double>::infinity()); |
| 71 default: | 74 default: |
| 72 NOTREACHED(); | 75 NOTREACHED(); |
| 73 } | 76 } |
| 74 return false; | 77 return false; |
| 75 } | 78 } |
| 76 | 79 |
| 77 bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type) { | 80 bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type) { |
| 78 switch (consumer_type) { | 81 switch (consumer_type) { |
| 79 case CONSUMER_TYPE_MOTION: | 82 case CONSUMER_TYPE_MOTION: |
| 80 return SetMotionBuffer(motion_buffer_, false); | 83 return SetMotionBuffer(motion_buffer_, false); |
| 81 case CONSUMER_TYPE_ORIENTATION: | 84 case CONSUMER_TYPE_ORIENTATION: |
| 85 SensorManager::GetInstance()->StopFetchingDeviceOrientationData(); | |
| 82 return SetOrientationBuffer(orientation_buffer_, false); | 86 return SetOrientationBuffer(orientation_buffer_, false); |
| 83 case CONSUMER_TYPE_LIGHT: | 87 case CONSUMER_TYPE_LIGHT: |
| 84 return SetLightBuffer(light_buffer_, -1); | 88 return SetLightBuffer(light_buffer_, -1); |
| 85 default: | 89 default: |
| 86 NOTREACHED(); | 90 NOTREACHED(); |
| 87 } | 91 } |
| 88 return false; | 92 return false; |
| 89 } | 93 } |
| 90 | 94 |
| 91 } // namespace content | 95 } // namespace content |
| OLD | NEW |