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

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

Issue 2506813003: Use new wrapper types for web_bluetooth.mojom (Closed)
Patch Set: address comments Created 4 years, 1 month 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 7fd80f93a3d7b10662e499dca4addbd1c23ed0b6..bbd1cbb5f9e741dd3834fdf5498af23647b21065 100644
--- a/content/browser/bluetooth/bluetooth_allowed_devices_map.cc
+++ b/content/browser/bluetooth/bluetooth_allowed_devices_map.cc
@@ -18,6 +18,15 @@ using device::BluetoothUUID;
namespace content {
+namespace {
+
+std::ostream& operator<<(std::ostream& out,
+ const WebBluetoothDeviceId& device_id) {
+ return out << device_id.str();
+}
+
+} // namespace
+
BluetoothAllowedDevicesMap::BluetoothAllowedDevicesMap() {}
BluetoothAllowedDevicesMap::~BluetoothAllowedDevicesMap() {}
@@ -86,16 +95,15 @@ const WebBluetoothDeviceId* BluetoothAllowedDevicesMap::GetDeviceId(
const url::Origin& origin,
const std::string& device_address) {
auto address_map_iter = origin_to_device_address_to_id_map_.find(origin);
- if (address_map_iter == origin_to_device_address_to_id_map_.end()) {
+ if (address_map_iter == origin_to_device_address_to_id_map_.end())
return nullptr;
- }
const auto& device_address_to_id_map = address_map_iter->second;
auto id_iter = device_address_to_id_map.find(device_address);
- if (id_iter == device_address_to_id_map.end()) {
+ if (id_iter == device_address_to_id_map.end())
return nullptr;
- }
+
return &(id_iter->second);
}
@@ -103,9 +111,8 @@ const std::string& BluetoothAllowedDevicesMap::GetDeviceAddress(
const url::Origin& origin,
const WebBluetoothDeviceId& device_id) {
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()) {
+ if (id_map_iter == origin_to_device_id_to_address_map_.end())
return base::EmptyString();
- }
const auto& device_id_to_address_map = id_map_iter->second;
@@ -119,9 +126,8 @@ bool BluetoothAllowedDevicesMap::IsOriginAllowedToAccessAtLeastOneService(
const url::Origin& origin,
const WebBluetoothDeviceId& device_id) const {
auto id_map_iter = origin_to_device_id_to_services_map_.find(origin);
- if (id_map_iter == origin_to_device_id_to_services_map_.end()) {
+ if (id_map_iter == origin_to_device_id_to_services_map_.end())
return false;
- }
const auto& device_id_to_services_map = id_map_iter->second;
@@ -135,14 +141,12 @@ bool BluetoothAllowedDevicesMap::IsOriginAllowedToAccessService(
const url::Origin& origin,
const WebBluetoothDeviceId& device_id,
const BluetoothUUID& service_uuid) const {
- if (BluetoothBlacklist::Get().IsExcluded(service_uuid)) {
+ if (BluetoothBlacklist::Get().IsExcluded(service_uuid))
return false;
- }
auto id_map_iter = origin_to_device_id_to_services_map_.find(origin);
- if (id_map_iter == origin_to_device_id_to_services_map_.end()) {
+ if (id_map_iter == origin_to_device_id_to_services_map_.end())
return false;
- }
const auto& device_id_to_services_map = id_map_iter->second;
@@ -167,13 +171,14 @@ void BluetoothAllowedDevicesMap::AddUnionOfServicesTo(
std::unordered_set<BluetoothUUID, device::BluetoothUUIDHash>*
unionOfServices) {
for (const auto& filter : options->filters) {
- for (const base::Optional<BluetoothUUID>& uuid : filter->services) {
- unionOfServices->insert(uuid.value());
- }
- }
- for (const base::Optional<BluetoothUUID>& uuid : options->optional_services) {
- unionOfServices->insert(uuid.value());
+ if (!filter->services)
+ continue;
+
+ for (const BluetoothUUID& uuid : filter->services.value())
+ unionOfServices->insert(uuid);
}
+ for (const BluetoothUUID& uuid : options->optional_services)
+ unionOfServices->insert(uuid);
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698