| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // NETWORK_ERROR Note: | 5 // NETWORK_ERROR Note: |
| 6 // When a device can't be found in the BluetoothAdapter, that generally | 6 // When a device can't be found in the BluetoothAdapter, that generally |
| 7 // indicates that it's gone out of range. We reject with a NetworkError in that | 7 // indicates that it's gone out of range. We reject with a NetworkError in that |
| 8 // case. | 8 // case. |
| 9 // https://webbluetoothchrome.github.io/web-bluetooth/#dom-bluetoothdevice-conne
ctgatt | 9 // https://webbluetoothchrome.github.io/web-bluetooth/#dom-bluetoothdevice-conne
ctgatt |
| 10 | 10 |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 // the device, because any domain can connect to any device. But once | 457 // the device, because any domain can connect to any device. But once |
| 458 // permissions are implemented we should check that the domain has access to | 458 // permissions are implemented we should check that the domain has access to |
| 459 // the device. https://crbug.com/484745 | 459 // the device. https://crbug.com/484745 |
| 460 device::BluetoothDevice* device = adapter_->GetDevice(device_instance_id); | 460 device::BluetoothDevice* device = adapter_->GetDevice(device_instance_id); |
| 461 if (device == nullptr) { // See "NETWORK_ERROR Note" above. | 461 if (device == nullptr) { // See "NETWORK_ERROR Note" above. |
| 462 RecordConnectGATTOutcome(UMAConnectGATTOutcome::NO_DEVICE); | 462 RecordConnectGATTOutcome(UMAConnectGATTOutcome::NO_DEVICE); |
| 463 Send(new BluetoothMsg_ConnectGATTError( | 463 Send(new BluetoothMsg_ConnectGATTError( |
| 464 thread_id, request_id, WebBluetoothError::DeviceNoLongerInRange)); | 464 thread_id, request_id, WebBluetoothError::DeviceNoLongerInRange)); |
| 465 return; | 465 return; |
| 466 } | 466 } |
| 467 // TODO(ortuno): Save the BluetoothGattConnection so we can disconnect |
| 468 // from it. |
| 467 device->CreateGattConnection( | 469 device->CreateGattConnection( |
| 468 base::Bind(&BluetoothDispatcherHost::OnGATTConnectionCreated, | 470 base::Bind(&BluetoothDispatcherHost::OnGATTConnectionCreated, |
| 469 weak_ptr_factory_.GetWeakPtr(), thread_id, request_id, | 471 weak_ptr_factory_.GetWeakPtr(), thread_id, request_id, |
| 470 device_instance_id, start_time), | 472 device_instance_id, start_time), |
| 471 base::Bind(&BluetoothDispatcherHost::OnCreateGATTConnectionError, | 473 base::Bind(&BluetoothDispatcherHost::OnCreateGATTConnectionError, |
| 472 weak_ptr_factory_.GetWeakPtr(), thread_id, request_id, | 474 weak_ptr_factory_.GetWeakPtr(), thread_id, request_id, |
| 473 device_instance_id, start_time)); | 475 device_instance_id, start_time)); |
| 474 } | 476 } |
| 475 | 477 |
| 476 void BluetoothDispatcherHost::OnGetPrimaryService( | 478 void BluetoothDispatcherHost::OnGetPrimaryService( |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::SUCCESS); | 821 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::SUCCESS); |
| 820 Send(new BluetoothMsg_RequestDeviceSuccess(session->thread_id, | 822 Send(new BluetoothMsg_RequestDeviceSuccess(session->thread_id, |
| 821 session->request_id, device_ipc)); | 823 session->request_id, device_ipc)); |
| 822 request_device_sessions_.Remove(chooser_id); | 824 request_device_sessions_.Remove(chooser_id); |
| 823 } | 825 } |
| 824 | 826 |
| 825 void BluetoothDispatcherHost::OnGATTConnectionCreated( | 827 void BluetoothDispatcherHost::OnGATTConnectionCreated( |
| 826 int thread_id, | 828 int thread_id, |
| 827 int request_id, | 829 int request_id, |
| 828 const std::string& device_instance_id, | 830 const std::string& device_instance_id, |
| 829 base::TimeTicks start_time, | 831 base::TimeTicks start_time) { |
| 830 scoped_ptr<device::BluetoothGattConnection> connection) { | |
| 831 // TODO(ortuno): Save the BluetoothGattConnection so we can disconnect | |
| 832 // from it. | |
| 833 RecordConnectGATTTimeSuccess(base::TimeTicks::Now() - start_time); | 832 RecordConnectGATTTimeSuccess(base::TimeTicks::Now() - start_time); |
| 834 RecordConnectGATTOutcome(UMAConnectGATTOutcome::SUCCESS); | 833 RecordConnectGATTOutcome(UMAConnectGATTOutcome::SUCCESS); |
| 835 Send(new BluetoothMsg_ConnectGATTSuccess(thread_id, request_id, | 834 Send(new BluetoothMsg_ConnectGATTSuccess(thread_id, request_id, |
| 836 device_instance_id)); | 835 device_instance_id)); |
| 837 } | 836 } |
| 838 | 837 |
| 839 void BluetoothDispatcherHost::OnCreateGATTConnectionError( | 838 void BluetoothDispatcherHost::OnCreateGATTConnectionError( |
| 840 int thread_id, | 839 int thread_id, |
| 841 int request_id, | 840 int request_id, |
| 842 const std::string& device_instance_id, | 841 const std::string& device_instance_id, |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 | 933 |
| 935 void BluetoothDispatcherHost::ShowBluetoothPairingLink() { | 934 void BluetoothDispatcherHost::ShowBluetoothPairingLink() { |
| 936 NOTIMPLEMENTED(); | 935 NOTIMPLEMENTED(); |
| 937 } | 936 } |
| 938 | 937 |
| 939 void BluetoothDispatcherHost::ShowBluetoothAdapterOffLink() { | 938 void BluetoothDispatcherHost::ShowBluetoothAdapterOffLink() { |
| 940 NOTIMPLEMENTED(); | 939 NOTIMPLEMENTED(); |
| 941 } | 940 } |
| 942 | 941 |
| 943 } // namespace content | 942 } // namespace content |
| OLD | NEW |