| Index: device/bluetooth/bluetooth_gatt_connection_chromeos.cc
|
| diff --git a/device/bluetooth/bluetooth_gatt_connection_chromeos.cc b/device/bluetooth/bluetooth_gatt_connection_chromeos.cc
|
| index 57aaa4d399ad5248704e5076bfd979ed8094bc62..b01389454dc839d7e6f8e2fae62ee5937a0a30ab 100644
|
| --- a/device/bluetooth/bluetooth_gatt_connection_chromeos.cc
|
| +++ b/device/bluetooth/bluetooth_gatt_connection_chromeos.cc
|
| @@ -15,8 +15,9 @@ namespace chromeos {
|
| BluetoothGattConnectionChromeOS::BluetoothGattConnectionChromeOS(
|
| scoped_refptr<device::BluetoothAdapter> adapter,
|
| const std::string& device_address,
|
| - const dbus::ObjectPath& object_path)
|
| - : BluetoothGattConnection(adapter.get(), device_address),
|
| + const dbus::ObjectPath& object_path,
|
| + bool in_progress)
|
| + : BluetoothGattConnection(adapter.get(), device_address, in_progress),
|
| connected_(true),
|
| object_path_(object_path) {
|
| DCHECK(adapter_.get());
|
| @@ -51,18 +52,17 @@ bool BluetoothGattConnectionChromeOS::IsConnected() {
|
| }
|
|
|
| void BluetoothGattConnectionChromeOS::Disconnect() {
|
| - if (!connected_) {
|
| + if (!connected_ && in_progress_) {
|
| + VLOG(1) << "Connection aborted during establishment.";
|
| + return;
|
| + }
|
| +
|
| + if (!connected_ && !in_progress_) {
|
| VLOG(1) << "Connection already inactive.";
|
| return;
|
| }
|
|
|
| - // TODO(armansito): There isn't currently a good way to manage the ownership
|
| - // of a connection between Chrome and bluetoothd plugins/profiles. Until
|
| - // a proper reference count is kept by bluetoothd, we might unwittingly kill
|
| - // a connection that is managed by the daemon (e.g. HoG). For now, just return
|
| - // success to indicate that this BluetoothGattConnection is no longer active,
|
| - // even though the underlying connection won't actually be disconnected. This
|
| - // technically doesn't violate the contract put forth by this API.
|
| + BluetoothGattConnection::Disconnect();
|
| connected_ = false;
|
| }
|
|
|
| @@ -92,9 +92,14 @@ void BluetoothGattConnectionChromeOS::DevicePropertyChanged(
|
| return;
|
| }
|
|
|
| - if (property_name == properties->connected.name() &&
|
| - !properties->connected.value())
|
| - connected_ = false;
|
| + if (property_name == properties->connected.name()) {
|
| + if (properties->connected.value()) {
|
| + connected_ = true;
|
| + in_progress_ = false;
|
| + } else {
|
| + connected_ = false;
|
| + }
|
| + }
|
|
|
| // The remote device's bluetooth address may change if it is paired while
|
| // connected.
|
|
|