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

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

Issue 2564283004: bluetooth: web: Include the UUID in the error message. (Closed)
Patch Set: Addressed issues in code review. Created 4 years 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/BluetoothRemoteGATTService.cpp
diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTService.cpp b/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTService.cpp
index 84d915fd495db3acdbbf855b6811c19d87763f45..16884e8e224026979a886f1bba941e6d08309538 100644
--- a/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTService.cpp
+++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTService.cpp
@@ -50,9 +50,13 @@ class GetCharacteristicsCallback
public:
GetCharacteristicsCallback(
BluetoothRemoteGATTService* service,
+ const String characteristicsUUID,
mojom::blink::WebBluetoothGATTQueryQuantity quantity,
ScriptPromiseResolver* resolver)
- : m_service(service), m_quantity(quantity), m_resolver(resolver) {
+ : m_service(service),
+ m_characteristicsUUID(characteristicsUUID),
+ m_quantity(quantity),
+ m_resolver(resolver) {
// We always check that the device is connected before constructing this
// object.
CHECK(m_service->device()->gatt()->connected());
@@ -111,12 +115,22 @@ class GetCharacteristicsCallback
DOMException::create(NetworkError, kGATTServerDisconnected));
return;
}
-
- m_resolver->reject(BluetoothError::take(m_resolver, error));
+ if (!m_characteristicsUUID.isEmpty() &&
+ BluetoothError::isSameError(
+ error,
+ mojom::blink::WebBluetoothResult::CHARACTERISTIC_NOT_FOUND)) {
+ m_resolver->reject(BluetoothError::take(
+ m_resolver, error,
+ "No Characteristics matching UUID " + m_characteristicsUUID +
+ " found in Service with UUID " + m_service->uuid() + "."));
+ } else {
+ m_resolver->reject(BluetoothError::take(m_resolver, error));
+ }
}
private:
Persistent<BluetoothRemoteGATTService> m_service;
+ const String m_characteristicsUUID;
mojom::blink::WebBluetoothGATTQueryQuantity m_quantity;
const Persistent<ScriptPromiseResolver> m_resolver;
};
@@ -178,8 +192,8 @@ ScriptPromise BluetoothRemoteGATTService::getCharacteristicsImpl(
BluetoothSupplement::fromScriptState(scriptState);
webbluetooth->getCharacteristics(
m_webService->serviceInstanceID, static_cast<int32_t>(quantity),
- characteristicsUUID,
- new GetCharacteristicsCallback(this, quantity, resolver));
+ characteristicsUUID, new GetCharacteristicsCallback(
+ this, characteristicsUUID, quantity, resolver));
return promise;
}

Powered by Google App Engine
This is Rietveld 408576698