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

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

Issue 2849493002: [EasyUnlock] Fixing the setup connection finder and message format. (Closed)
Patch Set: Using the right UUID 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
(...skipping 25 matching lines...) Expand all
36 const char kBLEGattServiceUUID[] = "b3b7e28e-a000-3e17-bd86-6e97b9e28c11"; 36 const char kBLEGattServiceUUID[] = "b3b7e28e-a000-3e17-bd86-6e97b9e28c11";
37 const int kRestartDiscoveryOnErrorDelaySeconds = 2; 37 const int kRestartDiscoveryOnErrorDelaySeconds = 2;
38 } // namespace 38 } // namespace
39 39
40 BluetoothLowEnergyConnectionFinder::BluetoothLowEnergyConnectionFinder( 40 BluetoothLowEnergyConnectionFinder::BluetoothLowEnergyConnectionFinder(
41 const cryptauth::RemoteDevice remote_device, 41 const cryptauth::RemoteDevice remote_device,
42 const std::vector<cryptauth::BeaconSeed>& beacon_seeds, 42 const std::vector<cryptauth::BeaconSeed>& beacon_seeds,
43 cryptauth::BluetoothThrottler* bluetooth_throttler) 43 cryptauth::BluetoothThrottler* bluetooth_throttler)
44 : BluetoothLowEnergyConnectionFinder( 44 : BluetoothLowEnergyConnectionFinder(
45 remote_device, 45 remote_device,
46 kBLEGattServiceUUID,
46 beacon_seeds, 47 beacon_seeds,
47 base::MakeUnique<cryptauth::BackgroundEidGenerator>(), 48 base::MakeUnique<cryptauth::BackgroundEidGenerator>(),
48 bluetooth_throttler) {} 49 bluetooth_throttler) {}
49 50
50 BluetoothLowEnergyConnectionFinder::BluetoothLowEnergyConnectionFinder( 51 BluetoothLowEnergyConnectionFinder::BluetoothLowEnergyConnectionFinder(
51 const cryptauth::RemoteDevice remote_device, 52 const cryptauth::RemoteDevice remote_device,
53 const std::string& service_uuid,
52 const std::vector<cryptauth::BeaconSeed>& beacon_seeds, 54 const std::vector<cryptauth::BeaconSeed>& beacon_seeds,
53 std::unique_ptr<cryptauth::BackgroundEidGenerator> eid_generator, 55 std::unique_ptr<cryptauth::BackgroundEidGenerator> eid_generator,
54 cryptauth::BluetoothThrottler* bluetooth_throttler) 56 cryptauth::BluetoothThrottler* bluetooth_throttler)
55 : remote_device_(remote_device), 57 : remote_device_(remote_device),
58 service_uuid_(service_uuid),
56 beacon_seeds_(beacon_seeds), 59 beacon_seeds_(beacon_seeds),
57 eid_generator_(std::move(eid_generator)), 60 eid_generator_(std::move(eid_generator)),
58 bluetooth_throttler_(bluetooth_throttler), 61 bluetooth_throttler_(bluetooth_throttler),
59 weak_ptr_factory_(this) {} 62 weak_ptr_factory_(this) {}
60 63
61 BluetoothLowEnergyConnectionFinder::~BluetoothLowEnergyConnectionFinder() { 64 BluetoothLowEnergyConnectionFinder::~BluetoothLowEnergyConnectionFinder() {
62 if (discovery_session_) { 65 if (discovery_session_) {
63 StopDiscoverySession(); 66 StopDiscoverySession();
64 } 67 }
65 68
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 PA_LOG(INFO) << "Stopping discovery session"; 227 PA_LOG(INFO) << "Stopping discovery session";
225 // Destroying the discovery session also stops it. 228 // Destroying the discovery session also stops it.
226 discovery_session_.reset(); 229 discovery_session_.reset();
227 } 230 }
228 231
229 std::unique_ptr<cryptauth::Connection> 232 std::unique_ptr<cryptauth::Connection>
230 BluetoothLowEnergyConnectionFinder::CreateConnection( 233 BluetoothLowEnergyConnectionFinder::CreateConnection(
231 const std::string& device_address) { 234 const std::string& device_address) {
232 return cryptauth::weave::BluetoothLowEnergyWeaveClientConnection::Factory:: 235 return cryptauth::weave::BluetoothLowEnergyWeaveClientConnection::Factory::
233 NewInstance(remote_device_, device_address, adapter_, 236 NewInstance(remote_device_, device_address, adapter_,
234 device::BluetoothUUID(kBLEGattServiceUUID), 237 device::BluetoothUUID(service_uuid_), bluetooth_throttler_);
235 bluetooth_throttler_);
236 } 238 }
237 239
238 void BluetoothLowEnergyConnectionFinder::OnConnectionStatusChanged( 240 void BluetoothLowEnergyConnectionFinder::OnConnectionStatusChanged(
239 cryptauth::Connection* connection, 241 cryptauth::Connection* connection,
240 cryptauth::Connection::Status old_status, 242 cryptauth::Connection::Status old_status,
241 cryptauth::Connection::Status new_status) { 243 cryptauth::Connection::Status new_status) {
242 DCHECK_EQ(connection, connection_.get()); 244 DCHECK_EQ(connection, connection_.get());
243 PA_LOG(INFO) << "OnConnectionStatusChanged: " << old_status << " -> " 245 PA_LOG(INFO) << "OnConnectionStatusChanged: " << old_status << " -> "
244 << new_status; 246 << new_status;
245 247
(...skipping 25 matching lines...) Expand all
271 connection_.reset(); 273 connection_.reset();
272 if (!discovery_session_ || !discovery_session_->IsActive()) 274 if (!discovery_session_ || !discovery_session_->IsActive())
273 StartDiscoverySession(); 275 StartDiscoverySession();
274 } 276 }
275 277
276 void BluetoothLowEnergyConnectionFinder::InvokeCallbackAsync() { 278 void BluetoothLowEnergyConnectionFinder::InvokeCallbackAsync() {
277 connection_callback_.Run(std::move(connection_)); 279 connection_callback_.Run(std::move(connection_));
278 } 280 }
279 281
280 } // namespace proximity_auth 282 } // namespace proximity_auth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698