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

Unified Diff: components/pairing/bluetooth_host_pairing_controller.cc

Issue 552983003: Wait for the Bluetooth adapter to be present before starting pairing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « components/pairing/bluetooth_host_pairing_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/pairing/bluetooth_host_pairing_controller.cc
diff --git a/components/pairing/bluetooth_host_pairing_controller.cc b/components/pairing/bluetooth_host_pairing_controller.cc
index a22dfc32952b0fddef88900f12d4b8e89daf52c2..b9e8b583e06b083b80f312782f01ee42d2349534 100644
--- a/components/pairing/bluetooth_host_pairing_controller.cc
+++ b/components/pairing/bluetooth_host_pairing_controller.cc
@@ -106,9 +106,19 @@ void BluetoothHostPairingController::OnGetAdapter(
DCHECK(!adapter_);
adapter_ = adapter;
+ if (adapter_->IsPresent()) {
+ SetName();
+ } else {
+ // Set the name once the adapter is present.
+ adapter_->AddObserver(this);
+ }
+}
+
+void BluetoothHostPairingController::SetName() {
// TODO(zork): Make the device name prettier. (http://crbug.com/405774)
device_name_ = base::StringPrintf("%s%s", kDeviceNamePrefix,
adapter_->GetAddress().c_str());
+
adapter_->SetName(
device_name_,
base::Bind(&BluetoothHostPairingController::OnSetName,
@@ -298,6 +308,16 @@ void BluetoothHostPairingController::OnErrorMessage(
NOTREACHED();
}
+void BluetoothHostPairingController::AdapterPresentChanged(
+ device::BluetoothAdapter* adapter,
+ bool present) {
+ DCHECK_EQ(adapter, adapter_.get());
+ if (present) {
+ adapter_->RemoveObserver(this);
+ SetName();
+ }
+}
+
void BluetoothHostPairingController::AddObserver(Observer* observer) {
observers_.AddObserver(observer);
}
« no previous file with comments | « components/pairing/bluetooth_host_pairing_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698