Chromium Code Reviews| 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..0eca07d76b151c9b28c031cd49d9c096a91918d1 100644 |
| --- a/components/arc/bluetooth/arc_bluetooth_bridge.cc |
| +++ b/components/arc/bluetooth/arc_bluetooth_bridge.cc |
| @@ -943,7 +943,8 @@ void ArcBluetoothBridge::OnGattConnectStateChanged( |
| void ArcBluetoothBridge::OnGattConnected( |
| mojom::BluetoothAddressPtr addr, |
| - std::unique_ptr<BluetoothGattConnection> connection) const { |
| + std::unique_ptr<BluetoothGattConnection> connection) { |
| + gatt_connections_.emplace(addr->To<std::string>(), std::move(connection)); |
|
Luis Héctor Chávez
2016/09/07 19:54:14
nit: DCHECK(CalledOnValidThread());
|
| OnGattConnectStateChanged(std::move(addr), true); |
| } |
| @@ -954,7 +955,14 @@ void ArcBluetoothBridge::OnGattConnectError( |
| } |
| void ArcBluetoothBridge::OnGattDisconnected( |
| - mojom::BluetoothAddressPtr addr) const { |
| + mojom::BluetoothAddressPtr addr) { |
| + auto it = gatt_connections_.find(addr->To<std::string>()); |
|
Luis Héctor Chávez
2016/09/07 19:54:14
nit: DCHECK(CalledOnValidThread());
|
| + 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); |
| } |