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( | 358 void WebBluetoothServiceImpl::HandleServerClientError( |
scheib
2017/03/20 21:39:13
Keep .h and .cc file methods in same order please.
juncai
2017/03/21 00:52:35
Done.
| |
359 const WebBluetoothDeviceId& device_id) { | 359 const WebBluetoothDeviceId& device_id) { |
360 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 360 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
361 RecordWebBluetoothFunctionCall( | 361 RecordWebBluetoothFunctionCall( |
362 UMAWebBluetoothFunction::REMOTE_GATT_SERVER_DISCONNECT); | 362 UMAWebBluetoothFunction::REMOTE_GATT_SERVER_DISCONNECT); |
363 | 363 |
364 if (connected_devices_->IsConnectedToDeviceWithId(device_id)) { | 364 if (connected_devices_->IsConnectedToDeviceWithId(device_id)) { |
365 DVLOG(1) << "Disconnecting device: " << device_id.str(); | 365 DVLOG(1) << "Disconnecting device: " << device_id.str(); |
366 connected_devices_->CloseConnectionToDeviceWithId(device_id); | 366 connected_devices_->CloseConnectionToDeviceWithId(device_id); |
367 } | 367 } |
368 } | 368 } |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
952 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 952 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
953 RecordConnectGATTTimeSuccess(base::TimeTicks::Now() - start_time); | 953 RecordConnectGATTTimeSuccess(base::TimeTicks::Now() - start_time); |
954 RecordConnectGATTOutcome(UMAConnectGATTOutcome::SUCCESS); | 954 RecordConnectGATTOutcome(UMAConnectGATTOutcome::SUCCESS); |
955 | 955 |
956 if (connected_devices_->IsConnectedToDeviceWithId(device_id)) { | 956 if (connected_devices_->IsConnectedToDeviceWithId(device_id)) { |
957 DVLOG(1) << "Already connected."; | 957 DVLOG(1) << "Already connected."; |
958 callback.Run(blink::mojom::WebBluetoothResult::SUCCESS); | 958 callback.Run(blink::mojom::WebBluetoothResult::SUCCESS); |
959 return; | 959 return; |
960 } | 960 } |
961 | 961 |
962 client.set_connection_error_handler( | |
963 base::Bind(&WebBluetoothServiceImpl::HandleServerClientError, | |
964 weak_ptr_factory_.GetWeakPtr(), device_id)); | |
962 callback.Run(blink::mojom::WebBluetoothResult::SUCCESS); | 965 callback.Run(blink::mojom::WebBluetoothResult::SUCCESS); |
963 connected_devices_->Insert(device_id, std::move(connection), | 966 connected_devices_->Insert(device_id, std::move(connection), |
964 std::move(client)); | 967 std::move(client)); |
965 } | 968 } |
966 | 969 |
967 void WebBluetoothServiceImpl::OnCreateGATTConnectionFailed( | 970 void WebBluetoothServiceImpl::OnCreateGATTConnectionFailed( |
968 base::TimeTicks start_time, | 971 base::TimeTicks start_time, |
969 const RemoteServerConnectCallback& callback, | 972 const RemoteServerConnectCallback& callback, |
970 device::BluetoothDevice::ConnectErrorCode error_code) { | 973 device::BluetoothDevice::ConnectErrorCode error_code) { |
971 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 974 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(); | 1218 descriptor_id_to_characteristic_id_.clear(); |
1216 characteristic_id_to_service_id_.clear(); | 1219 characteristic_id_to_service_id_.clear(); |
1217 service_id_to_device_address_.clear(); | 1220 service_id_to_device_address_.clear(); |
1218 connected_devices_.reset( | 1221 connected_devices_.reset( |
1219 new FrameConnectedBluetoothDevices(render_frame_host_)); | 1222 new FrameConnectedBluetoothDevices(render_frame_host_)); |
1220 device_chooser_controller_.reset(); | 1223 device_chooser_controller_.reset(); |
1221 BluetoothAdapterFactoryWrapper::Get().ReleaseAdapter(this); | 1224 BluetoothAdapterFactoryWrapper::Get().ReleaseAdapter(this); |
1222 } | 1225 } |
1223 | 1226 |
1224 } // namespace content | 1227 } // namespace content |
OLD | NEW |