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

Unified Diff: device/bluetooth/bluetooth_low_energy_device_mac.mm

Issue 2205693003: bluetooth: Replace old advertised uuids (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Mac test and docs Created 4 years, 4 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_low_energy_device_mac.mm
diff --git a/device/bluetooth/bluetooth_low_energy_device_mac.mm b/device/bluetooth/bluetooth_low_energy_device_mac.mm
index e335e5fb916f389b6e88d7b9bd285fcc3e72f114..0db9ce10233571d642f9c29ee3050faecdf8b970 100644
--- a/device/bluetooth/bluetooth_low_energy_device_mac.mm
+++ b/device/bluetooth/bluetooth_low_energy_device_mac.mm
@@ -61,18 +61,20 @@ void BluetoothLowEnergyDeviceMac::Update(NSDictionary* advertisement_data,
SetServiceData(service_uuid, static_cast<const char*>([data bytes]),
[data length]);
}
+
+ std::unordered_set<BluetoothUUID, BluetoothUUIDHash> uuid_set;
NSArray* service_uuids =
[advertisement_data objectForKey:CBAdvertisementDataServiceUUIDsKey];
for (CBUUID* uuid in service_uuids) {
- advertised_uuids_.insert(
- BluetoothUUID(std::string([[uuid UUIDString] UTF8String])));
+ uuid_set.emplace([[uuid UUIDString] UTF8String]);
}
NSArray* overflow_service_uuids = [advertisement_data
objectForKey:CBAdvertisementDataOverflowServiceUUIDsKey];
for (CBUUID* uuid in overflow_service_uuids) {
- advertised_uuids_.insert(
- BluetoothUUID(std::string([[uuid UUIDString] UTF8String])));
+ uuid_set.emplace([[uuid UUIDString] UTF8String]);
}
+
+ advertised_uuids_ = UUIDList(uuid_set.begin(), uuid_set.end());
}
std::string BluetoothLowEnergyDeviceMac::GetIdentifier() const {
@@ -141,11 +143,6 @@ bool BluetoothLowEnergyDeviceMac::IsConnecting() const {
return ([peripheral_ state] == CBPeripheralStateConnecting);
}
-BluetoothDevice::UUIDList BluetoothLowEnergyDeviceMac::GetUUIDs() const {
- return BluetoothDevice::UUIDList(advertised_uuids_.begin(),
- advertised_uuids_.end());
-}
-
int16_t BluetoothLowEnergyDeviceMac::GetInquiryRSSI() const {
return kUnknownPower;
}
@@ -303,6 +300,7 @@ void BluetoothLowEnergyDeviceMac::DidDiscoverCharacteristics(
->IsDiscoveryComplete();
}) == gatt_services_.end();
if (discovery_complete) {
+ UpdateServiceUUIDs();
SetGattServicesDiscoveryComplete(true);
adapter_->NotifyGattServicesDiscovered(this);
}
@@ -318,6 +316,7 @@ void BluetoothLowEnergyDeviceMac::DidModifyServices(
gatt_services_.take_and_erase(gatt_service->GetIdentifier());
adapter_->NotifyGattServiceRemoved(scoped_service.get());
}
+ service_uuids_.clear();
SetGattServicesDiscoveryComplete(false);
[GetPeripheral() discoverServices:nil];
}

Powered by Google App Engine
This is Rietveld 408576698