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

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

Issue 2847233003: [EasyUnlock] Move DataWithTimestamp out of ForegroundEidGenerator so it can be shared. (Closed)
Patch Set: fixes Created 3 years, 7 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/bluetooth_low_energy_connection_finder.h" 5 #include "components/proximity_auth/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
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
18 #include "components/cryptauth/background_eid_generator.h"
18 #include "components/cryptauth/ble/bluetooth_low_energy_weave_client_connection. h" 19 #include "components/cryptauth/ble/bluetooth_low_energy_weave_client_connection. h"
19 #include "components/cryptauth/bluetooth_throttler.h" 20 #include "components/cryptauth/bluetooth_throttler.h"
20 #include "components/cryptauth/connection.h" 21 #include "components/cryptauth/connection.h"
22 #include "components/cryptauth/raw_eid_generator.h"
21 #include "components/proximity_auth/logging/logging.h" 23 #include "components/proximity_auth/logging/logging.h"
22 #include "device/bluetooth/bluetooth_adapter_factory.h" 24 #include "device/bluetooth/bluetooth_adapter_factory.h"
23 #include "device/bluetooth/bluetooth_common.h" 25 #include "device/bluetooth/bluetooth_common.h"
24 #include "device/bluetooth/bluetooth_device.h" 26 #include "device/bluetooth/bluetooth_device.h"
25 #include "device/bluetooth/bluetooth_discovery_session.h" 27 #include "device/bluetooth/bluetooth_discovery_session.h"
26 #include "device/bluetooth/bluetooth_uuid.h" 28 #include "device/bluetooth/bluetooth_uuid.h"
27 29
28 using device::BluetoothAdapter; 30 using device::BluetoothAdapter;
29 using device::BluetoothDevice; 31 using device::BluetoothDevice;
30 using device::BluetoothGattConnection; 32 using device::BluetoothGattConnection;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 if (!device) 162 if (!device)
161 return false; 163 return false;
162 164
163 device::BluetoothUUID advertisement_uuid(kAdvertisementUUID); 165 device::BluetoothUUID advertisement_uuid(kAdvertisementUUID);
164 const std::vector<uint8_t>* service_data = 166 const std::vector<uint8_t>* service_data =
165 device->GetServiceDataForUUID(advertisement_uuid); 167 device->GetServiceDataForUUID(advertisement_uuid);
166 if (!service_data) 168 if (!service_data)
167 return false; 169 return false;
168 170
169 std::string service_data_string(service_data->begin(), service_data->end()); 171 std::string service_data_string(service_data->begin(), service_data->end());
170 std::vector<std::string> nearest_eids = 172 std::vector<cryptauth::DataWithTimestamp> nearest_eids =
171 eid_generator_->GenerateNearestEids(beacon_seeds_); 173 eid_generator_->GenerateNearestEids(beacon_seeds_);
172 for (const std::string& eid : nearest_eids) { 174 for (const cryptauth::DataWithTimestamp& eid : nearest_eids) {
173 if (eid == service_data_string) { 175 if (eid.data == service_data_string) {
174 PA_LOG(INFO) << "Found a matching EID: " << eid; 176 PA_LOG(INFO) << "Found a matching EID: " << eid.DataInHex();
175 return true; 177 return true;
176 } 178 }
177 } 179 }
178 return false; 180 return false;
179 } 181 }
180 182
181 void BluetoothLowEnergyConnectionFinder::OnAdapterInitialized( 183 void BluetoothLowEnergyConnectionFinder::OnAdapterInitialized(
182 scoped_refptr<BluetoothAdapter> adapter) { 184 scoped_refptr<BluetoothAdapter> adapter) {
183 PA_LOG(INFO) << "Adapter ready"; 185 PA_LOG(INFO) << "Adapter ready";
184 adapter_ = adapter; 186 adapter_ = adapter;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 connection_.reset(); 275 connection_.reset();
274 if (!discovery_session_ || !discovery_session_->IsActive()) 276 if (!discovery_session_ || !discovery_session_->IsActive())
275 StartDiscoverySession(); 277 StartDiscoverySession();
276 } 278 }
277 279
278 void BluetoothLowEnergyConnectionFinder::InvokeCallbackAsync() { 280 void BluetoothLowEnergyConnectionFinder::InvokeCallbackAsync() {
279 connection_callback_.Run(std::move(connection_)); 281 connection_callback_.Run(std::move(connection_));
280 } 282 }
281 283
282 } // namespace proximity_auth 284 } // namespace proximity_auth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698