| Index: device/generic_sensor/sensor_impl.cc
|
| diff --git a/device/generic_sensor/sensor_impl.cc b/device/generic_sensor/sensor_impl.cc
|
| index 33e9cd0bb2a0f14e81f6cbcdaedfbe5e4c4da948..3f82419c424e35b2e34573880006594a9de033f8 100644
|
| --- a/device/generic_sensor/sensor_impl.cc
|
| +++ b/device/generic_sensor/sensor_impl.cc
|
| @@ -11,7 +11,9 @@
|
| namespace device {
|
|
|
| SensorImpl::SensorImpl(scoped_refptr<PlatformSensor> sensor)
|
| - : sensor_(std::move(sensor)), suspended_(false) {
|
| + : sensor_(std::move(sensor)),
|
| + suspended_(false),
|
| + suppress_on_change_events_count_(0) {
|
| sensor_->AddClient(this);
|
| }
|
|
|
| @@ -28,7 +30,10 @@ void SensorImpl::AddConfiguration(
|
| AddConfigurationCallback callback) {
|
| // TODO(Mikhail): To avoid overflowing browser by repeated AddConfigs
|
| // (maybe limit the number of configs per client).
|
| - std::move(callback).Run(sensor_->StartListening(this, configuration));
|
| + bool success = sensor_->StartListening(this, configuration);
|
| + if (success && configuration.suppress_on_change_events())
|
| + ++suppress_on_change_events_count_;
|
| + std::move(callback).Run(success);
|
| }
|
|
|
| void SensorImpl::GetDefaultConfiguration(
|
| @@ -39,7 +44,10 @@ void SensorImpl::GetDefaultConfiguration(
|
| void SensorImpl::RemoveConfiguration(
|
| const PlatformSensorConfiguration& configuration,
|
| RemoveConfigurationCallback callback) {
|
| - std::move(callback).Run(sensor_->StopListening(this, configuration));
|
| + bool success = sensor_->StopListening(this, configuration);
|
| + if (success && configuration.suppress_on_change_events())
|
| + --suppress_on_change_events_count_;
|
| + std::move(callback).Run(success);
|
| }
|
|
|
| void SensorImpl::Suspend() {
|
| @@ -54,7 +62,7 @@ void SensorImpl::Resume() {
|
|
|
| void SensorImpl::OnSensorReadingChanged() {
|
| DCHECK(!suspended_);
|
| - if (client_)
|
| + if (client_ && suppress_on_change_events_count_ == 0)
|
| client_->SensorReadingChanged();
|
| }
|
|
|
|
|