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

Unified Diff: third_party/WebKit/Source/modules/sensor/Sensor.cpp

Issue 2330943002: [Sensors] Handle default sensor configuration (Closed)
Patch Set: Rebased Created 4 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: 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..872afd786fdd7de5f4333a06813c33abd1eb43ad 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()
@@ -195,17 +187,24 @@ void Sensor::startListening()
{
DCHECK(m_sensorProxy);
updateState(Sensor::SensorState::ACTIVATING);
- if (!m_sensorReading)
+ if (!m_sensorReading) {
m_sensorReading = createSensorReading(m_sensorProxy);
+ DCHECK(m_sensorReading);
+ }
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) {
+ m_configuration = createSensorConfig(m_sensorOptions, *m_sensorProxy->defaultConfig());
+ DCHECK(m_configuration);
}
+
+ auto startCallback = WTF::bind(&Sensor::onStartRequestCompleted, wrapWeakPersistent(this));
+ m_sensorProxy->addConfiguration(m_configuration->Clone(), std::move(startCallback));
}
void Sensor::stopListening()
« no previous file with comments | « third_party/WebKit/Source/modules/sensor/Sensor.h ('k') | third_party/WebKit/Source/modules/sensor/SensorProxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698