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

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

Issue 1775953004: bluetooth: Move writeValue to mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Moar cleanup Created 4 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/bluetooth/BluetoothError.cpp
diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothError.cpp b/third_party/WebKit/Source/modules/bluetooth/BluetoothError.cpp
index ff601f927851040566861b866ac35d00f4de67ae..7a99cc27217e6f41e4aafaf9f7a744046b6ee980 100644
--- a/third_party/WebKit/Source/modules/bluetooth/BluetoothError.cpp
+++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothError.cpp
@@ -9,6 +9,46 @@
namespace blink {
+DOMException* BluetoothError::take(ScriptPromiseResolver*, const mojom::WebBluetoothError& webError)
+{
+ switch (webError) {
+ case mojom::WebBluetoothError::SUCCESS:
+ ASSERT_NOT_REACHED();
+ return DOMException::create(UnknownError);
+#define MAP_ERROR(enumeration, name, message) \
+ case mojom::WebBluetoothError::enumeration: \
+ return DOMException::create(name, message)
+
+ // InvalidModificationErrors:
+ MAP_ERROR(GATT_INVALID_ATTRIBUTE_LENGTH, InvalidModificationError, "GATT Error: invalid attribute length.");
+
+ // InvalidStateErrors:
+ MAP_ERROR(SERVICE_NO_LONGER_EXISTS, InvalidStateError, "GATT Service no longer exists.");
+ MAP_ERROR(CHARACTERISTIC_NO_LONGER_EXISTS, InvalidStateError, "GATT Characteristic no longer exists.");
+
+ // NetworkErrors:
+ MAP_ERROR(DEVICE_NO_LONGER_IN_RANGE, NetworkError, "Bluetooth Device is no longer in range.");
+ MAP_ERROR(GATT_NOT_PAIRED, NetworkError, "GATT Error: Not paired.");
+ MAP_ERROR(GATT_OPERATION_IN_PROGRESS, NetworkError, "GATT operation already in progress.");
+
+ // NotSupportedErrors:
+ MAP_ERROR(GATT_UNKNOWN_ERROR, NotSupportedError, "GATT Error Unknown.");
+ MAP_ERROR(GATT_UNKNOWN_FAILURE, NotSupportedError, "GATT operation failed for unknown reason.");
+ MAP_ERROR(GATT_NOT_PERMITTED, NotSupportedError, "GATT operation not permitted.");
+ MAP_ERROR(GATT_NOT_SUPPORTED, NotSupportedError, "GATT Error: Not supported.");
+ MAP_ERROR(GATT_UNTRANSLATED_ERROR_CODE, NotSupportedError, "GATT Error: Unknown GattErrorCode.");
+
+ // SecurityErrors:
+ MAP_ERROR(GATT_NOT_AUTHORIZED, SecurityError, "GATT operation not authorized.");
+ MAP_ERROR(BLACKLISTED_WRITE, SecurityError, "writeValue() called on blacklisted object marked exclude-writes. https://goo.gl/4NeimX");
+
+#undef MAP_ERROR
+ }
+
+ ASSERT_NOT_REACHED();
+ return DOMException::create(UnknownError);
+}
+
DOMException* BluetoothError::take(ScriptPromiseResolver*, const WebBluetoothError& webError)
{
switch (webError) {
@@ -65,7 +105,6 @@ DOMException* BluetoothError::take(ScriptPromiseResolver*, const WebBluetoothErr
MAP_ERROR(GATTNotAuthorized, SecurityError, "GATT operation not authorized.");
MAP_ERROR(BlacklistedCharacteristicUUID, SecurityError, "getCharacteristic(s) called with blacklisted UUID. https://goo.gl/4NeimX");
MAP_ERROR(BlacklistedRead, SecurityError, "readValue() called on blacklisted object marked exclude-reads. https://goo.gl/4NeimX");
- MAP_ERROR(BlacklistedWrite, SecurityError, "writeValue() called on blacklisted object marked exclude-writes. https://goo.gl/4NeimX");
MAP_ERROR(NotAllowedToAccessService, SecurityError, "Origin is not allowed to access the service. Remember to add the service to a filter or to optionalServices in requestDevice().");
MAP_ERROR(RequestDeviceWithBlacklistedUUID, SecurityError, "requestDevice() called with a filter containing a blacklisted UUID. https://goo.gl/4NeimX");
MAP_ERROR(RequestDeviceWithUniqueOrigin, SecurityError, "requestDevice() called from sandboxed or otherwise unique origin.");

Powered by Google App Engine
This is Rietveld 408576698