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

Side by Side 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 unified diff | Download patch
OLDNEW
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 9
10 namespace blink { 10 namespace blink {
11 11
12 DOMException* BluetoothError::take(ScriptPromiseResolver*, const mojom::WebBluet oothError& webError)
13 {
14 switch (webError) {
15 case mojom::WebBluetoothError::SUCCESS:
16 ASSERT_NOT_REACHED();
17 return DOMException::create(UnknownError);
18 #define MAP_ERROR(enumeration, name, message) \
19 case mojom::WebBluetoothError::enumeration: \
20 return DOMException::create(name, message)
21
22 // InvalidModificationErrors:
23 MAP_ERROR(GATT_INVALID_ATTRIBUTE_LENGTH, InvalidModificationError, "GATT Error: invalid attribute length.");
24
25 // InvalidStateErrors:
26 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
29 // NetworkErrors:
30 MAP_ERROR(DEVICE_NO_LONGER_IN_RANGE, NetworkError, "Bluetooth Device is no longer in range.");
31 MAP_ERROR(GATT_NOT_PAIRED, NetworkError, "GATT Error: Not paired.");
32 MAP_ERROR(GATT_OPERATION_IN_PROGRESS, NetworkError, "GATT operation alre ady in progress.");
33
34 // NotSupportedErrors:
35 MAP_ERROR(GATT_UNKNOWN_ERROR, NotSupportedError, "GATT Error Unknown.");
36 MAP_ERROR(GATT_UNKNOWN_FAILURE, NotSupportedError, "GATT operation faile d for unknown reason.");
37 MAP_ERROR(GATT_NOT_PERMITTED, NotSupportedError, "GATT operation not per mitted.");
38 MAP_ERROR(GATT_NOT_SUPPORTED, NotSupportedError, "GATT Error: Not suppor ted.");
39 MAP_ERROR(GATT_UNTRANSLATED_ERROR_CODE, NotSupportedError, "GATT Error: Unknown GattErrorCode.");
40
41 // SecurityErrors:
42 MAP_ERROR(GATT_NOT_AUTHORIZED, SecurityError, "GATT operation not author ized.");
43 MAP_ERROR(BLACKLISTED_WRITE, SecurityError, "writeValue() called on blac klisted object marked exclude-writes. https://goo.gl/4NeimX");
44
45 #undef MAP_ERROR
46 }
47
48 ASSERT_NOT_REACHED();
49 return DOMException::create(UnknownError);
50 }
51
12 DOMException* BluetoothError::take(ScriptPromiseResolver*, const WebBluetoothErr or& webError) 52 DOMException* BluetoothError::take(ScriptPromiseResolver*, const WebBluetoothErr or& webError)
13 { 53 {
14 switch (webError) { 54 switch (webError) {
15 #define MAP_ERROR(enumeration, name, message) \ 55 #define MAP_ERROR(enumeration, name, message) \
16 case WebBluetoothError::enumeration: \ 56 case WebBluetoothError::enumeration: \
17 return DOMException::create(name, message) 57 return DOMException::create(name, message)
18 58
19 // InvalidModificationErrors: 59 // InvalidModificationErrors:
20 MAP_ERROR(GATTInvalidAttributeLength, InvalidModificationError, "GATT Er ror: invalid attribute length."); 60 MAP_ERROR(GATTInvalidAttributeLength, InvalidModificationError, "GATT Er ror: invalid attribute length.");
21 61
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 MAP_ERROR(GATTUnknownError, NotSupportedError, "GATT Error Unknown."); 98 MAP_ERROR(GATTUnknownError, NotSupportedError, "GATT Error Unknown.");
59 MAP_ERROR(GATTUnknownFailure, NotSupportedError, "GATT operation failed for unknown reason."); 99 MAP_ERROR(GATTUnknownFailure, NotSupportedError, "GATT operation failed for unknown reason.");
60 MAP_ERROR(GATTNotPermitted, NotSupportedError, "GATT operation not permi tted."); 100 MAP_ERROR(GATTNotPermitted, NotSupportedError, "GATT operation not permi tted.");
61 MAP_ERROR(GATTNotSupported, NotSupportedError, "GATT Error: Not supporte d."); 101 MAP_ERROR(GATTNotSupported, NotSupportedError, "GATT Error: Not supporte d.");
62 MAP_ERROR(GATTUntranslatedErrorCode, NotSupportedError, "GATT Error: Unk nown GattErrorCode."); 102 MAP_ERROR(GATTUntranslatedErrorCode, NotSupportedError, "GATT Error: Unk nown GattErrorCode.");
63 103
64 // SecurityErrors: 104 // SecurityErrors:
65 MAP_ERROR(GATTNotAuthorized, SecurityError, "GATT operation not authoriz ed."); 105 MAP_ERROR(GATTNotAuthorized, SecurityError, "GATT operation not authoriz ed.");
66 MAP_ERROR(BlacklistedCharacteristicUUID, SecurityError, "getCharacterist ic(s) called with blacklisted UUID. https://goo.gl/4NeimX"); 106 MAP_ERROR(BlacklistedCharacteristicUUID, SecurityError, "getCharacterist ic(s) called with blacklisted UUID. https://goo.gl/4NeimX");
67 MAP_ERROR(BlacklistedRead, SecurityError, "readValue() called on blackli sted object marked exclude-reads. https://goo.gl/4NeimX"); 107 MAP_ERROR(BlacklistedRead, SecurityError, "readValue() called on blackli sted object marked exclude-reads. https://goo.gl/4NeimX");
68 MAP_ERROR(BlacklistedWrite, SecurityError, "writeValue() called on black listed object marked exclude-writes. https://goo.gl/4NeimX");
69 MAP_ERROR(NotAllowedToAccessService, SecurityError, "Origin is not allow ed to access the service. Remember to add the service to a filter or to optional Services in requestDevice()."); 108 MAP_ERROR(NotAllowedToAccessService, SecurityError, "Origin is not allow ed to access the service. Remember to add the service to a filter or to optional Services in requestDevice().");
70 MAP_ERROR(RequestDeviceWithBlacklistedUUID, SecurityError, "requestDevic e() called with a filter containing a blacklisted UUID. https://goo.gl/4NeimX"); 109 MAP_ERROR(RequestDeviceWithBlacklistedUUID, SecurityError, "requestDevic e() called with a filter containing a blacklisted UUID. https://goo.gl/4NeimX");
71 MAP_ERROR(RequestDeviceWithUniqueOrigin, SecurityError, "requestDevice() called from sandboxed or otherwise unique origin."); 110 MAP_ERROR(RequestDeviceWithUniqueOrigin, SecurityError, "requestDevice() called from sandboxed or otherwise unique origin.");
72 MAP_ERROR(RequestDeviceWithoutFrame, SecurityError, "No window to show t he requestDevice() dialog."); 111 MAP_ERROR(RequestDeviceWithoutFrame, SecurityError, "No window to show t he requestDevice() dialog.");
73 112
74 #undef MAP_ERROR 113 #undef MAP_ERROR
75 } 114 }
76 115
77 ASSERT_NOT_REACHED(); 116 ASSERT_NOT_REACHED();
78 return DOMException::create(UnknownError); 117 return DOMException::create(UnknownError);
79 } 118 }
80 119
81 } // namespace blink 120 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698