Chromium Code Reviews| 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 cd703d4b3bb4f7a8e28b01d75e02d24a879ef29d..be9e291ee91efdaa6d312324864d32623b0be2d8 100644 |
| --- a/third_party/WebKit/Source/modules/bluetooth/BluetoothError.cpp |
| +++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothError.cpp |
| @@ -11,16 +11,28 @@ |
| namespace blink { |
| DOMException* BluetoothError::take( |
| - ScriptPromiseResolver*, |
| + ScriptPromiseResolver* resolver, |
| int32_t |
| webError /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */) { |
| + return take(resolver, webError, String()); |
| +} |
| + |
| +DOMException* BluetoothError::take( |
| + ScriptPromiseResolver*, |
| + int32_t |
| + webError /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */, |
| + String detailedMessage) { |
| switch (static_cast<mojom::blink::WebBluetoothResult>(webError)) { |
| case mojom::blink::WebBluetoothResult::SUCCESS: |
| ASSERT_NOT_REACHED(); |
| return DOMException::create(UnknownError); |
| -#define MAP_ERROR(enumeration, name, message) \ |
| - case mojom::blink::WebBluetoothResult::enumeration: \ |
| - return DOMException::create(name, message) |
| +#define MAP_ERROR(enumeration, name, message) \ |
| + case mojom::blink::WebBluetoothResult::enumeration: \ |
| + if (detailedMessage.isEmpty()) { \ |
| + return DOMException::create(name, message); \ |
| + } else { \ |
| + return DOMException::create(name, detailedMessage); \ |
| + } |
| // InvalidModificationErrors: |
| MAP_ERROR(GATT_INVALID_ATTRIBUTE_LENGTH, InvalidModificationError, |
| @@ -144,4 +156,9 @@ DOMException* BluetoothError::take( |
| return DOMException::create(UnknownError); |
| } |
| +bool BluetoothError::isSameError(int32_t error, |
|
scheib
2016/12/14 18:22:46
Not official style guide, but nice to have: prefix
perja
2016/12/15 10:54:01
Done.
|
| + mojom::blink::WebBluetoothResult webError) { |
| + return static_cast<mojom::blink::WebBluetoothResult>(error) == webError; |
| +} |
| + |
| } // namespace blink |