Index: content/browser/bluetooth/bluetooth_allowed_devices_map.cc |
diff --git a/content/browser/bluetooth/bluetooth_allowed_devices_map.cc b/content/browser/bluetooth/bluetooth_allowed_devices_map.cc |
index e14147c7ad8e5d176b5020cb2545e53732eec59f..171063c50afce01d2fa6c654e43fff24c8109b76 100644 |
--- a/content/browser/bluetooth/bluetooth_allowed_devices_map.cc |
+++ b/content/browser/bluetooth/bluetooth_allowed_devices_map.cc |
@@ -67,6 +67,8 @@ const std::string& BluetoothAllowedDevicesMap::AddDevice( |
origin_to_device_id_to_services_map_[origin][device_id] = |
UnionOfServices(filters, optional_services); |
+ CHECK(device_id_set_.insert(device_id).second); |
+ |
return origin_to_device_address_to_id_map_[origin][device_address]; |
} |
@@ -87,6 +89,9 @@ void BluetoothAllowedDevicesMap::RemoveDevice( |
CHECK(origin_to_device_id_to_address_map_.erase(origin)); |
CHECK(origin_to_device_id_to_services_map_.erase(origin)); |
} |
+ |
+ // 3. Remove from set of ids. |
+ CHECK(device_id_set_.erase(device_id)); |
} |
const std::string& BluetoothAllowedDevicesMap::GetDeviceId( |
@@ -125,11 +130,7 @@ const std::string& BluetoothAllowedDevicesMap::GetDeviceAddress( |
std::string BluetoothAllowedDevicesMap::GenerateDeviceId( |
const url::Origin& origin) { |
Jeffrey Yasskin
2016/01/15 01:12:19
Now that you're not using it, remove |origin| from
ortuno
2016/01/15 01:33:14
Done.
|
std::string device_id = GetBase64Id(); |
- auto id_map_iter = origin_to_device_id_to_address_map_.find(origin); |
- if (id_map_iter == origin_to_device_id_to_address_map_.end()) { |
- return device_id; |
- } |
- while (ContainsKey(id_map_iter->second, device_id)) { |
+ while (ContainsKey(device_id_set_, device_id)) { |
LOG(WARNING) << "Generated repeated id."; |
device_id = GetBase64Id(); |
} |