| Index: content/renderer/device_sensors/device_light_event_pump.cc
|
| diff --git a/content/renderer/device_sensors/device_light_event_pump.cc b/content/renderer/device_sensors/device_light_event_pump.cc
|
| index a20919d968d9f3637afe8fb3e1435255d98890ce..f2fa5cb6ea0f6a608514dfc26eed3f87bdc25c45 100644
|
| --- a/content/renderer/device_sensors/device_light_event_pump.cc
|
| +++ b/content/renderer/device_sensors/device_light_event_pump.cc
|
| @@ -37,13 +37,24 @@ bool DeviceLightEventPump::OnControlMessageReceived(
|
| void DeviceLightEventPump::FireEvent() {
|
| DCHECK(listener());
|
| DeviceLightData data;
|
| - bool did_return_light_data = reader_->GetLatestData(&data);
|
| - if (did_return_light_data && data.value != last_seen_data_) {
|
| + if (reader_->GetLatestData(&data) && ShouldFireEvent(data.value)) {
|
| last_seen_data_ = data.value;
|
| listener()->didChangeDeviceLight(data.value);
|
| }
|
| }
|
|
|
| +bool DeviceLightEventPump::ShouldFireEvent(double lux) const {
|
| + if (lux < 0)
|
| + return false;
|
| +
|
| + if (lux == std::numeric_limits<double>::infinity()) {
|
| + // no sensor data can be provided, fire an Infinity event to Blink.
|
| + return true;
|
| + }
|
| +
|
| + return lux != last_seen_data_;
|
| +}
|
| +
|
| bool DeviceLightEventPump::InitializeReader(base::SharedMemoryHandle handle) {
|
| if (!reader_)
|
| reader_.reset(new DeviceLightSharedMemoryReader());
|
|
|