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..7249d52b9feabda9759254f198ea41a2086ef837 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::OnGATTServerClientDisconnection( | 
| + const WebBluetoothDeviceId& device_id) { | 
| + DCHECK_CURRENTLY_ON(BrowserThread::UI); | 
| + RecordWebBluetoothFunctionCall( | 
| 
 
scheib
2017/03/30 22:45:51
Please address the UMA patch, and make this change
 
 | 
| + UMAWebBluetoothFunction::REMOTE_GATT_SERVER_DISCONNECT); | 
| + | 
| + // 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::OnGATTServerClientDisconnection, | 
| + weak_ptr_factory_.GetWeakPtr(), device_id)); | 
| callback.Run(blink::mojom::WebBluetoothResult::SUCCESS); | 
| connected_devices_->Insert(device_id, std::move(connection), | 
| std::move(client)); |