Chromium Code Reviews| Index: content/browser/bluetooth/web_bluetooth_service_impl.cc |
| diff --git a/content/browser/bluetooth/web_bluetooth_service_impl.cc b/content/browser/bluetooth/web_bluetooth_service_impl.cc |
| index 9c6b89958aba9da4647a53297600c6036a12b4f1..f848545a3fbadc8781fbdc09d2e571a1bcb114e2 100644 |
| --- a/content/browser/bluetooth/web_bluetooth_service_impl.cc |
| +++ b/content/browser/bluetooth/web_bluetooth_service_impl.cc |
| @@ -355,18 +355,6 @@ void WebBluetoothServiceImpl::RemoteServerConnect( |
| weak_ptr_factory_.GetWeakPtr(), start_time, callback)); |
| } |
| -void WebBluetoothServiceImpl::RemoteServerDisconnect( |
| - const WebBluetoothDeviceId& device_id) { |
| - DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| - RecordWebBluetoothFunctionCall( |
| - UMAWebBluetoothFunction::REMOTE_GATT_SERVER_DISCONNECT); |
| - |
| - if (connected_devices_->IsConnectedToDeviceWithId(device_id)) { |
| - DVLOG(1) << "Disconnecting device: " << device_id.str(); |
| - connected_devices_->CloseConnectionToDeviceWithId(device_id); |
| - } |
| -} |
| - |
| void WebBluetoothServiceImpl::RemoteServerGetPrimaryServices( |
| const WebBluetoothDeviceId& device_id, |
| blink::mojom::WebBluetoothGATTQueryQuantity quantity, |
| @@ -847,6 +835,20 @@ void WebBluetoothServiceImpl::RequestDeviceImpl( |
| weak_ptr_factory_.GetWeakPtr(), callback)); |
| } |
| +void WebBluetoothServiceImpl::HandleServerClientError( |
| + const WebBluetoothDeviceId& device_id) { |
| + DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| + RecordWebBluetoothFunctionCall( |
| + UMAWebBluetoothFunction::REMOTE_GATT_SERVER_DISCONNECT); |
|
scheib
2017/03/22 01:11:07
This UMA was intended to count how often Javascrip
juncai
2017/03/27 20:44:46
Filed an issue:
https://bugs.chromium.org/p/chromi
|
| + |
| + // If a GATT connection exists for device identified by |device_id| then |
| + // decreases the ref count for that connection. |
| + if (connected_devices_->IsConnectedToDeviceWithId(device_id)) { |
| + DVLOG(1) << "Disconnecting device: " << device_id.str(); |
| + connected_devices_->CloseConnectionToDeviceWithId(device_id); |
| + } |
| +} |
| + |
| void WebBluetoothServiceImpl::RemoteServerGetPrimaryServicesImpl( |
| const WebBluetoothDeviceId& device_id, |
| blink::mojom::WebBluetoothGATTQueryQuantity quantity, |
| @@ -959,6 +961,9 @@ void WebBluetoothServiceImpl::OnCreateGATTConnectionSuccess( |
| return; |
| } |
| + client.set_connection_error_handler( |
| + base::Bind(&WebBluetoothServiceImpl::HandleServerClientError, |
| + weak_ptr_factory_.GetWeakPtr(), device_id)); |
| callback.Run(blink::mojom::WebBluetoothResult::SUCCESS); |
| connected_devices_->Insert(device_id, std::move(connection), |
| std::move(client)); |