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

Unified Diff: device/bluetooth/bluetooth_adapter_chromeos.cc

Issue 935383003: Fix BluetoothAdapterProfileChromeOS lifecycle management (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add DCHECK confirming profiles are gone during shutdown Created 5 years, 10 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
Index: device/bluetooth/bluetooth_adapter_chromeos.cc
diff --git a/device/bluetooth/bluetooth_adapter_chromeos.cc b/device/bluetooth/bluetooth_adapter_chromeos.cc
index e6c628322d349b629b507b17f753d8d541b35955..6af221ad2569848e390f23ee226b077e027d8cab 100644
--- a/device/bluetooth/bluetooth_adapter_chromeos.cc
+++ b/device/bluetooth/bluetooth_adapter_chromeos.cc
@@ -85,6 +85,7 @@ void BluetoothAdapterChromeOS::Shutdown() {
if (IsPresent())
RemoveAdapter(); // Also deletes devices_.
DCHECK(devices_.empty());
+ DCHECK(profiles_.empty());
armansito 2015/02/24 23:32:51 Is this because RemoveAdapter clears |profiles_|?
Marie Janssen 2015/02/27 18:56:58 RemoveAdapter() signals the profiles through Prese
DBusThreadManager::Get()->GetBluetoothAdapterClient()->RemoveObserver(this);
DBusThreadManager::Get()->GetBluetoothDeviceClient()->RemoveObserver(this);
@@ -964,14 +965,22 @@ void BluetoothAdapterChromeOS::UseProfile(
}
profiles_[uuid] = BluetoothAdapterProfileChromeOS::Register(
- this, uuid, options,
+ uuid, options,
base::Bind(&BluetoothAdapterChromeOS::OnRegisterProfile, this, uuid,
device_path, delegate, success_callback, error_callback),
base::Bind(&BluetoothAdapterChromeOS::OnRegisterProfileError, this, uuid,
error_callback));
}
-void BluetoothAdapterChromeOS::ReleaseProfile(const BluetoothUUID& uuid) {
+void BluetoothAdapterChromeOS::ReleaseProfile(
+ const dbus::ObjectPath& device_path,
+ BluetoothAdapterProfileChromeOS* profile) {
armansito 2015/02/24 23:32:51 Add VLOG
Marie Janssen 2015/02/27 18:56:58 Done.
+ profile->RemoveDelegate(
+ device_path, base::Bind(&BluetoothAdapterChromeOS::RemoveProfile,
+ weak_ptr_factory_.GetWeakPtr(), profile->uuid()));
+}
+
+void BluetoothAdapterChromeOS::RemoveProfile(const BluetoothUUID& uuid) {
if (profiles_.find(uuid) != profiles_.end()) {
delete profiles_[uuid];
profiles_.erase(uuid);
@@ -1011,8 +1020,9 @@ void BluetoothAdapterChromeOS::OnRegisterProfileError(
LOG(WARNING) << object_path_.value()
armansito 2015/02/24 23:32:51 Change this to VLOG
Marie Janssen 2015/02/27 18:56:58 Done.
<< ": Failed to register profile: " << error_name << ": "
<< error_message;
+ delete profiles_[uuid];
+ profiles_.erase(uuid);
armansito 2015/02/24 23:32:51 I think you can simplify the memory management her
Marie Janssen 2015/02/27 18:56:58 I've reworked this to avoid these problems. Now t
error_callback.Run(error_message);
- ReleaseProfile(uuid);
}
void BluetoothAdapterChromeOS::OnSetDiscoverable(

Powered by Google App Engine
This is Rietveld 408576698