Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Unified Diff: device/generic_sensor/platform_sensor_provider_base.cc

Issue 2395853003: [Sensors] Improvements in shared buffer managing (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698