| Index: device/generic_sensor/platform_sensor_linux.cc
|
| diff --git a/device/generic_sensor/platform_sensor_linux.cc b/device/generic_sensor/platform_sensor_linux.cc
|
| index 55aa1398d1499c7bd61bfc4ec10b1199b5087c85..0252f2e30dc822f10745736e7aa09cb84af23ef5 100644
|
| --- a/device/generic_sensor/platform_sensor_linux.cc
|
| +++ b/device/generic_sensor/platform_sensor_linux.cc
|
| @@ -24,17 +24,23 @@ PlatformSensorLinux::PlatformSensorLinux(
|
| mojo::ScopedSharedBufferMapping mapping,
|
| PlatformSensorProvider* provider,
|
| const SensorInfoLinux* sensor_device,
|
| + std::unique_ptr<SensorReader> sensor_reader,
|
| scoped_refptr<base::SingleThreadTaskRunner> polling_thread_task_runner)
|
| : PlatformSensor(type, std::move(mapping), provider),
|
| default_configuration_(
|
| PlatformSensorConfiguration(sensor_device->device_frequency)),
|
| reporting_mode_(sensor_device->reporting_mode),
|
| + polling_thread_task_runner_(std::move(polling_thread_task_runner)),
|
| + sensor_reader_(std::move(sensor_reader)),
|
| weak_factory_(this) {
|
| - sensor_reader_ =
|
| - SensorReader::Create(sensor_device, this, polling_thread_task_runner);
|
| + DCHECK(sensor_reader_);
|
| + sensor_reader_->SetPlatformSensorLinux(this);
|
| }
|
|
|
| -PlatformSensorLinux::~PlatformSensorLinux() = default;
|
| +PlatformSensorLinux::~PlatformSensorLinux() {
|
| + DCHECK(task_runner_->BelongsToCurrentThread());
|
| + polling_thread_task_runner_->DeleteSoon(FROM_HERE, sensor_reader_.release());
|
| +}
|
|
|
| mojom::ReportingMode PlatformSensorLinux::GetReportingMode() {
|
| DCHECK(task_runner_->BelongsToCurrentThread());
|
| @@ -62,15 +68,18 @@ void PlatformSensorLinux::NotifyPlatformSensorError() {
|
| bool PlatformSensorLinux::StartSensor(
|
| const PlatformSensorConfiguration& configuration) {
|
| DCHECK(task_runner_->BelongsToCurrentThread());
|
| - if (!sensor_reader_)
|
| - return false;
|
| - return sensor_reader_->StartFetchingData(configuration);
|
| + polling_thread_task_runner_->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&SensorReader::StartFetchingData,
|
| + base::Unretained(sensor_reader_.get()), configuration));
|
| + return true;
|
| }
|
|
|
| void PlatformSensorLinux::StopSensor() {
|
| DCHECK(task_runner_->BelongsToCurrentThread());
|
| - DCHECK(sensor_reader_);
|
| - sensor_reader_->StopFetchingData();
|
| + polling_thread_task_runner_->PostTask(
|
| + FROM_HERE, base::Bind(&SensorReader::StopFetchingData,
|
| + base::Unretained(sensor_reader_.get())));
|
| }
|
|
|
| bool PlatformSensorLinux::CheckSensorConfiguration(
|
|
|