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

Unified Diff: third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.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/BluetoothRemoteGATTServer.cpp
diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.cpp b/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.cpp
index 8f522942f58ceff3f3dd501ebb8d4c515c280870..8b2185a27894517466375353468015d90f583b4b 100644
--- a/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.cpp
+++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.cpp
@@ -67,7 +67,7 @@ void BluetoothRemoteGATTServer::ConnectCallback(
setConnected(true);
resolver->resolve(this);
} else {
- resolver->reject(BluetoothError::take(resolver, result));
+ resolver->reject(BluetoothError::createDOMException(result));
}
}
@@ -96,6 +96,7 @@ void BluetoothRemoteGATTServer::disconnect(ScriptState* scriptState) {
// Callback that allows us to resolve the promise with a single service or
// with a vector owning the services.
void BluetoothRemoteGATTServer::GetPrimaryServicesCallback(
+ const String& requestedServiceUUID,
mojom::blink::WebBluetoothGATTQueryQuantity quantity,
ScriptPromiseResolver* resolver,
mojom::blink::WebBluetoothResult result,
@@ -131,7 +132,14 @@ void BluetoothRemoteGATTServer::GetPrimaryServicesCallback(
}
resolver->resolve(gattServices);
} else {
- resolver->reject(BluetoothError::take(resolver, result));
+ if (result == mojom::blink::WebBluetoothResult::SERVICE_NOT_FOUND) {
+ resolver->reject(BluetoothError::createDOMException(
+ BluetoothErrorCode::ServiceNotFound, "No Services matching UUID " +
+ requestedServiceUUID +
+ " found in Device."));
+ } else {
+ resolver->reject(BluetoothError::createDOMException(result));
+ }
}
}
@@ -187,7 +195,8 @@ ScriptPromise BluetoothRemoteGATTServer::getPrimaryServicesImpl(
device()->id(), quantity, servicesUUID,
convertToBaseCallback(
WTF::bind(&BluetoothRemoteGATTServer::GetPrimaryServicesCallback,
- wrapPersistent(this), quantity, wrapPersistent(resolver))));
+ wrapPersistent(this), servicesUUID, quantity,
+ wrapPersistent(resolver))));
return promise;
}

Powered by Google App Engine
This is Rietveld 408576698