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..8f4d90769ae1fc17552b814af1ebcc2a93521981 100644 |
--- a/device/bluetooth/bluetooth_adapter_chromeos.cc |
+++ b/device/bluetooth/bluetooth_adapter_chromeos.cc |
@@ -964,14 +964,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) { |
+ profile->RemoveDelegate( |
+ device_path, base::Bind(&BluetoothAdapterChromeOS::RemoveProfile, |
+ weak_ptr_factory_.GetWeakPtr(), profile->uuid())); |
Ilya Sherman
2015/02/21 01:22:10
nit: Is this what git cl format produces? The for
Marie Janssen
2015/02/23 17:49:09
This is in fact what cl format produced. It looks
|
+} |
+ |
+void BluetoothAdapterChromeOS::RemoveProfile(const BluetoothUUID& uuid) { |
if (profiles_.find(uuid) != profiles_.end()) { |
delete profiles_[uuid]; |
profiles_.erase(uuid); |
@@ -1011,8 +1019,8 @@ void BluetoothAdapterChromeOS::OnRegisterProfileError( |
LOG(WARNING) << object_path_.value() |
<< ": Failed to register profile: " << error_name << ": " |
<< error_message; |
+ delete profiles_[uuid]; |
error_callback.Run(error_message); |
- ReleaseProfile(uuid); |
} |
void BluetoothAdapterChromeOS::OnSetDiscoverable( |