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

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

Issue 2384273004: [Sensors] 'onerror' event implementation (Closed)
Patch Set: updated global-interface-listing-expected.txt Created 4 years, 2 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
« no previous file with comments | « third_party/WebKit/Source/modules/sensor/SensorProxy.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 be0321dbded63426673baa7397231115a552cd72..0e2b58ad38addbb8c7aab354e551476276ce5c0a 100644
--- a/third_party/WebKit/Source/modules/sensor/SensorProxy.cpp
+++ b/third_party/WebKit/Source/modules/sensor/SensorProxy.cpp
@@ -55,8 +55,6 @@ void SensorProxy::initialize() {
WTF::bind(&SensorProxy::onSensorCreated, wrapWeakPersistent(this)));
m_provider->sensorProvider()->GetSensor(m_type, mojo::GetProxy(&m_sensor),
callback);
- m_sensor.set_connection_error_handler(convertToBaseCallback(
- WTF::bind(&SensorProxy::handleSensorError, wrapWeakPersistent(this))));
}
void SensorProxy::addConfiguration(
@@ -114,7 +112,9 @@ void SensorProxy::SensorReadingChanged() {
observer->onSensorReadingChanged();
}
-void SensorProxy::handleSensorError() {
+void SensorProxy::handleSensorError(ExceptionCode code,
+ const String& sanitizedMessage,
+ const String& unsanitizedMessage) {
m_state = Uninitialized;
m_sensor.reset();
m_sharedBuffer.reset();
@@ -123,14 +123,14 @@ void SensorProxy::handleSensorError() {
m_clientBinding.Close();
for (Observer* observer : m_observers)
- observer->onSensorError();
+ observer->onSensorError(code, sanitizedMessage, unsanitizedMessage);
}
void SensorProxy::onSensorCreated(SensorInitParamsPtr params,
SensorClientRequest clientRequest) {
DCHECK_EQ(Initializing, m_state);
if (!params) {
- handleSensorError();
+ handleSensorError(NotFoundError, "Sensor is not present on the platform.");
return;
}
@@ -156,6 +156,12 @@ void SensorProxy::onSensorCreated(SensorInitParamsPtr params,
return;
}
+ auto errorCallback =
+ WTF::bind(&SensorProxy::handleSensorError, wrapWeakPersistent(this),
+ UnknownError, String("Internal error"), String());
+ m_sensor.set_connection_error_handler(
+ convertToBaseCallback(std::move(errorCallback)));
+
m_state = Initialized;
for (Observer* observer : m_observers)
observer->onSensorInitialized();
« no previous file with comments | « third_party/WebKit/Source/modules/sensor/SensorProxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698