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

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

Issue 2746573002: [Sensors] Implement bindings for AbsoluteOrientationSensor (Closed)
Patch Set: Comments from Alex Created 3 years, 9 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/SensorProxy.cpp
diff --git a/third_party/WebKit/Source/modules/sensor/SensorProxy.cpp b/third_party/WebKit/Source/modules/sensor/SensorProxy.cpp
index baa7be212caa72df4b93ed3c77bf24acfc2be9a3..68a8daa8e4c6904adf716b1c51bf8898e621ca52 100644
--- a/third_party/WebKit/Source/modules/sensor/SensorProxy.cpp
+++ b/third_party/WebKit/Source/modules/sensor/SensorProxy.cpp
@@ -34,18 +34,18 @@ void SensorProxy::dispose() {
DEFINE_TRACE(SensorProxy) {
visitor->trace(m_readingUpdater);
- visitor->trace(m_observers);
+ visitor->trace(m_clients);
visitor->trace(m_provider);
PageVisibilityObserver::trace(visitor);
}
-void SensorProxy::addObserver(Observer* observer) {
- if (!m_observers.contains(observer))
- m_observers.insert(observer);
+void SensorProxy::addClient(Client* client) {
+ if (!m_clients.contains(client))
+ m_clients.insert(client);
}
-void SensorProxy::removeObserver(Observer* observer) {
- m_observers.erase(observer);
+void SensorProxy::removeClient(Client* client) {
+ m_clients.erase(client);
}
void SensorProxy::initialize() {
@@ -129,15 +129,19 @@ void SensorProxy::updateSensorReading() {
}
}
- m_reading = readingData;
+ if (m_reading.timestamp != readingData.timestamp) {
+ m_reading = readingData;
+ for (Client* client : m_clients)
+ client->onSensorReadingChanged();
+ }
}
void SensorProxy::notifySensorChanged(double timestamp) {
// This notification leads to sync 'onchange' event sending, so
- // we must cache m_observers as it can be modified within event handlers.
- auto copy = m_observers;
- for (Observer* observer : copy)
- observer->onSensorReadingChanged(timestamp);
+ // we must cache m_clients as it can be modified within event handlers.
+ auto copy = m_clients;
+ for (Client* client : copy)
+ client->notifySensorChanged(timestamp);
}
void SensorProxy::RaiseError() {
@@ -174,9 +178,9 @@ void SensorProxy::handleSensorError() {
m_defaultConfig.reset();
m_clientBinding.Close();
- for (Observer* observer : m_observers) {
- observer->onSensorError(NotReadableError, "Could not connect to a sensor",
- String());
+ for (Client* client : m_clients) {
+ client->onSensorError(NotReadableError, "Could not connect to a sensor",
+ String());
}
}
@@ -228,8 +232,8 @@ void SensorProxy::onSensorCreated(SensorInitParamsPtr params,
m_state = Initialized;
- for (Observer* observer : m_observers)
- observer->onSensorInitialized();
+ for (Client* client : m_clients)
+ client->onSensorInitialized();
}
void SensorProxy::onAddConfigurationCompleted(

Powered by Google App Engine
This is Rietveld 408576698