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

Unified Diff: third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTDescriptor.cpp

Issue 2680783002: bluetooth: show better error messages for services, characteristics and descriptors (Closed)
Patch Set: Added comment and changed to enum class. Created 3 years, 10 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/bluetooth/BluetoothRemoteGATTDescriptor.cpp
diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTDescriptor.cpp b/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTDescriptor.cpp
index 9bb73d669e97c3512fff7570306fa1b7dd2c5368..ad14abb1b48ae1052934bcdfe83e658579e99df4 100644
--- a/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTDescriptor.cpp
+++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTDescriptor.cpp
@@ -38,8 +38,8 @@ void BluetoothRemoteGATTDescriptor::ReadValueCallback(
// If the device is disconnected, reject.
if (!getGatt()->RemoveFromActiveAlgorithms(resolver)) {
- resolver->reject(BluetoothRemoteGATTUtils::CreateDOMException(
- BluetoothRemoteGATTUtils::ExceptionType::kGATTServerDisconnected));
+ resolver->reject(BluetoothError::createDOMException(
+ mojom::blink::WebBluetoothResult::GATT_SERVER_DISCONNECTED));
return;
}
@@ -50,7 +50,7 @@ void BluetoothRemoteGATTDescriptor::ReadValueCallback(
m_value = domDataView;
resolver->resolve(domDataView);
} else {
- resolver->reject(BluetoothError::take(resolver, result));
+ resolver->reject(BluetoothError::createDOMException(result));
}
}
@@ -59,15 +59,13 @@ ScriptPromise BluetoothRemoteGATTDescriptor::readValue(
if (!getGatt()->connected()) {
return ScriptPromise::rejectWithDOMException(
scriptState,
- BluetoothRemoteGATTUtils::CreateDOMException(
- BluetoothRemoteGATTUtils::ExceptionType::kGATTServerNotConnected));
+ BluetoothError::createDOMException(
+ mojom::blink::WebBluetoothResult::GATT_SERVER_NOT_CONNECTED));
}
if (!getGatt()->device()->isValidDescriptor(m_descriptor->instance_id)) {
return ScriptPromise::rejectWithDOMException(
- scriptState,
- BluetoothRemoteGATTUtils::CreateDOMException(
- BluetoothRemoteGATTUtils::ExceptionType::kInvalidDescriptor));
+ scriptState, createInvalidDescriptorError());
}
ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
@@ -93,8 +91,8 @@ void BluetoothRemoteGATTDescriptor::WriteValueCallback(
// If the resolver is not in the set of ActiveAlgorithms then the frame
// disconnected so we reject.
if (!getGatt()->RemoveFromActiveAlgorithms(resolver)) {
- resolver->reject(BluetoothRemoteGATTUtils::CreateDOMException(
- BluetoothRemoteGATTUtils::ExceptionType::kGATTServerDisconnected));
+ resolver->reject(BluetoothError::createDOMException(
+ mojom::blink::WebBluetoothResult::GATT_SERVER_DISCONNECTED));
return;
}
@@ -102,7 +100,7 @@ void BluetoothRemoteGATTDescriptor::WriteValueCallback(
m_value = BluetoothRemoteGATTUtils::ConvertWTFVectorToDataView(value);
resolver->resolve();
} else {
- resolver->reject(BluetoothError::take(resolver, result));
+ resolver->reject(BluetoothError::createDOMException(result));
}
}
@@ -112,15 +110,13 @@ ScriptPromise BluetoothRemoteGATTDescriptor::writeValue(
if (!getGatt()->connected()) {
return ScriptPromise::rejectWithDOMException(
scriptState,
- BluetoothRemoteGATTUtils::CreateDOMException(
- BluetoothRemoteGATTUtils::ExceptionType::kGATTServerNotConnected));
+ BluetoothError::createDOMException(
+ mojom::blink::WebBluetoothResult::GATT_SERVER_NOT_CONNECTED));
}
if (!getGatt()->device()->isValidDescriptor(m_descriptor->instance_id)) {
return ScriptPromise::rejectWithDOMException(
- scriptState,
- BluetoothRemoteGATTUtils::CreateDOMException(
- BluetoothRemoteGATTUtils::ExceptionType::kInvalidDescriptor));
+ scriptState, createInvalidDescriptorError());
}
// Partial implementation of writeValue algorithm:
@@ -151,6 +147,14 @@ ScriptPromise BluetoothRemoteGATTDescriptor::writeValue(
return promise;
}
+DOMException* BluetoothRemoteGATTDescriptor::createInvalidDescriptorError() {
+ return BluetoothError::createDOMException(
+ BluetoothErrorCode::InvalidDescriptor,
+ "Descriptor with UUID " + uuid() +
+ " is no longer valid. Remember to retrieve the Descriptor again "
+ "after reconnecting.");
+}
+
DEFINE_TRACE(BluetoothRemoteGATTDescriptor) {
visitor->trace(m_characteristic);
visitor->trace(m_value);

Powered by Google App Engine
This is Rietveld 408576698