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

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

Issue 1663883003: bluetooth: When adding a device a second time merge the list of services. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: 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
« no previous file with comments | « no previous file | content/browser/bluetooth/bluetooth_allowed_devices_map_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c959c8715ac0de11529a2987b2c9f41189a998b3..375458d870b9087874dcfe06ac1dad8538336e23 100644
--- a/content/browser/bluetooth/bluetooth_allowed_devices_map.cc
+++ b/content/browser/bluetooth/bluetooth_allowed_devices_map.cc
@@ -55,9 +55,18 @@ const std::string& BluetoothAllowedDevicesMap::AddDevice(
// https://w3c.github.io/webappsec-secure-contexts/
CHECK(!origin.unique());
- if (ContainsKey(origin_to_device_address_to_id_map_[origin],
- device_address)) {
+ auto device_address_to_id_map = origin_to_device_address_to_id_map_[origin];
+ auto id_iter = device_address_to_id_map.find(device_address);
+ if (id_iter != device_address_to_id_map.end()) {
VLOG(1) << "Device already in map of allowed devices.";
+ const auto& device_id = id_iter->second;
+
+ // Update set of services.
+ auto new_services = UnionOfServices(filters, optional_services);
Jeffrey Yasskin 2016/02/03 23:18:18 We could optimize this by having UnionOfServices a
ortuno 2016/02/04 02:21:09 Done. Also replaced the UnionOfServices function s
Jeffrey Yasskin 2016/02/04 04:03:40 Yep, that's what I meant. Thanks!
+ auto& old_services =
+ origin_to_device_id_to_services_map_[origin][device_id];
+ old_services.insert(new_services.begin(), new_services.end());
+
return origin_to_device_address_to_id_map_[origin][device_address];
}
const std::string device_id = GenerateDeviceId();
« no previous file with comments | « no previous file | content/browser/bluetooth/bluetooth_allowed_devices_map_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698