Chromium Code Reviews| Index: device/bluetooth/bluetooth_adapter_mac.mm |
| diff --git a/device/bluetooth/bluetooth_adapter_mac.mm b/device/bluetooth/bluetooth_adapter_mac.mm |
| index cf33939b61c4902c156f616a9e554e1fbabc6469..cc65ddf8fbe124f4cf932947948b454cfca5acd2 100644 |
| --- a/device/bluetooth/bluetooth_adapter_mac.mm |
| +++ b/device/bluetooth/bluetooth_adapter_mac.mm |
| @@ -402,11 +402,39 @@ 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); |
| + BluetoothDevice*& device_reference = devices_[device_address]; |
|
armansito
2015/07/15 18:14:42
Please add a comment here explaining why you're us
krstnmnlsn
2015/07/15 20:38:14
Done.
|
| + |
|
armansito
2015/07/15 18:14:42
Remove extra space here.
krstnmnlsn
2015/07/15 20:38:14
Done.
|
| + if (!device_reference) { |
| + // A new device has been found. |
| + device_reference = |
| + new BluetoothLowEnergyDeviceMac(peripheral, advertisementData, rssi); |
| + FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, |
| + DeviceAdded(this, device_reference)); |
| + return; |
| + } |
| + |
| + if (static_cast<BluetoothLowEnergyDeviceMac*>(device_reference) |
| + ->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 (see |
| + // https://en.wikipedia.org/wiki/Birthday_problem#Probability_table). We |
| + // ignore the second device by returning. |
| + return; |
| + } |
| + |
| + // A device has an update. |
| + static_cast<BluetoothLowEnergyDeviceMac*>(device_reference) |
| + ->Update(peripheral, advertisementData, rssi); |
| + FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, |
| + DeviceChanged(this, device_reference)); |
| } |
| void BluetoothAdapterMac::RemoveTimedOutDevices() { |