| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/bluetooth/BluetoothError.h" | 5 #include "modules/bluetooth/BluetoothError.h" |
| 6 | 6 |
| 7 #include "core/dom/DOMException.h" | 7 #include "core/dom/DOMException.h" |
| 8 #include "core/dom/ExceptionCode.h" | 8 #include "core/dom/ExceptionCode.h" |
| 9 #include "third_party/WebKit/public/platform/modules/bluetooth/web_bluetooth.moj
om-blink.h" |
| 9 | 10 |
| 10 namespace blink { | 11 namespace blink { |
| 11 | 12 |
| 12 DOMException* BluetoothError::take(ScriptPromiseResolver*, const WebBluetoothErr
or& webError) | 13 DOMException* BluetoothError::take(ScriptPromiseResolver*, int32_t webError /* C
orresponds to WebBluetoothError in web_bluetooth.mojom */) |
| 13 { | 14 { |
| 14 switch (webError) { | 15 switch (static_cast<mojom::blink::WebBluetoothError>(webError)) { |
| 15 case WebBluetoothError::SUCCESS: | 16 case mojom::blink::WebBluetoothError::SUCCESS: |
| 16 ASSERT_NOT_REACHED(); | 17 ASSERT_NOT_REACHED(); |
| 17 return DOMException::create(UnknownError); | 18 return DOMException::create(UnknownError); |
| 18 #define MAP_ERROR(enumeration, name, message) \ | 19 #define MAP_ERROR(enumeration, name, message) \ |
| 19 case WebBluetoothError::enumeration: \ | 20 case mojom::blink::WebBluetoothError::enumeration: \ |
| 20 return DOMException::create(name, message) | 21 return DOMException::create(name, message) |
| 21 | 22 |
| 22 // InvalidModificationErrors: | 23 // InvalidModificationErrors: |
| 23 MAP_ERROR(GATT_INVALID_ATTRIBUTE_LENGTH, InvalidModificationError, "GATT
Error: invalid attribute length."); | 24 MAP_ERROR(GATT_INVALID_ATTRIBUTE_LENGTH, InvalidModificationError, "GATT
Error: invalid attribute length."); |
| 24 | 25 |
| 25 // InvalidStateErrors: | 26 // InvalidStateErrors: |
| 26 MAP_ERROR(SERVICE_NO_LONGER_EXISTS, InvalidStateError, "GATT Service no
longer exists."); | 27 MAP_ERROR(SERVICE_NO_LONGER_EXISTS, InvalidStateError, "GATT Service no
longer exists."); |
| 27 MAP_ERROR(CHARACTERISTIC_NO_LONGER_EXISTS, InvalidStateError, "GATT Char
acteristic no longer exists."); | 28 MAP_ERROR(CHARACTERISTIC_NO_LONGER_EXISTS, InvalidStateError, "GATT Char
acteristic no longer exists."); |
| 28 | 29 |
| 29 // NetworkErrors: | 30 // NetworkErrors: |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 MAP_ERROR(REQUEST_DEVICE_WITHOUT_FRAME, SecurityError, "No window to sho
w the requestDevice() dialog."); | 79 MAP_ERROR(REQUEST_DEVICE_WITHOUT_FRAME, SecurityError, "No window to sho
w the requestDevice() dialog."); |
| 79 | 80 |
| 80 #undef MAP_ERROR | 81 #undef MAP_ERROR |
| 81 } | 82 } |
| 82 | 83 |
| 83 ASSERT_NOT_REACHED(); | 84 ASSERT_NOT_REACHED(); |
| 84 return DOMException::create(UnknownError); | 85 return DOMException::create(UnknownError); |
| 85 } | 86 } |
| 86 | 87 |
| 87 } // namespace blink | 88 } // namespace blink |
| OLD | NEW |