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 6269f7162258b4d688ab5b11d14af4e8d0f7f4ac..e76e201911b10621df32d04af66242db8fe05f94 100644 |
--- a/third_party/WebKit/Source/modules/sensor/Sensor.cpp |
+++ b/third_party/WebKit/Source/modules/sensor/Sensor.cpp |
@@ -125,15 +125,7 @@ void Sensor::onSensorInitialized() |
if (m_state != Sensor::SensorState::ACTIVATING) |
return; |
- m_configuration = createSensorConfig(m_sensorOptions); |
- if (!m_configuration) { |
- reportError(); |
- return; |
- } |
- |
- DCHECK(m_sensorProxy); |
- auto startCallback = WTF::bind(&Sensor::onStartRequestCompleted, wrapWeakPersistent(this)); |
- m_sensorProxy->addConfiguration(m_configuration->Clone(), std::move(startCallback)); |
+ startListening(); |
} |
void Sensor::onSensorReadingChanged() |
@@ -199,13 +191,22 @@ void Sensor::startListening() |
m_sensorReading = createSensorReading(m_sensorProxy); |
m_sensorProxy->addObserver(this); |
- if (m_sensorProxy->isInitialized()) { |
- auto callback = WTF::bind(&Sensor::onStartRequestCompleted, wrapWeakPersistent(this)); |
- DCHECK(m_configuration); |
- m_sensorProxy->addConfiguration(m_configuration->Clone(), std::move(callback)); |
- } else { |
+ if (!m_sensorProxy->isInitialized()) { |
m_sensorProxy->initialize(); |
+ return; |
} |
+ |
+ if (!m_configuration) { |
+ DCHECK(m_sensorProxy->defaultConfig()); |
timvolodine
2016/09/12 16:37:08
should this check be in sensorProxy itself, perhap
Mikhail
2016/09/12 17:08:10
right, the DCHECK can be omitted I just put it to
|
+ m_configuration = createSensorConfig(m_sensorOptions, *m_sensorProxy->defaultConfig()); |
+ if (!m_configuration) { // Failed to create configuration. |
timvolodine
2016/09/12 16:37:08
when can this happen? maybe just DCHECK here?
Mikhail
2016/09/12 17:08:10
can be DCHECK() (given options checks can/should b
|
+ reportError(); |
+ return; |
+ } |
+ } |
+ |
+ auto startCallback = WTF::bind(&Sensor::onStartRequestCompleted, wrapWeakPersistent(this)); |
+ m_sensorProxy->addConfiguration(m_configuration->Clone(), std::move(startCallback)); |
} |
void Sensor::stopListening() |