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

Side by Side Diff: content/browser/bluetooth/bluetooth_allowed_devices_map.cc

Issue 2228403003: content: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/bluetooth/bluetooth_allowed_devices_map.h" 5 #include "content/browser/bluetooth/bluetooth_allowed_devices_map.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 if (id_map_iter == origin_to_device_id_to_services_map_.end()) { 127 if (id_map_iter == origin_to_device_id_to_services_map_.end()) {
128 return false; 128 return false;
129 } 129 }
130 130
131 const auto& device_id_to_services_map = id_map_iter->second; 131 const auto& device_id_to_services_map = id_map_iter->second;
132 132
133 auto id_iter = device_id_to_services_map.find(device_id); 133 auto id_iter = device_id_to_services_map.find(device_id);
134 134
135 return id_iter == device_id_to_services_map.end() 135 return id_iter == device_id_to_services_map.end()
136 ? false 136 ? false
137 : ContainsKey(id_iter->second, service_uuid); 137 : base::ContainsKey(id_iter->second, service_uuid);
138 } 138 }
139 139
140 WebBluetoothDeviceId BluetoothAllowedDevicesMap::GenerateUniqueDeviceId() { 140 WebBluetoothDeviceId BluetoothAllowedDevicesMap::GenerateUniqueDeviceId() {
141 WebBluetoothDeviceId device_id = WebBluetoothDeviceId::Create(); 141 WebBluetoothDeviceId device_id = WebBluetoothDeviceId::Create();
142 while (ContainsKey(device_id_set_, device_id)) { 142 while (base::ContainsKey(device_id_set_, device_id)) {
143 LOG(WARNING) << "Generated repeated id."; 143 LOG(WARNING) << "Generated repeated id.";
144 device_id = WebBluetoothDeviceId::Create(); 144 device_id = WebBluetoothDeviceId::Create();
145 } 145 }
146 return device_id; 146 return device_id;
147 } 147 }
148 148
149 void BluetoothAllowedDevicesMap::AddUnionOfServicesTo( 149 void BluetoothAllowedDevicesMap::AddUnionOfServicesTo(
150 const blink::mojom::WebBluetoothRequestDeviceOptionsPtr& options, 150 const blink::mojom::WebBluetoothRequestDeviceOptionsPtr& options,
151 std::unordered_set<BluetoothUUID, device::BluetoothUUIDHash>* 151 std::unordered_set<BluetoothUUID, device::BluetoothUUIDHash>*
152 unionOfServices) { 152 unionOfServices) {
153 for (const auto& filter : options->filters) { 153 for (const auto& filter : options->filters) {
154 for (const base::Optional<BluetoothUUID>& uuid : filter->services) { 154 for (const base::Optional<BluetoothUUID>& uuid : filter->services) {
155 unionOfServices->insert(uuid.value()); 155 unionOfServices->insert(uuid.value());
156 } 156 }
157 } 157 }
158 for (const base::Optional<BluetoothUUID>& uuid : options->optional_services) { 158 for (const base::Optional<BluetoothUUID>& uuid : options->optional_services) {
159 unionOfServices->insert(uuid.value()); 159 unionOfServices->insert(uuid.value());
160 } 160 }
161 } 161 }
162 162
163 } // namespace content 163 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698