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

Unified Diff: device/bluetooth/bluetooth_adapter_chromeos.h

Issue 935383003: Fix BluetoothAdapterProfileChromeOS lifecycle management (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix for leak detected by LSAN 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.h
diff --git a/device/bluetooth/bluetooth_adapter_chromeos.h b/device/bluetooth/bluetooth_adapter_chromeos.h
index 61e4a3a3da9c3c12e5545a96e13a7a059cb80b00..415fce89e0bfedad78ff5673d0b87bc7aed124ad 100644
--- a/device/bluetooth/bluetooth_adapter_chromeos.h
+++ b/device/bluetooth/bluetooth_adapter_chromeos.h
@@ -145,8 +145,9 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterChromeOS
const ProfileRegisteredCallback& success_callback,
const ErrorCompletionCallback& error_callback);
- // Releases the profile associated with |uuid|
- void ReleaseProfile(const device::BluetoothUUID& uuid);
+ // Release use of a profile by a device.
+ void ReleaseProfile(const dbus::ObjectPath& device_path,
+ BluetoothAdapterProfileChromeOS* profile);
protected:
// BluetoothAdapter:
@@ -283,20 +284,21 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterChromeOS
// Called by dbus:: on completion of the D-Bus method to register a profile.
void OnRegisterProfile(const device::BluetoothUUID& uuid,
- const dbus::ObjectPath& device_path,
- BluetoothProfileServiceProvider::Delegate* delegate,
- const ProfileRegisteredCallback& success_callback,
- const ErrorCompletionCallback& error_callback);
- bool SetProfileDelegate(const device::BluetoothUUID& uuid,
+ BluetoothAdapterProfileChromeOS* profile);
+
+ void SetProfileDelegate(const device::BluetoothUUID& uuid,
const dbus::ObjectPath& device_path,
BluetoothProfileServiceProvider::Delegate* delegate,
const ProfileRegisteredCallback& success_callback,
const ErrorCompletionCallback& error_callback);
void OnRegisterProfileError(const device::BluetoothUUID& uuid,
- const ErrorCompletionCallback& error_callback,
const std::string& error_name,
const std::string& error_message);
+ // Called by BluetoothAdapterProfileChromeOS when no users of a profile
+ // remain.
+ void RemoveProfile(const device::BluetoothUUID& uuid);
+
// Processes the queued discovery requests. For each DiscoveryCallbackPair in
// the queue, this method will try to add a new discovery session. This method
// is called whenever a pending D-Bus call to start or stop discovery has
@@ -340,6 +342,14 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterChromeOS
// The profiles we have registered with the bluetooth daemon.
std::map<device::BluetoothUUID, BluetoothAdapterProfileChromeOS*> profiles_;
+ // Callback pair for the profile registration queue.
+ typedef std::pair<base::Closure, ErrorCompletionCallback>
+ RegisterProfileCompletionPair;
+
+ // Queue of delegates waiting for a profile to register.
+ std::map<device::BluetoothUUID, std::vector<RegisterProfileCompletionPair>*>
+ profile_queues_;
+
// Note: This should remain the last member so it'll be destroyed and
// invalidate its weak pointers before any other members are destroyed.
base::WeakPtrFactory<BluetoothAdapterChromeOS> weak_ptr_factory_;
« no previous file with comments | « chromeos/dbus/fake_bluetooth_profile_manager_client.cc ('k') | device/bluetooth/bluetooth_adapter_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698