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

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: Clean up 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 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_) {
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_device_android.cc » ('j') | device/bluetooth/bluetooth_device_android.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698