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

Unified Diff: device/bluetooth/bluetooth_adapter_profile_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_profile_chromeos.h
diff --git a/device/bluetooth/bluetooth_adapter_profile_chromeos.h b/device/bluetooth/bluetooth_adapter_profile_chromeos.h
index 5f1edc2ead5e57aa892079cac232e8b71460515c..5422d9e6904e376e54c1f9d54e1a052334e50544 100644
--- a/device/bluetooth/bluetooth_adapter_profile_chromeos.h
+++ b/device/bluetooth/bluetooth_adapter_profile_chromeos.h
@@ -21,17 +21,23 @@ namespace chromeos {
// profile for custom Bluetooth services managed by a BluetoothAdapter.
// Maintains a list of delegates which may serve the profile.
// One delegate is allowed for each device.
+//
+// BluetoothAdapterProfileChromeOS objects are owned by the
+// BluetoothAdapterChromeOS and allocated through Register()
class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterProfileChromeOS
: public chromeos::BluetoothProfileServiceProvider::Delegate {
public:
+ typedef base::Callback<void(BluetoothAdapterProfileChromeOS* profile)>
+ ProfileRegisteredCallback;
+
// Registers a profile with the BlueZ server for |uuid| with the
- // options |options|. Returns a newly allocated pointer, or nullptr
- // if there was a problem.
- static BluetoothAdapterProfileChromeOS* Register(
- BluetoothAdapterChromeOS* adapter,
+ // options |options|. |success_callback| is provided with a newly
+ // allocated profile if registration is successful, otherwise |error_callback|
+ // will be called.
+ static void Register(
const device::BluetoothUUID& uuid,
const BluetoothProfileManagerClient::Options& options,
- const base::Closure& success_callback,
+ const ProfileRegisteredCallback& success_callback,
const BluetoothProfileManagerClient::ErrorCallback& error_callback);
~BluetoothAdapterProfileChromeOS() override;
@@ -39,6 +45,9 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterProfileChromeOS
// The object path of the profile.
const dbus::ObjectPath& object_path() const { return object_path_; }
+ // Returns the UUID of the profile
+ const device::BluetoothUUID& uuid() const { return uuid_; }
+
// Add a delegate for a device associated with this profile.
// An empty |device_path| indicates a local listening service.
// Returns true if the delegate was set, and false if the |device_path|
@@ -55,8 +64,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterProfileChromeOS
size_t DelegateCount() const { return delegates_.size(); }
private:
- BluetoothAdapterProfileChromeOS(BluetoothAdapterChromeOS* adapter,
- const device::BluetoothUUID& uuid);
+ BluetoothAdapterProfileChromeOS(const device::BluetoothUUID& uuid);
// BluetoothProfileServiceProvider::Delegate:
void Released() override;
@@ -86,9 +94,6 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterProfileChromeOS
// Profile dbus object for receiving profile method calls from BlueZ
scoped_ptr<BluetoothProfileServiceProvider> profile_;
- // Adapter that owns this profile.
- BluetoothAdapterChromeOS* adapter_;
-
// 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<BluetoothAdapterProfileChromeOS> weak_ptr_factory_;
« no previous file with comments | « device/bluetooth/bluetooth_adapter_chromeos.cc ('k') | device/bluetooth/bluetooth_adapter_profile_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698