Index: components/arc/bluetooth/arc_bluetooth_bridge.cc |
diff --git a/components/arc/bluetooth/arc_bluetooth_bridge.cc b/components/arc/bluetooth/arc_bluetooth_bridge.cc |
index 50963c920acb590c87964d8ff3cc9fbea4a1d6d3..5805d487ce396566b70f74ec46023dad047c5aa7 100644 |
--- a/components/arc/bluetooth/arc_bluetooth_bridge.cc |
+++ b/components/arc/bluetooth/arc_bluetooth_bridge.cc |
@@ -943,7 +943,9 @@ void ArcBluetoothBridge::OnGattConnectStateChanged( |
void ArcBluetoothBridge::OnGattConnected( |
mojom::BluetoothAddressPtr addr, |
- std::unique_ptr<BluetoothGattConnection> connection) const { |
+ std::unique_ptr<BluetoothGattConnection> connection) { |
+ DCHECK(CalledOnValidThread()); |
+ gatt_connections_[addr->To<std::string>()] = std::move(connection); |
OnGattConnectStateChanged(std::move(addr), true); |
} |
@@ -954,7 +956,16 @@ void ArcBluetoothBridge::OnGattConnectError( |
} |
void ArcBluetoothBridge::OnGattDisconnected( |
- mojom::BluetoothAddressPtr addr) const { |
+ mojom::BluetoothAddressPtr addr) { |
+ DCHECK(CalledOnValidThread()); |
+ auto it = gatt_connections_.find(addr->To<std::string>()); |
+ if (it == gatt_connections_.end()) { |
+ LOG(WARNING) << "OnGattDisconnected called, " |
+ << "but no gatt connection was found"; |
+ } else { |
+ gatt_connections_.erase(it); |
+ } |
+ |
OnGattConnectStateChanged(std::move(addr), false); |
} |