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

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

Issue 2323683002: [Sensors] Implement sensor data polling (Closed)
Patch Set: No extra PageVisibilityObservers 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 070b3b88aa3107e7257ddbff65b4110899b8bd19..a93c3818b149ce3885b637e3dab3b674ae5a8b09 100644
--- a/third_party/WebKit/Source/modules/sensor/Sensor.cpp
+++ b/third_party/WebKit/Source/modules/sensor/Sensor.cpp
@@ -179,6 +179,15 @@ void Sensor::onStopRequestCompleted(bool result)
void Sensor::pageVisibilityChanged()
{
updatePollingStatus();
+
+ if (!m_sensorProxy || !m_sensorProxy->isInitialized())
+ return;
+
+ if (page()->visibilityState() != PageVisibilityStateVisible) {
+ m_sensorProxy->suspend();
+ } else {
+ m_sensorProxy->resume();
+ }
}
void Sensor::startListening()

Powered by Google App Engine
This is Rietveld 408576698