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

Side by Side Diff: components/proximity_auth/ble/bluetooth_low_energy_connection_finder.cc

Issue 2244693002: bluetooth: Refactor how we update based on Advertising Data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Typo 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 "components/proximity_auth/ble/bluetooth_low_energy_connection_finder.h " 5 #include "components/proximity_auth/ble/bluetooth_low_energy_connection_finder.h "
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // The device should be paired when looking for BLE devices by bluetooth 165 // The device should be paired when looking for BLE devices by bluetooth
166 // address. 166 // address.
167 if (finder_strategy_ == FIND_PAIRED_DEVICE) 167 if (finder_strategy_ == FIND_PAIRED_DEVICE)
168 return device->IsPaired() && 168 return device->IsPaired() &&
169 device->GetAddress() == remote_device_.bluetooth_address; 169 device->GetAddress() == remote_device_.bluetooth_address;
170 return HasService(device); 170 return HasService(device);
171 } 171 }
172 172
173 bool BluetoothLowEnergyConnectionFinder::HasService( 173 bool BluetoothLowEnergyConnectionFinder::HasService(
174 BluetoothDevice* remote_device) { 174 BluetoothDevice* remote_device) {
175 if (remote_device) { 175 if (!remote_device) {
176 PA_LOG(INFO) << "Device " << remote_device->GetAddress() << " has " 176 return false;
177 << remote_device->GetUUIDs().size() << " services.";
178 std::vector<device::BluetoothUUID> uuids = remote_device->GetUUIDs();
179 for (const auto& service_uuid : uuids) {
180 if (remote_service_uuid_ == service_uuid) {
181 return true;
182 }
183 }
184 } 177 }
185 return false; 178
179 BluetoothDevice::UUIDSet uuids = remote_device->GetUUIDs();
180
181 PA_LOG(INFO) << "Device " << remote_device->GetAddress() << " has "
182 << uuids.size() << " services.";
183 return base::ContainsKey(uuids, remote_service_uuid_);
186 } 184 }
187 185
188 void BluetoothLowEnergyConnectionFinder::OnAdapterInitialized( 186 void BluetoothLowEnergyConnectionFinder::OnAdapterInitialized(
189 scoped_refptr<BluetoothAdapter> adapter) { 187 scoped_refptr<BluetoothAdapter> adapter) {
190 PA_LOG(INFO) << "Adapter ready"; 188 PA_LOG(INFO) << "Adapter ready";
191 189
192 adapter_ = adapter; 190 adapter_ = adapter;
193 adapter_->AddObserver(this); 191 adapter_->AddObserver(this);
194 192
195 // This is important for debugging. To eliminate the case where the device was 193 // This is important for debugging. To eliminate the case where the device was
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 return device; 309 return device;
312 } 310 }
313 return nullptr; 311 return nullptr;
314 } 312 }
315 313
316 void BluetoothLowEnergyConnectionFinder::InvokeCallbackAsync() { 314 void BluetoothLowEnergyConnectionFinder::InvokeCallbackAsync() {
317 connection_callback_.Run(std::move(connection_)); 315 connection_callback_.Run(std::move(connection_));
318 } 316 }
319 317
320 } // namespace proximity_auth 318 } // namespace proximity_auth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698