Index: third_party/WebKit/Source/modules/sensor/Sensor.cpp |
diff --git a/third_party/WebKit/Source/modules/sensor/Sensor.cpp b/third_party/WebKit/Source/modules/sensor/Sensor.cpp |
index ca613f9e1e8670fb65e75c1ba499ec3b0a9a2004..49cb94633ae5d6f01c7e86f19023215b1412cc10 100644 |
--- a/third_party/WebKit/Source/modules/sensor/Sensor.cpp |
+++ b/third_party/WebKit/Source/modules/sensor/Sensor.cpp |
@@ -138,6 +138,26 @@ bool Sensor::hasPendingActivity() const { |
return hasEventListeners(); |
} |
+auto Sensor::createSensorConfig() -> SensorConfigurationPtr { |
+ auto result = SensorConfiguration::New(); |
+ |
+ double defaultFrequency = m_sensorProxy->defaultConfig()->frequency; |
+ double maximumFrequency = m_sensorProxy->maximumFrequency(); |
+ |
+ double frequency = m_sensorOptions.hasFrequency() |
+ ? m_sensorOptions.frequency() |
+ : defaultFrequency; |
+ |
+ if (frequency > maximumFrequency) |
+ frequency = maximumFrequency; |
+ |
+ if (frequency > maximumFrequency) |
+ frequency = maximumFrequency; |
haraken
2016/11/03 13:58:45
Duplicated code.
Mikhail
2016/11/04 21:17:45
ah, thanks!
|
+ |
+ result->frequency = frequency; |
+ return result; |
+} |
+ |
void Sensor::initSensorProxyIfNeeded() { |
if (m_sensorProxy) |
return; |
@@ -234,9 +254,10 @@ void Sensor::startListening() { |
} |
if (!m_configuration) { |
- m_configuration = |
- createSensorConfig(m_sensorOptions, *m_sensorProxy->defaultConfig()); |
+ m_configuration = createSensorConfig(); |
DCHECK(m_configuration); |
+ DCHECK(m_configuration->frequency && |
timvolodine
2016/11/03 17:32:56
nit: m_configuration->frequency > 0 ? (or maybe >=
Mikhail
2016/11/04 21:17:45
Done.
|
+ m_configuration->frequency <= m_sensorProxy->maximumFrequency()); |
} |
auto startCallback = |