| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_device_chooser_controller.h" | 5 #include "content/browser/bluetooth/bluetooth_device_chooser_controller.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <unordered_set> | 9 #include <unordered_set> |
| 10 | 10 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 if (!filter->name_prefix.is_null() && filter->name_prefix.size()) { | 100 if (!filter->name_prefix.is_null() && filter->name_prefix.size()) { |
| 101 if (!device.GetName()) | 101 if (!device.GetName()) |
| 102 return false; | 102 return false; |
| 103 if (!base::StartsWith(device.GetName().value(), filter->name_prefix.get(), | 103 if (!base::StartsWith(device.GetName().value(), filter->name_prefix.get(), |
| 104 base::CompareCase::SENSITIVE)) | 104 base::CompareCase::SENSITIVE)) |
| 105 return false; | 105 return false; |
| 106 } | 106 } |
| 107 | 107 |
| 108 if (!filter->services.is_null()) { | 108 if (!filter->services.is_null()) { |
| 109 const auto& device_uuid_list = device.GetUUIDs(); | 109 const device::BluetoothDevice::UUIDSet& device_uuids = device.GetUUIDs(); |
| 110 const std::unordered_set<BluetoothUUID, device::BluetoothUUIDHash> | |
| 111 device_uuids(device_uuid_list.begin(), device_uuid_list.end()); | |
| 112 for (const base::Optional<BluetoothUUID>& service : filter->services) { | 110 for (const base::Optional<BluetoothUUID>& service : filter->services) { |
| 113 if (!base::ContainsKey(device_uuids, service.value())) { | 111 if (!base::ContainsKey(device_uuids, service.value())) { |
| 114 return false; | 112 return false; |
| 115 } | 113 } |
| 116 } | 114 } |
| 117 } | 115 } |
| 118 | 116 |
| 119 return true; | 117 return true; |
| 120 } | 118 } |
| 121 | 119 |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 | 486 |
| 489 void BluetoothDeviceChooserController::PostErrorCallback( | 487 void BluetoothDeviceChooserController::PostErrorCallback( |
| 490 blink::mojom::WebBluetoothError error) { | 488 blink::mojom::WebBluetoothError error) { |
| 491 if (!base::ThreadTaskRunnerHandle::Get()->PostTask( | 489 if (!base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 492 FROM_HERE, base::Bind(error_callback_, error))) { | 490 FROM_HERE, base::Bind(error_callback_, error))) { |
| 493 LOG(WARNING) << "No TaskRunner."; | 491 LOG(WARNING) << "No TaskRunner."; |
| 494 } | 492 } |
| 495 } | 493 } |
| 496 | 494 |
| 497 } // namespace content | 495 } // namespace content |
| OLD | NEW |