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

Unified Diff: content/renderer/device_sensors/device_light_event_pump.cc

Issue 292693004: [DeviceLight] Browser+java part (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Forgot some light bits removal from device_inertial_sensor_diagnostics.html Created 6 years, 3 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: 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..ccb91221b7026f5e0ebc5a92993170b1f81276f7 100644
--- a/content/renderer/device_sensors/device_light_event_pump.cc
+++ b/content/renderer/device_sensors/device_light_event_pump.cc
@@ -37,13 +37,22 @@ 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 != last_seen_data_ || lux == std::numeric_limits<double>::infinity())
timvolodine 2014/09/08 15:20:19 could you add a comment regarding why infinity is
timvolodine 2014/09/08 15:20:19 also a unit test for this case would be desirable
riju_ 2014/09/09 14:01:18 Done.
riju_ 2014/09/09 14:01:18 Done.
+ return true;
+
+ return false;
+}
+
bool DeviceLightEventPump::InitializeReader(base::SharedMemoryHandle handle) {
if (!reader_)
reader_.reset(new DeviceLightSharedMemoryReader());

Powered by Google App Engine
This is Rietveld 408576698