| 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 c864dda453a3745afea78a6724a0b6802ee1b347..57daa1fea7647846109857d35daf6a2880c74318 100644
|
| --- a/third_party/WebKit/Source/modules/sensor/Sensor.cpp
|
| +++ b/third_party/WebKit/Source/modules/sensor/Sensor.cpp
|
| @@ -163,10 +163,11 @@ auto Sensor::createSensorConfig() -> SensorConfigurationPtr {
|
| }
|
|
|
| double Sensor::readingValue(int index, bool& isNull) const {
|
| - if (!canReturnReadings()) {
|
| - isNull = true;
|
| - return 0.0;
|
| - }
|
| + isNull = !canReturnReadings();
|
| + return isNull ? 0.0 : readingValueUnchecked(index);
|
| +}
|
| +
|
| +double Sensor::readingValueUnchecked(int index) const {
|
| DCHECK(m_sensorProxy);
|
| DCHECK(index >= 0 && index < device::SensorReading::kValuesCount);
|
| return m_sensorProxy->reading().values[index];
|
| @@ -200,12 +201,13 @@ void Sensor::onSensorInitialized() {
|
| startListening();
|
| }
|
|
|
| -void Sensor::onSensorReadingChanged(double timestamp) {
|
| +void Sensor::notifySensorChanged(double timestamp) {
|
| if (m_state != Sensor::SensorState::Activated)
|
| return;
|
|
|
| DCHECK_GT(m_configuration->frequency, 0.0);
|
| double period = 1 / m_configuration->frequency;
|
| +
|
| if (timestamp - m_lastUpdateTimestamp >= period) {
|
| m_lastUpdateTimestamp = timestamp;
|
| notifySensorReadingChanged();
|
| @@ -236,7 +238,7 @@ void Sensor::startListening() {
|
| DCHECK(m_sensorProxy);
|
| updateState(Sensor::SensorState::Activating);
|
|
|
| - m_sensorProxy->addObserver(this);
|
| + m_sensorProxy->addClient(this);
|
| if (!m_sensorProxy->isInitialized()) {
|
| m_sensorProxy->initialize();
|
| return;
|
| @@ -264,7 +266,7 @@ void Sensor::stopListening() {
|
| DCHECK(m_configuration);
|
| m_sensorProxy->removeConfiguration(m_configuration->Clone());
|
| }
|
| - m_sensorProxy->removeObserver(this);
|
| + m_sensorProxy->removeClient(this);
|
| }
|
|
|
| void Sensor::updateState(Sensor::SensorState newState) {
|
| @@ -318,7 +320,7 @@ void Sensor::notifyError(DOMException* error) {
|
| }
|
|
|
| bool Sensor::canReturnReadings() const {
|
| - if (m_state != Sensor::SensorState::Activated)
|
| + if (!isActivated())
|
| return false;
|
| DCHECK(m_sensorProxy);
|
| return m_sensorProxy->reading().timestamp != 0.0;
|
|
|