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 937d601ffeb244d5d63045af3548ca9f4edfd228..0bf2382fbae3adbcad7c5fd35120103fdf58e7a6 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_.emplace(addr->To<std::string>(), std::move(connection)); |
Rahul Chaturvedi
2016/09/07 21:31:38
Also, don't expect to "not" have the address in th
Rahul Chaturvedi
2016/09/07 21:31:39
can't use map::emplace
Eric Caruso
2016/09/07 21:33:31
I switched this out for operator[] which will caus
|
OnGattConnectStateChanged(std::move(addr), true); |
} |
@@ -954,7 +956,15 @@ 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()) |
Rahul Chaturvedi
2016/09/07 21:31:38
nit: {} around multiline
|
+ LOG(WARNING) << "OnGattDisconnected called, " |
+ << "but no gatt connection was found"; |
+ else |
+ gatt_connections_.erase(it); |
+ |
OnGattConnectStateChanged(std::move(addr), false); |
} |