Chromium Code Reviews| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 MAX_ERROR, | 42 MAX_ERROR, |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 enum class UMARequestDeviceOutcome { | 45 enum class UMARequestDeviceOutcome { |
| 46 SUCCESS = 0, | 46 SUCCESS = 0, |
| 47 NO_BLUETOOTH_ADAPTER = 1, | 47 NO_BLUETOOTH_ADAPTER = 1, |
| 48 NO_RENDER_FRAME = 2, | 48 NO_RENDER_FRAME = 2, |
| 49 DISCOVERY_START_FAILED = 3, | 49 DISCOVERY_START_FAILED = 3, |
| 50 DISCOVERY_STOP_FAILED = 4, | 50 DISCOVERY_STOP_FAILED = 4, |
| 51 NO_MATCHING_DEVICES_FOUND = 5, | 51 NO_MATCHING_DEVICES_FOUND = 5, |
| 52 BLUETOOTH_ADAPTER_NOT_PRESENT = 6, | |
| 53 BLUETOOTH_ADAPTER_OFF = 7, | |
| 52 // NOTE: Add new requestDevice() outcomes immediately above this line. Make | 54 // NOTE: Add new requestDevice() outcomes immediately above this line. Make |
| 53 // sure to update the enum list in | 55 // sure to update the enum list in |
| 54 // tools/metrics/histogram/histograms.xml accordingly. | 56 // tools/metrics/histogram/histograms.xml accordingly. |
| 55 COUNT | 57 COUNT |
| 56 }; | 58 }; |
| 57 | 59 |
| 58 void RecordRequestDeviceOutcome(UMARequestDeviceOutcome outcome) { | 60 void RecordRequestDeviceOutcome(UMARequestDeviceOutcome outcome) { |
| 59 UMA_HISTOGRAM_ENUMERATION("Bluetooth.RequestDevice.Outcome", | 61 UMA_HISTOGRAM_ENUMERATION("Bluetooth.RequestDevice.Outcome", |
| 60 static_cast<int>(outcome), | 62 static_cast<int>(outcome), |
| 61 static_cast<int>(UMARequestDeviceOutcome::COUNT)); | 63 static_cast<int>(UMARequestDeviceOutcome::COUNT)); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 289 .insert(std::make_pair( | 291 .insert(std::make_pair( |
| 290 std::make_pair(thread_id, request_id), | 292 std::make_pair(thread_id, request_id), |
| 291 RequestDeviceSession(filters, optional_services))) | 293 RequestDeviceSession(filters, optional_services))) |
| 292 .second) { | 294 .second) { |
| 293 LOG(ERROR) << "2 requestDevice() calls with the same thread_id (" | 295 LOG(ERROR) << "2 requestDevice() calls with the same thread_id (" |
| 294 << thread_id << ") and request_id (" << request_id | 296 << thread_id << ") and request_id (" << request_id |
| 295 << ") shouldn't arrive at the same BluetoothDispatcherHost."; | 297 << ") shouldn't arrive at the same BluetoothDispatcherHost."; |
| 296 bad_message::ReceivedBadMessage( | 298 bad_message::ReceivedBadMessage( |
| 297 this, bad_message::BDH_DUPLICATE_REQUEST_DEVICE_ID); | 299 this, bad_message::BDH_DUPLICATE_REQUEST_DEVICE_ID); |
| 298 } | 300 } |
| 301 if (!adapter_->IsPresent()) { | |
| 302 VLOG(1) << "Bluetooth Adapter not present. Can't serve requestDevice."; | |
| 303 RecordRequestDeviceOutcome( | |
| 304 UMARequestDeviceOutcome::BLUETOOTH_ADAPTER_NOT_PRESENT); | |
| 305 Send(new BluetoothMsg_RequestDeviceError( | |
|
Jeffrey Yasskin
2015/08/05 17:13:14
Every Send needs to be matched to a request_device
ortuno
2015/08/05 18:01:53
Done.
| |
| 306 thread_id, request_id, WebBluetoothError::NoBluetoothAdapter)); | |
| 307 return; | |
| 308 } | |
| 309 if (!adapter_->IsPowered()) { | |
|
Jeffrey Yasskin
2015/08/05 17:13:13
This one isn't going to happen once we have the re
ortuno
2015/08/05 18:01:53
True. But the dialog is gonna take a couple of rel
| |
| 310 VLOG(1) << "Bluetooth Adapter is not powered. Can't serve requestDevice."; | |
| 311 RecordRequestDeviceOutcome( | |
| 312 UMARequestDeviceOutcome::BLUETOOTH_ADAPTER_OFF); | |
| 313 Send(new BluetoothMsg_RequestDeviceError( | |
| 314 thread_id, request_id, WebBluetoothError::BluetoothAdapterOff)); | |
| 315 return; | |
| 316 } | |
| 299 adapter_->StartDiscoverySessionWithFilter( | 317 adapter_->StartDiscoverySessionWithFilter( |
| 300 ComputeScanFilter(filters), | 318 ComputeScanFilter(filters), |
| 301 base::Bind(&BluetoothDispatcherHost::OnDiscoverySessionStarted, | 319 base::Bind(&BluetoothDispatcherHost::OnDiscoverySessionStarted, |
| 302 weak_ptr_factory_.GetWeakPtr(), thread_id, request_id), | 320 weak_ptr_factory_.GetWeakPtr(), thread_id, request_id), |
| 303 base::Bind(&BluetoothDispatcherHost::OnDiscoverySessionStartedError, | 321 base::Bind(&BluetoothDispatcherHost::OnDiscoverySessionStartedError, |
| 304 weak_ptr_factory_.GetWeakPtr(), thread_id, request_id)); | 322 weak_ptr_factory_.GetWeakPtr(), thread_id, request_id)); |
| 305 } else { | 323 } else { |
| 306 DLOG(WARNING) << "No BluetoothAdapter. Can't serve requestDevice."; | 324 DLOG(WARNING) << "No BluetoothAdapter. Can't serve requestDevice."; |
| 307 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::NO_BLUETOOTH_ADAPTER); | 325 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::NO_BLUETOOTH_ADAPTER); |
| 308 Send(new BluetoothMsg_RequestDeviceError( | 326 Send(new BluetoothMsg_RequestDeviceError( |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 703 | 721 |
| 704 void BluetoothDispatcherHost::OnWriteValueFailed( | 722 void BluetoothDispatcherHost::OnWriteValueFailed( |
| 705 int thread_id, | 723 int thread_id, |
| 706 int request_id, | 724 int request_id, |
| 707 device::BluetoothGattService::GattErrorCode error_code) { | 725 device::BluetoothGattService::GattErrorCode error_code) { |
| 708 Send(new BluetoothMsg_WriteCharacteristicValueError( | 726 Send(new BluetoothMsg_WriteCharacteristicValueError( |
| 709 thread_id, request_id, TranslateGATTError(error_code))); | 727 thread_id, request_id, TranslateGATTError(error_code))); |
| 710 } | 728 } |
| 711 | 729 |
| 712 } // namespace content | 730 } // namespace content |
| OLD | NEW |