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

Unified Diff: device/bluetooth/bluetooth_device_win.cc

Issue 2244693002: bluetooth: Refactor how we update based on Advertising Data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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_device_win.cc
diff --git a/device/bluetooth/bluetooth_device_win.cc b/device/bluetooth/bluetooth_device_win.cc
index 9436651ccbc9a86a86a5a290ae35dc6b5f206f07..d9c88792bba61738a9b7b34968be4d4bd8532a7d 100644
--- a/device/bluetooth/bluetooth_device_win.cc
+++ b/device/bluetooth/bluetooth_device_win.cc
@@ -112,7 +112,7 @@ bool BluetoothDeviceWin::IsConnecting() const {
return false;
}
-BluetoothDevice::UUIDList BluetoothDeviceWin::GetUUIDs() const {
+BluetoothDevice::UUIDSet BluetoothDeviceWin::GetUUIDs() const {
return uuids_;
}
@@ -233,17 +233,10 @@ bool BluetoothDeviceWin::IsEqual(
}
// Checks service collection
- typedef std::set<BluetoothUUID> UUIDSet;
typedef base::ScopedPtrHashMap<std::string,
std::unique_ptr<BluetoothServiceRecordWin>>
ServiceRecordMap;
- UUIDSet known_services;
- for (UUIDList::const_iterator iter = uuids_.begin(); iter != uuids_.end();
- ++iter) {
- known_services.insert((*iter));
- }
-
UUIDSet new_services;
ServiceRecordMap new_service_records;
for (ScopedVector<BluetoothTaskManagerWin::ServiceRecordState>::const_iterator
@@ -257,14 +250,8 @@ bool BluetoothDeviceWin::IsEqual(
std::unique_ptr<BluetoothServiceRecordWin>(service_record));
}
- UUIDSet removed_services =
- base::STLSetDifference<UUIDSet>(known_services, new_services);
- if (!removed_services.empty()) {
- return false;
- }
- UUIDSet added_devices =
- base::STLSetDifference<UUIDSet>(new_services, known_services);
- if (!added_devices.empty()) {
+ // Check that no new services have been added or removed.
+ if (uuids_ != new_services) {
return false;
}
@@ -320,7 +307,7 @@ void BluetoothDeviceWin::UpdateServices(
new BluetoothServiceRecordWin(device_state.address, (*iter)->name,
(*iter)->sdp_bytes, (*iter)->gatt_uuid);
service_record_list_.push_back(service_record);
- uuids_.push_back(service_record->uuid());
+ uuids_.insert(service_record->uuid());
}
if (!device_state.is_bluetooth_classic())

Powered by Google App Engine
This is Rietveld 408576698