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

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

Issue 2561203002: Migrate weave-related classes from proximity_auth/ble to cryptauth/ble. (Closed)
Patch Set: Created 4 years 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.h" 5 #include "components/proximity_auth/ble/bluetooth_low_energy_connection.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/task_runner.h" 13 #include "base/task_runner.h"
14 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/thread_task_runner_handle.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "components/proximity_auth/ble/bluetooth_low_energy_characteristics_fin der.h" 16 #include "components/cryptauth/ble/bluetooth_low_energy_characteristics_finder.h "
17 #include "components/proximity_auth/ble/fake_wire_message.h" 17 #include "components/cryptauth/ble/fake_wire_message.h"
18 #include "components/proximity_auth/bluetooth_throttler.h" 18 #include "components/proximity_auth/bluetooth_throttler.h"
19 #include "components/proximity_auth/connection_finder.h" 19 #include "components/proximity_auth/connection_finder.h"
20 #include "components/proximity_auth/logging/logging.h" 20 #include "components/proximity_auth/logging/logging.h"
21 #include "components/proximity_auth/wire_message.h" 21 #include "components/proximity_auth/wire_message.h"
22 #include "device/bluetooth/bluetooth_adapter.h" 22 #include "device/bluetooth/bluetooth_adapter.h"
23 #include "device/bluetooth/bluetooth_device.h" 23 #include "device/bluetooth/bluetooth_device.h"
24 #include "device/bluetooth/bluetooth_gatt_connection.h" 24 #include "device/bluetooth/bluetooth_gatt_connection.h"
25 #include "device/bluetooth/bluetooth_gatt_notify_session.h" 25 #include "device/bluetooth/bluetooth_gatt_notify_session.h"
26 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" 26 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h"
27 #include "device/bluetooth/bluetooth_uuid.h" 27 #include "device/bluetooth/bluetooth_uuid.h"
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 350
351 gatt_connection_ = std::move(gatt_connection); 351 gatt_connection_ = std::move(gatt_connection);
352 SetSubStatus(SubStatus::WAITING_CHARACTERISTICS); 352 SetSubStatus(SubStatus::WAITING_CHARACTERISTICS);
353 characteristic_finder_.reset(CreateCharacteristicsFinder( 353 characteristic_finder_.reset(CreateCharacteristicsFinder(
354 base::Bind(&BluetoothLowEnergyConnection::OnCharacteristicsFound, 354 base::Bind(&BluetoothLowEnergyConnection::OnCharacteristicsFound,
355 weak_ptr_factory_.GetWeakPtr()), 355 weak_ptr_factory_.GetWeakPtr()),
356 base::Bind(&BluetoothLowEnergyConnection::OnCharacteristicsFinderError, 356 base::Bind(&BluetoothLowEnergyConnection::OnCharacteristicsFinderError,
357 weak_ptr_factory_.GetWeakPtr()))); 357 weak_ptr_factory_.GetWeakPtr())));
358 } 358 }
359 359
360 BluetoothLowEnergyCharacteristicsFinder* 360 cryptauth::BluetoothLowEnergyCharacteristicsFinder*
361 BluetoothLowEnergyConnection::CreateCharacteristicsFinder( 361 BluetoothLowEnergyConnection::CreateCharacteristicsFinder(
362 const BluetoothLowEnergyCharacteristicsFinder::SuccessCallback& 362 const cryptauth::BluetoothLowEnergyCharacteristicsFinder::SuccessCallback&
363 success_callback, 363 success_callback,
364 const BluetoothLowEnergyCharacteristicsFinder::ErrorCallback& 364 const cryptauth::BluetoothLowEnergyCharacteristicsFinder::ErrorCallback&
365 error_callback) { 365 error_callback) {
366 return new BluetoothLowEnergyCharacteristicsFinder( 366 return new cryptauth::BluetoothLowEnergyCharacteristicsFinder(
367 adapter_, GetRemoteDevice(), remote_service_, to_peripheral_char_, 367 adapter_, GetRemoteDevice(), remote_service_, to_peripheral_char_,
368 from_peripheral_char_, success_callback, error_callback); 368 from_peripheral_char_, success_callback, error_callback);
369 } 369 }
370 370
371 void BluetoothLowEnergyConnection::OnCharacteristicsFound( 371 void BluetoothLowEnergyConnection::OnCharacteristicsFound(
372 const RemoteAttribute& service, 372 const cryptauth::RemoteAttribute& service,
373 const RemoteAttribute& to_peripheral_char, 373 const cryptauth::RemoteAttribute& to_peripheral_char,
374 const RemoteAttribute& from_peripheral_char) { 374 const cryptauth::RemoteAttribute& from_peripheral_char) {
375 PA_LOG(INFO) << "Remote chacteristics found."; 375 PA_LOG(INFO) << "Remote chacteristics found.";
376 PrintTimeElapsed(); 376 PrintTimeElapsed();
377 377
378 DCHECK(sub_status() == SubStatus::WAITING_CHARACTERISTICS); 378 DCHECK(sub_status() == SubStatus::WAITING_CHARACTERISTICS);
379 remote_service_ = service; 379 remote_service_ = service;
380 to_peripheral_char_ = to_peripheral_char; 380 to_peripheral_char_ = to_peripheral_char;
381 from_peripheral_char_ = from_peripheral_char; 381 from_peripheral_char_ = from_peripheral_char;
382 382
383 SetSubStatus(SubStatus::CHARACTERISTICS_FOUND); 383 SetSubStatus(SubStatus::CHARACTERISTICS_FOUND);
384 StartNotifySession(); 384 StartNotifySession();
385 } 385 }
386 386
387 void BluetoothLowEnergyConnection::OnCharacteristicsFinderError( 387 void BluetoothLowEnergyConnection::OnCharacteristicsFinderError(
388 const RemoteAttribute& to_peripheral_char, 388 const cryptauth::RemoteAttribute& to_peripheral_char,
389 const RemoteAttribute& from_peripheral_char) { 389 const cryptauth::RemoteAttribute& from_peripheral_char) {
390 DCHECK(sub_status() == SubStatus::WAITING_CHARACTERISTICS); 390 DCHECK(sub_status() == SubStatus::WAITING_CHARACTERISTICS);
391 PA_LOG(WARNING) << "Connection error, missing characteristics for SmartLock " 391 PA_LOG(WARNING) << "Connection error, missing characteristics for SmartLock "
392 "service.\n" 392 "service.\n"
393 << (to_peripheral_char.id.empty() 393 << (to_peripheral_char.id.empty()
394 ? to_peripheral_char.uuid.canonical_value() 394 ? to_peripheral_char.uuid.canonical_value()
395 : "") 395 : "")
396 << (from_peripheral_char.id.empty() 396 << (from_peripheral_char.id.empty()
397 ? ", " + from_peripheral_char.uuid.canonical_value() 397 ? ", " + from_peripheral_char.uuid.canonical_value()
398 : "") << " not found."; 398 : "") << " not found.";
399 399
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 const uint32_t value) { 609 const uint32_t value) {
610 std::vector<uint8_t> bytes(4, 0); 610 std::vector<uint8_t> bytes(4, 0);
611 bytes[0] = static_cast<uint8_t>(value); 611 bytes[0] = static_cast<uint8_t>(value);
612 bytes[1] = static_cast<uint8_t>(value >> 8); 612 bytes[1] = static_cast<uint8_t>(value >> 8);
613 bytes[2] = static_cast<uint8_t>(value >> 16); 613 bytes[2] = static_cast<uint8_t>(value >> 16);
614 bytes[3] = static_cast<uint8_t>(value >> 24); 614 bytes[3] = static_cast<uint8_t>(value >> 24);
615 return bytes; 615 return bytes;
616 } 616 }
617 617
618 } // namespace proximity_auth 618 } // namespace proximity_auth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698