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

Unified Diff: device/generic_sensor/sensor_impl.cc

Issue 2927263002: Add |notify_client_on_reading_change| flag to sensor configuration (Closed)
Patch Set: address comments Created 3 years, 6 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
« device/generic_sensor/sensor_impl.h ('K') | « device/generic_sensor/sensor_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9b03167138e58d0dfd19e303d48d85da037faf11 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),
+ not_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 flag = sensor_->StartListening(this, configuration);
Reilly Grant (use Gerrit) 2017/06/09 22:10:02 s/flag/success/
juncai 2017/06/09 22:52:32 Done.
+ if (flag && !configuration.suppress_on_change_events())
+ ++not_suppress_on_change_events_count_;
+ std::move(callback).Run(flag);
}
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 flag = sensor_->StopListening(this, configuration);
+ if (flag && !configuration.suppress_on_change_events())
+ --not_suppress_on_change_events_count_;
+ std::move(callback).Run(flag);
}
void SensorImpl::Suspend() {
@@ -54,7 +62,7 @@ void SensorImpl::Resume() {
void SensorImpl::OnSensorReadingChanged() {
DCHECK(!suspended_);
- if (client_)
+ if (client_ && not_suppress_on_change_events_count_ > 0)
client_->SensorReadingChanged();
}
« device/generic_sensor/sensor_impl.h ('K') | « device/generic_sensor/sensor_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698