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

Unified Diff: device/bluetooth/bluez/bluetooth_device_bluez.cc

Issue 2357083002: bluetooth: Leak connections to paired devices (Closed)
Patch Set: Fix test Created 4 years, 3 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
« no previous file with comments | « device/bluetooth/bluetooth_device.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluez/bluetooth_device_bluez.cc
diff --git a/device/bluetooth/bluez/bluetooth_device_bluez.cc b/device/bluetooth/bluez/bluetooth_device_bluez.cc
index 44338eb7250916fbd2047485b91c876f17d6ffc4..417ed161d40b86266ffbb43cea208a835ae1a5ec 100644
--- a/device/bluetooth/bluez/bluetooth_device_bluez.cc
+++ b/device/bluetooth/bluez/bluetooth_device_bluez.cc
@@ -236,6 +236,28 @@ bool BluetoothDeviceBlueZ::IsGattServicesDiscoveryComplete() const {
}
void BluetoothDeviceBlueZ::DisconnectGatt() {
+ // 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 in bluetoothd, we might unwittingly kill a connection to a
+ // device the user is still interested in, e.g. a mouse. A device's paired
+ // status is usually a good indication that the device is being used by other
+ // parts of the system and therefore we leak these connections.
+ // TODO(crbug.com/630586): Call disconnect for all devices.
+
+ // IsPaired() returns true if we've connected to the device before. So we
+ // check the dbus property directly.
+ // TODO(crbug.com/649651): Use IsPaired once it returns true only for paired
+ // devices.
+ bluez::BluetoothDeviceClient::Properties* properties =
+ bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties(
+ object_path_);
+ DCHECK(properties);
+
+ if (properties->paired.value()) {
+ LOG(WARNING) << "Leaking connection to paired device.";
+ return;
+ }
+
Disconnect(base::Bind(&base::DoNothing), base::Bind(&base::DoNothing));
}
@@ -557,8 +579,8 @@ void BluetoothDeviceBlueZ::CreateGattConnection(
return;
}
- // TODO(armansito): Until there is a way to create a reference counted GATT
- // connection in bluetoothd, simply do a regular connect.
+ // TODO(crbug.com/630586): Until there is a way to create a reference counted
+ // GATT connection in bluetoothd, simply do a regular connect.
Connect(NULL, base::Bind(&BluetoothDeviceBlueZ::OnCreateGattConnection,
weak_ptr_factory_.GetWeakPtr(), callback),
error_callback);
« no previous file with comments | « device/bluetooth/bluetooth_device.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698