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

Unified Diff: device/bluetooth/bluetooth_adapter_mac.mm

Issue 1229473005: BluetoothAdapterMac::LowEnergyDeviceUpdated() Implemented (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@hash
Patch Set: Created 5 years, 5 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 | « no previous file | device/bluetooth/bluetooth_adapter_mac_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluetooth_adapter_mac.mm
diff --git a/device/bluetooth/bluetooth_adapter_mac.mm b/device/bluetooth/bluetooth_adapter_mac.mm
index 0dfb7991ca4587d78faca8c4378900d86dbc08a7..3c60c6b8c868d1fd898c65dbee749cb37817fded 100644
--- a/device/bluetooth/bluetooth_adapter_mac.mm
+++ b/device/bluetooth/bluetooth_adapter_mac.mm
@@ -388,11 +388,35 @@ void BluetoothAdapterMac::ClassicDeviceAdded(IOBluetoothDevice* device) {
DeviceAdded(this, devices_[device_address]));
}
-// TODO(krstnmnlsn): Implement method. http://crbug.com/496987.
void BluetoothAdapterMac::LowEnergyDeviceUpdated(
CBPeripheral* peripheral,
NSDictionary* advertisementData,
int rssi) {
+ std::string device_address =
+ BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(peripheral);
+
+ if (devices_.count(device_address)) {
scheib 2015/07/08 05:20:36 Push back if you like, but here's my take on testi
krstnmnlsn 2015/07/13 17:26:23 Done.
+ if (devices_[device_address]->GetIdentifier() !=
+ BluetoothLowEnergyDeviceMac::GetPeripheralIdentifier(peripheral)) {
+ // Collision, two identifiers map to the same hash address. With a 48 bit
+ // hash the probability of this occuring with 10,000 devices
+ // simultaneously present is 1e-6, so we simply return.
scheib 2015/07/08 05:20:36 Cite the source for those numbers. Also explain ha
krstnmnlsn 2015/07/13 17:26:23 Done.
+ return;
+ }
+ // A device has an update.
+ BluetoothLowEnergyDeviceMac* old_device =
+ static_cast<BluetoothLowEnergyDeviceMac*>(devices_[device_address]);
+ old_device->Update(peripheral, advertisementData, rssi);
+ FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
scheib 2015/07/08 05:20:36 I think only call DeviceChanged if data about the
krstnmnlsn 2015/07/13 17:26:23 (after offline discussion) leaving this for now, a
scheib 2015/07/13 18:24:39 Acknowledged.
+ DeviceChanged(this, old_device));
+ return;
+ }
+
+ // A new device has been found.
+ devices_[device_address] =
+ new BluetoothLowEnergyDeviceMac(peripheral, advertisementData, rssi);
+ FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
+ DeviceAdded(this, devices_[device_address]));
}
void BluetoothAdapterMac::RemoveTimedOutDevices() {
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_adapter_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698