Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 348 web_bluetooth_server_client; | 348 web_bluetooth_server_client; |
| 349 web_bluetooth_server_client.Bind(std::move(client)); | 349 web_bluetooth_server_client.Bind(std::move(client)); |
| 350 query_result.device->CreateGattConnection( | 350 query_result.device->CreateGattConnection( |
| 351 base::Bind(&WebBluetoothServiceImpl::OnCreateGATTConnectionSuccess, | 351 base::Bind(&WebBluetoothServiceImpl::OnCreateGATTConnectionSuccess, |
| 352 weak_ptr_factory_.GetWeakPtr(), device_id, start_time, | 352 weak_ptr_factory_.GetWeakPtr(), device_id, start_time, |
| 353 base::Passed(&web_bluetooth_server_client), callback), | 353 base::Passed(&web_bluetooth_server_client), callback), |
| 354 base::Bind(&WebBluetoothServiceImpl::OnCreateGATTConnectionFailed, | 354 base::Bind(&WebBluetoothServiceImpl::OnCreateGATTConnectionFailed, |
| 355 weak_ptr_factory_.GetWeakPtr(), start_time, callback)); | 355 weak_ptr_factory_.GetWeakPtr(), start_time, callback)); |
| 356 } | 356 } |
| 357 | 357 |
| 358 void WebBluetoothServiceImpl::RemoteServerDisconnect( | |
| 359 const WebBluetoothDeviceId& device_id) { | |
| 360 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 361 RecordWebBluetoothFunctionCall( | |
| 362 UMAWebBluetoothFunction::REMOTE_GATT_SERVER_DISCONNECT); | |
| 363 | |
| 364 if (connected_devices_->IsConnectedToDeviceWithId(device_id)) { | |
| 365 DVLOG(1) << "Disconnecting device: " << device_id.str(); | |
| 366 connected_devices_->CloseConnectionToDeviceWithId(device_id); | |
| 367 } | |
| 368 } | |
| 369 | |
| 370 void WebBluetoothServiceImpl::RemoteServerGetPrimaryServices( | 358 void WebBluetoothServiceImpl::RemoteServerGetPrimaryServices( |
| 371 const WebBluetoothDeviceId& device_id, | 359 const WebBluetoothDeviceId& device_id, |
| 372 blink::mojom::WebBluetoothGATTQueryQuantity quantity, | 360 blink::mojom::WebBluetoothGATTQueryQuantity quantity, |
| 373 const base::Optional<BluetoothUUID>& services_uuid, | 361 const base::Optional<BluetoothUUID>& services_uuid, |
| 374 const RemoteServerGetPrimaryServicesCallback& callback) { | 362 const RemoteServerGetPrimaryServicesCallback& callback) { |
| 375 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 363 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 376 RecordWebBluetoothFunctionCall( | 364 RecordWebBluetoothFunctionCall( |
| 377 quantity == blink::mojom::WebBluetoothGATTQueryQuantity::SINGLE | 365 quantity == blink::mojom::WebBluetoothGATTQueryQuantity::SINGLE |
| 378 ? UMAWebBluetoothFunction::GET_PRIMARY_SERVICE | 366 ? UMAWebBluetoothFunction::GET_PRIMARY_SERVICE |
| 379 : UMAWebBluetoothFunction::GET_PRIMARY_SERVICES); | 367 : UMAWebBluetoothFunction::GET_PRIMARY_SERVICES); |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 840 new BluetoothDeviceChooserController(this, render_frame_host_, adapter)); | 828 new BluetoothDeviceChooserController(this, render_frame_host_, adapter)); |
| 841 | 829 |
| 842 device_chooser_controller_->GetDevice( | 830 device_chooser_controller_->GetDevice( |
| 843 std::move(options), | 831 std::move(options), |
| 844 base::Bind(&WebBluetoothServiceImpl::OnGetDeviceSuccess, | 832 base::Bind(&WebBluetoothServiceImpl::OnGetDeviceSuccess, |
| 845 weak_ptr_factory_.GetWeakPtr(), callback), | 833 weak_ptr_factory_.GetWeakPtr(), callback), |
| 846 base::Bind(&WebBluetoothServiceImpl::OnGetDeviceFailed, | 834 base::Bind(&WebBluetoothServiceImpl::OnGetDeviceFailed, |
| 847 weak_ptr_factory_.GetWeakPtr(), callback)); | 835 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 848 } | 836 } |
| 849 | 837 |
| 838 void WebBluetoothServiceImpl::HandleServerClientError( | |
| 839 const WebBluetoothDeviceId& device_id) { | |
| 840 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 841 RecordWebBluetoothFunctionCall( | |
| 842 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
| |
| 843 | |
| 844 // If a GATT connection exists for device identified by |device_id| then | |
| 845 // decreases the ref count for that connection. | |
| 846 if (connected_devices_->IsConnectedToDeviceWithId(device_id)) { | |
| 847 DVLOG(1) << "Disconnecting device: " << device_id.str(); | |
| 848 connected_devices_->CloseConnectionToDeviceWithId(device_id); | |
| 849 } | |
| 850 } | |
| 851 | |
| 850 void WebBluetoothServiceImpl::RemoteServerGetPrimaryServicesImpl( | 852 void WebBluetoothServiceImpl::RemoteServerGetPrimaryServicesImpl( |
| 851 const WebBluetoothDeviceId& device_id, | 853 const WebBluetoothDeviceId& device_id, |
| 852 blink::mojom::WebBluetoothGATTQueryQuantity quantity, | 854 blink::mojom::WebBluetoothGATTQueryQuantity quantity, |
| 853 const base::Optional<BluetoothUUID>& services_uuid, | 855 const base::Optional<BluetoothUUID>& services_uuid, |
| 854 const RemoteServerGetPrimaryServicesCallback& callback, | 856 const RemoteServerGetPrimaryServicesCallback& callback, |
| 855 device::BluetoothDevice* device) { | 857 device::BluetoothDevice* device) { |
| 856 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 858 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 857 DCHECK(device->IsGattServicesDiscoveryComplete()); | 859 DCHECK(device->IsGattServicesDiscoveryComplete()); |
| 858 | 860 |
| 859 std::vector<device::BluetoothRemoteGattService*> services = | 861 std::vector<device::BluetoothRemoteGattService*> services = |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 952 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 954 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 953 RecordConnectGATTTimeSuccess(base::TimeTicks::Now() - start_time); | 955 RecordConnectGATTTimeSuccess(base::TimeTicks::Now() - start_time); |
| 954 RecordConnectGATTOutcome(UMAConnectGATTOutcome::SUCCESS); | 956 RecordConnectGATTOutcome(UMAConnectGATTOutcome::SUCCESS); |
| 955 | 957 |
| 956 if (connected_devices_->IsConnectedToDeviceWithId(device_id)) { | 958 if (connected_devices_->IsConnectedToDeviceWithId(device_id)) { |
| 957 DVLOG(1) << "Already connected."; | 959 DVLOG(1) << "Already connected."; |
| 958 callback.Run(blink::mojom::WebBluetoothResult::SUCCESS); | 960 callback.Run(blink::mojom::WebBluetoothResult::SUCCESS); |
| 959 return; | 961 return; |
| 960 } | 962 } |
| 961 | 963 |
| 964 client.set_connection_error_handler( | |
| 965 base::Bind(&WebBluetoothServiceImpl::HandleServerClientError, | |
| 966 weak_ptr_factory_.GetWeakPtr(), device_id)); | |
| 962 callback.Run(blink::mojom::WebBluetoothResult::SUCCESS); | 967 callback.Run(blink::mojom::WebBluetoothResult::SUCCESS); |
| 963 connected_devices_->Insert(device_id, std::move(connection), | 968 connected_devices_->Insert(device_id, std::move(connection), |
| 964 std::move(client)); | 969 std::move(client)); |
| 965 } | 970 } |
| 966 | 971 |
| 967 void WebBluetoothServiceImpl::OnCreateGATTConnectionFailed( | 972 void WebBluetoothServiceImpl::OnCreateGATTConnectionFailed( |
| 968 base::TimeTicks start_time, | 973 base::TimeTicks start_time, |
| 969 const RemoteServerConnectCallback& callback, | 974 const RemoteServerConnectCallback& callback, |
| 970 device::BluetoothDevice::ConnectErrorCode error_code) { | 975 device::BluetoothDevice::ConnectErrorCode error_code) { |
| 971 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 976 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1215 descriptor_id_to_characteristic_id_.clear(); | 1220 descriptor_id_to_characteristic_id_.clear(); |
| 1216 characteristic_id_to_service_id_.clear(); | 1221 characteristic_id_to_service_id_.clear(); |
| 1217 service_id_to_device_address_.clear(); | 1222 service_id_to_device_address_.clear(); |
| 1218 connected_devices_.reset( | 1223 connected_devices_.reset( |
| 1219 new FrameConnectedBluetoothDevices(render_frame_host_)); | 1224 new FrameConnectedBluetoothDevices(render_frame_host_)); |
| 1220 device_chooser_controller_.reset(); | 1225 device_chooser_controller_.reset(); |
| 1221 BluetoothAdapterFactoryWrapper::Get().ReleaseAdapter(this); | 1226 BluetoothAdapterFactoryWrapper::Get().ReleaseAdapter(this); |
| 1222 } | 1227 } |
| 1223 | 1228 |
| 1224 } // namespace content | 1229 } // namespace content |
| OLD | NEW |