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

Side by Side Diff: content/browser/bluetooth/web_bluetooth_service_impl.cc

Issue 2727683003: bluetooth: Clean up connection errors (Closed)
Patch Set: merge Created 3 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 // ID Not In Map Note: A service, characteristic, or descriptor ID not in the 5 // ID Not In Map Note: A service, characteristic, or descriptor ID not in the
6 // corresponding WebBluetoothServiceImpl map [service_id_to_device_address_, 6 // corresponding WebBluetoothServiceImpl map [service_id_to_device_address_,
7 // characteristic_id_to_service_id_, descriptor_id_to_characteristic_id_] 7 // characteristic_id_to_service_id_, descriptor_id_to_characteristic_id_]
8 // implies a hostile renderer because a renderer obtains the corresponding ID 8 // implies a hostile renderer because a renderer obtains the corresponding ID
9 // from this class and it will be added to the map at that time. 9 // from this class and it will be added to the map at that time.
10 10
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 return blink::mojom::WebBluetoothResult::CONNECT_AUTH_CANCELED; 57 return blink::mojom::WebBluetoothResult::CONNECT_AUTH_CANCELED;
58 case device::BluetoothDevice::ERROR_AUTH_REJECTED: 58 case device::BluetoothDevice::ERROR_AUTH_REJECTED:
59 RecordConnectGATTOutcome(UMAConnectGATTOutcome::AUTH_REJECTED); 59 RecordConnectGATTOutcome(UMAConnectGATTOutcome::AUTH_REJECTED);
60 return blink::mojom::WebBluetoothResult::CONNECT_AUTH_REJECTED; 60 return blink::mojom::WebBluetoothResult::CONNECT_AUTH_REJECTED;
61 case device::BluetoothDevice::ERROR_AUTH_TIMEOUT: 61 case device::BluetoothDevice::ERROR_AUTH_TIMEOUT:
62 RecordConnectGATTOutcome(UMAConnectGATTOutcome::AUTH_TIMEOUT); 62 RecordConnectGATTOutcome(UMAConnectGATTOutcome::AUTH_TIMEOUT);
63 return blink::mojom::WebBluetoothResult::CONNECT_AUTH_TIMEOUT; 63 return blink::mojom::WebBluetoothResult::CONNECT_AUTH_TIMEOUT;
64 case device::BluetoothDevice::ERROR_UNSUPPORTED_DEVICE: 64 case device::BluetoothDevice::ERROR_UNSUPPORTED_DEVICE:
65 RecordConnectGATTOutcome(UMAConnectGATTOutcome::UNSUPPORTED_DEVICE); 65 RecordConnectGATTOutcome(UMAConnectGATTOutcome::UNSUPPORTED_DEVICE);
66 return blink::mojom::WebBluetoothResult::CONNECT_UNSUPPORTED_DEVICE; 66 return blink::mojom::WebBluetoothResult::CONNECT_UNSUPPORTED_DEVICE;
67 case device::BluetoothDevice::ERROR_ATTRIBUTE_LENGTH_INVALID:
68 RecordConnectGATTOutcome(UMAConnectGATTOutcome::ATTRIBUTE_LENGTH_INVALID);
69 return blink::mojom::WebBluetoothResult::CONNECT_ATTRIBUTE_LENGTH_INVALID;
70 case device::BluetoothDevice::ERROR_CONNECTION_CONGESTED:
71 RecordConnectGATTOutcome(UMAConnectGATTOutcome::CONNECTION_CONGESTED);
72 return blink::mojom::WebBluetoothResult::CONNECT_CONNECTION_CONGESTED;
73 case device::BluetoothDevice::ERROR_INSUFFICIENT_ENCRYPTION:
74 RecordConnectGATTOutcome(UMAConnectGATTOutcome::INSUFFICIENT_ENCRYPTION);
75 return blink::mojom::WebBluetoothResult::CONNECT_INSUFFICIENT_ENCRYPTION;
76 case device::BluetoothDevice::ERROR_OFFSET_INVALID:
77 RecordConnectGATTOutcome(UMAConnectGATTOutcome::OFFSET_INVALID);
78 return blink::mojom::WebBluetoothResult::CONNECT_OFFSET_INVALID;
79 case device::BluetoothDevice::ERROR_READ_NOT_PERMITTED:
80 RecordConnectGATTOutcome(UMAConnectGATTOutcome::READ_NOT_PERMITTED);
81 return blink::mojom::WebBluetoothResult::CONNECT_READ_NOT_PERMITTED;
82 case device::BluetoothDevice::ERROR_REQUEST_NOT_SUPPORTED:
83 RecordConnectGATTOutcome(UMAConnectGATTOutcome::REQUEST_NOT_SUPPORTED);
84 return blink::mojom::WebBluetoothResult::CONNECT_REQUEST_NOT_SUPPORTED;
85 case device::BluetoothDevice::ERROR_WRITE_NOT_PERMITTED:
86 RecordConnectGATTOutcome(UMAConnectGATTOutcome::WRITE_NOT_PERMITTED);
87 return blink::mojom::WebBluetoothResult::CONNECT_WRITE_NOT_PERMITTED;
88 case device::BluetoothDevice::NUM_CONNECT_ERROR_CODES: 67 case device::BluetoothDevice::NUM_CONNECT_ERROR_CODES:
89 NOTREACHED(); 68 NOTREACHED();
90 return blink::mojom::WebBluetoothResult::UNTRANSLATED_CONNECT_ERROR_CODE; 69 return blink::mojom::WebBluetoothResult::CONNECT_UNKNOWN_FAILURE;
91 } 70 }
92 NOTREACHED(); 71 NOTREACHED();
93 return blink::mojom::WebBluetoothResult::UNTRANSLATED_CONNECT_ERROR_CODE; 72 return blink::mojom::WebBluetoothResult::CONNECT_UNKNOWN_FAILURE;
94 } 73 }
95 74
96 blink::mojom::WebBluetoothResult TranslateGATTErrorAndRecord( 75 blink::mojom::WebBluetoothResult TranslateGATTErrorAndRecord(
97 device::BluetoothRemoteGattService::GattErrorCode error_code, 76 device::BluetoothRemoteGattService::GattErrorCode error_code,
98 UMAGATTOperation operation) { 77 UMAGATTOperation operation) {
99 switch (error_code) { 78 switch (error_code) {
100 case device::BluetoothRemoteGattService::GATT_ERROR_UNKNOWN: 79 case device::BluetoothRemoteGattService::GATT_ERROR_UNKNOWN:
101 RecordGATTOperationOutcome(operation, UMAGATTOperationOutcome::UNKNOWN); 80 RecordGATTOperationOutcome(operation, UMAGATTOperationOutcome::UNKNOWN);
102 return blink::mojom::WebBluetoothResult::GATT_UNKNOWN_ERROR; 81 return blink::mojom::WebBluetoothResult::GATT_UNKNOWN_ERROR;
103 case device::BluetoothRemoteGattService::GATT_ERROR_FAILED: 82 case device::BluetoothRemoteGattService::GATT_ERROR_FAILED:
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 descriptor_id_to_characteristic_id_.clear(); 1186 descriptor_id_to_characteristic_id_.clear();
1208 characteristic_id_to_service_id_.clear(); 1187 characteristic_id_to_service_id_.clear();
1209 service_id_to_device_address_.clear(); 1188 service_id_to_device_address_.clear();
1210 connected_devices_.reset( 1189 connected_devices_.reset(
1211 new FrameConnectedBluetoothDevices(render_frame_host_)); 1190 new FrameConnectedBluetoothDevices(render_frame_host_));
1212 device_chooser_controller_.reset(); 1191 device_chooser_controller_.reset();
1213 BluetoothAdapterFactoryWrapper::Get().ReleaseAdapter(this); 1192 BluetoothAdapterFactoryWrapper::Get().ReleaseAdapter(this);
1214 } 1193 }
1215 1194
1216 } // namespace content 1195 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698