Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Unified Diff: device/bluetooth/bluetooth_device.cc

Issue 1583333003: bluetooth: Invalidate connection objects if a connection fails and add histograms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Address scheib's comments Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/bluetooth_device.cc
diff --git a/device/bluetooth/bluetooth_device.cc b/device/bluetooth/bluetooth_device.cc
index 05532cc2b071b831cbc744c2d107cf6c07da519f..c85af11c090b5233e6b40d010689d74e841ca17f 100644
--- a/device/bluetooth/bluetooth_device.cc
+++ b/device/bluetooth/bluetooth_device.cc
@@ -303,6 +303,10 @@ void BluetoothDevice::DidConnectGatt() {
}
void BluetoothDevice::DidFailToConnectGatt(ConnectErrorCode error) {
+ // Connection request should only be made if there are no active
+ // connections.
+ DCHECK(gatt_connections_.empty());
+
for (const auto& error_callback : create_gatt_connection_error_callbacks_)
error_callback.Run(error);
create_gatt_connection_success_callbacks_.clear();
@@ -311,13 +315,8 @@ void BluetoothDevice::DidFailToConnectGatt(ConnectErrorCode error) {
void BluetoothDevice::DidDisconnectGatt() {
// Pending calls to connect GATT are not expected, if they were then
- // DidFailToConnectGatt should be called. But in case callbacks exist
- // flush them to ensure a consistent state.
- if (create_gatt_connection_error_callbacks_.size() > 0) {
- VLOG(1) << "Unexpected / unexplained DidDisconnectGatt call while "
- "create_gatt_connection_error_callbacks_ are pending.";
- }
- DidFailToConnectGatt(ERROR_FAILED);
+ // DidFailToConnectGatt should have been called.
+ DCHECK(create_gatt_connection_error_callbacks_.empty());
// Invalidate all BluetoothGattConnection objects.
for (BluetoothGattConnection* connection : gatt_connections_) {
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_device_android.cc » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698