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

Unified Diff: device/bluetooth/bluetooth_adapter_mac.mm

Issue 2282763004: bluetooth: mac: Improve classic device discovery and update (Closed)
Patch Set: Store a TimeDelta instead of int Created 4 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
Index: device/bluetooth/bluetooth_adapter_mac.mm
diff --git a/device/bluetooth/bluetooth_adapter_mac.mm b/device/bluetooth/bluetooth_adapter_mac.mm
index 1690da6559fe9582cecaba733cc476a6c4d7d763..aff621ccba13985ddd31ffa25b12cec2f2320b57 100644
--- a/device/bluetooth/bluetooth_adapter_mac.mm
+++ b/device/bluetooth/bluetooth_adapter_mac.mm
@@ -469,12 +469,19 @@ void BluetoothAdapterMac::ClassicDeviceAdded(IOBluetoothDevice* device) {
std::string device_address =
BluetoothClassicDeviceMac::GetDeviceAddress(device);
+ BluetoothDevice* device_classic = GetDevice(device_address);
+
// Only notify observers once per device.
- if (devices_.count(device_address))
+ if (device_classic != nullptr) {
+ VLOG(3) << "Updating classic device: " << device_classic->GetAddress();
+ device_classic->UpdateTimestamp();
return;
+ }
- BluetoothDevice* device_classic = new BluetoothClassicDeviceMac(this, device);
+ device_classic = new BluetoothClassicDeviceMac(this, device);
devices_.set(device_address, base::WrapUnique(device_classic));
+ VLOG(1) << "Adding new classic device: " << device_classic->GetAddress();
+
FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
DeviceAdded(this, device_classic));
}
@@ -567,7 +574,9 @@ void BluetoothAdapterMac::LowEnergyCentralManagerUpdatedState() {}
void BluetoothAdapterMac::AddPairedDevices() {
// Add any new paired devices.
for (IOBluetoothDevice* device in [IOBluetoothDevice pairedDevices]) {
- ClassicDeviceAdded(device);
+ if ([device isPaired]) {
Jeffrey Yasskin 2016/09/14 20:35:57 Could you comment why this is needed, with any rad
ortuno 2016/09/20 04:31:32 Done. For some reason pairedDevices returns an un
+ ClassicDeviceAdded(device);
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698