Index: device/bluetooth/bluetooth_device.cc |
diff --git a/device/bluetooth/bluetooth_device.cc b/device/bluetooth/bluetooth_device.cc |
index e666aa5c870785788f24031163407101a6ef8146..79e2caf2386f90cf94cd0ed8d6df649eb6bf532a 100644 |
--- a/device/bluetooth/bluetooth_device.cc |
+++ b/device/bluetooth/bluetooth_device.cc |
@@ -297,17 +297,21 @@ void BluetoothDevice::DidFailToConnectGatt(ConnectErrorCode error) { |
error_callback.Run(error); |
create_gatt_connection_success_callbacks_.clear(); |
create_gatt_connection_error_callbacks_.clear(); |
+ |
+ // TODO(ortuno): We shouldn't need to invalidate connections since |
+ // DidFailToConnectGatt should only be called when a connection attempt |
+ // fails and there are no connection objects. |
+ // http://crbug.com/570850 |
+ for (BluetoothGattConnection* connection : gatt_connections_) { |
scheib
2016/01/15 01:39:45
DCHECK this instead.
ortuno
2016/01/15 21:34:41
Done.
|
+ connection->InvalidateConnectionReference(); |
+ } |
+ gatt_connections_.clear(); |
} |
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. |
+ CHECK(!create_gatt_connection_error_callbacks_.size()); |
scheib
2016/01/15 01:39:44
If you use CHECK, please TODO and file a ship bloc
ortuno
2016/01/15 21:34:41
Done.
|
// Invalidate all BluetoothGattConnection objects. |
for (BluetoothGattConnection* connection : gatt_connections_) { |