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

Unified Diff: content/browser/bluetooth/bluetooth_allowed_devices_map.cc

Issue 1527853002: bluetooth: Add disconnect function (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-device-identifier
Patch Set: Fix test that fails after upstream change. Created 4 years, 11 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: 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 9075fe82bb38d61cc150e5915a6b1fd943ee3467..36fce42211f7ca4144c06d9983eb86d6fd042761 100644
--- a/content/browser/bluetooth/bluetooth_allowed_devices_map.cc
+++ b/content/browser/bluetooth/bluetooth_allowed_devices_map.cc
@@ -60,7 +60,7 @@ const std::string& BluetoothAllowedDevicesMap::AddDevice(
VLOG(1) << "Device already in map of allowed devices.";
return origin_to_device_address_to_id_map_[origin][device_address];
}
- const std::string device_id = GenerateDeviceId(origin);
+ const std::string device_id = GenerateDeviceId();
VLOG(1) << "Id generated for device: " << device_id;
origin_to_device_address_to_id_map_[origin][device_address] = device_id;
@@ -68,6 +68,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];
}
@@ -88,6 +90,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(
@@ -123,14 +128,9 @@ const std::string& BluetoothAllowedDevicesMap::GetDeviceAddress(
: id_iter->second;
}
-std::string BluetoothAllowedDevicesMap::GenerateDeviceId(
- const url::Origin& origin) {
+std::string BluetoothAllowedDevicesMap::GenerateDeviceId() {
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();
}
« no previous file with comments | « content/browser/bluetooth/bluetooth_allowed_devices_map.h ('k') | content/browser/bluetooth/bluetooth_dispatcher_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698