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

Unified Diff: device/bluetooth/bluetooth_socket_chromeos.cc

Issue 935383003: Fix BluetoothAdapterProfileChromeOS lifecycle management (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: further fix ownership, address comments 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_socket_chromeos.cc
diff --git a/device/bluetooth/bluetooth_socket_chromeos.cc b/device/bluetooth/bluetooth_socket_chromeos.cc
index 3026113a5cb9a1de191b98e29b04759b29129b4e..a67e974fc0849d0e5702b9b3b7beb138303fd17a 100644
--- a/device/bluetooth/bluetooth_socket_chromeos.cc
+++ b/device/bluetooth/bluetooth_socket_chromeos.cc
@@ -110,6 +110,8 @@ void BluetoothSocketChromeOS::Connect(
if (security_level == SECURITY_LEVEL_LOW)
options_->require_authentication.reset(new bool(false));
+ adapter_ = device->adapter();
+
RegisterProfile(device->adapter(), success_callback, error_callback);
}
@@ -128,7 +130,8 @@ void BluetoothSocketChromeOS::Listen(
return;
}
- adapter->AddObserver(this);
+ adapter_ = adapter;
+ adapter_->AddObserver(this);
uuid_ = uuid;
options_.reset(new BluetoothProfileManagerClient::Options());
@@ -221,12 +224,10 @@ void BluetoothSocketChromeOS::RegisterProfile(
DCHECK(!profile_);
DCHECK(adapter);
Ilya Sherman 2015/02/21 01:22:10 Should you also DCHECK that adapter_ and adapter a
Marie Janssen 2015/02/23 17:49:10 we don't use adapter_ in this function anymore. t
Ilya Sherman 2015/02/24 05:26:06 I agree that |adapter_| isn't accessed, but should
Marie Janssen 2015/02/24 18:49:21 I mean from before this CL. Earlier patches moved
Ilya Sherman 2015/02/24 19:00:21 Per offline discussion, this CL is partially resto
- adapter_ = adapter;
-
// If the adapter is not present, this is a listening socket and the
// adapter isn't running yet. Report success and carry on;
// the profile will be registered when the daemon becomes available.
- if (!adapter_->IsPresent()) {
+ if (!adapter->IsPresent()) {
VLOG(1) << uuid_.canonical_value() << " on " << device_path_.value()
<< ": Delaying profile registration.";
base::MessageLoop::current()->PostTask(FROM_HERE, success_callback);
@@ -549,20 +550,9 @@ void BluetoothSocketChromeOS::UnregisterProfile() {
VLOG(1) << profile_->object_path().value() << ": Release profile";
- profile_->RemoveDelegate(
- device_path_,
- base::Bind(&BluetoothSocketChromeOS::ReleaseProfile, this, profile_));
-
+ static_cast<BluetoothAdapterChromeOS*>(adapter_.get())
+ ->ReleaseProfile(device_path_, profile_);
Ilya Sherman 2015/02/21 01:22:10 Is it guaranteed that the adapter_ is non-null? I
Marie Janssen 2015/02/23 17:49:09 Here it is: if we have a profile to unregister at
Ilya Sherman 2015/02/24 05:26:06 You're probably right, as I do not know this code
Marie Janssen 2015/02/24 18:49:21 ReleaseProfile() was called asynchronously from a
Ilya Sherman 2015/02/24 19:00:21 Ok, that makes sense -- thanks!
profile_ = nullptr;
}
-void BluetoothSocketChromeOS::ReleaseProfile(
- BluetoothAdapterProfileChromeOS* profile) {
- if (adapter_)
- static_cast<BluetoothAdapterChromeOS*>(adapter_.get())
- ->ReleaseProfile(uuid_);
- else
- delete profile;
-}
-
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698