Chromium Code Reviews| 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( |