Index: device/generic_sensor/platform_sensor_provider_base.cc |
diff --git a/device/generic_sensor/platform_sensor_provider_base.cc b/device/generic_sensor/platform_sensor_provider_base.cc |
index 51c60ac5ae25e681cefa83ed2cdec325ee9d9ccc..80c2bfc103e7f4dfd66a8b796979609d6d2a61a9 100644 |
--- a/device/generic_sensor/platform_sensor_provider_base.cc |
+++ b/device/generic_sensor/platform_sensor_provider_base.cc |
@@ -14,7 +14,7 @@ namespace device { |
namespace { |
const uint64_t kSharedBufferSizeInBytes = |
- mojom::SensorInitParams::kReadBufferSize * |
+ PlatformSensor::kReadingBufferSize * |
static_cast<uint64_t>(mojom::SensorType::LAST); |
} // namespace |
@@ -23,21 +23,19 @@ PlatformSensorProviderBase::PlatformSensorProviderBase() = default; |
PlatformSensorProviderBase::~PlatformSensorProviderBase() = default; |
scoped_refptr<PlatformSensor> PlatformSensorProviderBase::CreateSensor( |
- mojom::SensorType type, |
- uint64_t size, |
- uint64_t offset) { |
+ mojom::SensorType type) { |
DCHECK(CalledOnValidThread()); |
if (!CreateSharedBufferIfNeeded()) |
return nullptr; |
- mojo::ScopedSharedBufferMapping mapping = |
- shared_buffer_handle_->MapAtOffset(size, offset); |
+ mojo::ScopedSharedBufferMapping mapping = shared_buffer_handle_->MapAtOffset( |
+ PlatformSensor::kReadingBufferSize, GetSharedBufferOffset(type)); |
if (!mapping) |
return nullptr; |
scoped_refptr<PlatformSensor> new_sensor = |
- CreateSensorInternal(type, std::move(mapping), size); |
+ CreateSensorInternal(type, std::move(mapping)); |
if (!new_sensor) |
return nullptr; |
@@ -83,4 +81,11 @@ PlatformSensorProviderBase::CloneSharedBufferHandle() { |
return shared_buffer_handle_->Clone(); |
} |
+uint64_t PlatformSensorProviderBase::GetSharedBufferOffset( |
+ mojom::SensorType type) { |
+ return (static_cast<uint64_t>(mojom::SensorType::LAST) - |
+ static_cast<uint64_t>(type)) * |
+ PlatformSensor::kReadingBufferSize; |
+} |
+ |
} // namespace device |