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

Side by Side Diff: components/cryptauth/ble/bluetooth_low_energy_characteristics_finder.cc

Issue 2561203002: Migrate weave-related classes from proximity_auth/ble to cryptauth/ble. (Closed)
Patch Set: Moved all general classes from proximity_auth to cryptauth. 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_characteristics_fin der.h" 5 #include "components/cryptauth/ble/bluetooth_low_energy_characteristics_finder.h "
6 6
7 #include "components/proximity_auth/logging/logging.h" 7 #include "components/proximity_auth/logging/logging.h"
8 #include "device/bluetooth/bluetooth_adapter.h" 8 #include "device/bluetooth/bluetooth_adapter.h"
9 #include "device/bluetooth/bluetooth_device.h" 9 #include "device/bluetooth/bluetooth_device.h"
10 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" 10 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h"
11 #include "device/bluetooth/bluetooth_uuid.h" 11 #include "device/bluetooth/bluetooth_uuid.h"
12 12
13 using device::BluetoothAdapter; 13 using device::BluetoothAdapter;
14 using device::BluetoothDevice; 14 using device::BluetoothDevice;
15 using device::BluetoothRemoteGattCharacteristic; 15 using device::BluetoothRemoteGattCharacteristic;
16 using device::BluetoothRemoteGattService; 16 using device::BluetoothRemoteGattService;
17 using device::BluetoothUUID; 17 using device::BluetoothUUID;
18 18
19 namespace proximity_auth { 19 namespace cryptauth {
20 20
21 BluetoothLowEnergyCharacteristicsFinder:: 21 BluetoothLowEnergyCharacteristicsFinder::
22 BluetoothLowEnergyCharacteristicsFinder( 22 BluetoothLowEnergyCharacteristicsFinder(
23 scoped_refptr<BluetoothAdapter> adapter, 23 scoped_refptr<BluetoothAdapter> adapter,
24 BluetoothDevice* device, 24 BluetoothDevice* device,
25 const RemoteAttribute& remote_service, 25 const RemoteAttribute& remote_service,
26 const RemoteAttribute& to_peripheral_char, 26 const RemoteAttribute& to_peripheral_char,
27 const RemoteAttribute& from_peripheral_char, 27 const RemoteAttribute& from_peripheral_char,
28 const SuccessCallback& success_callback, 28 const SuccessCallback& success_callback,
29 const ErrorCallback& error_callback) 29 const ErrorCallback& error_callback)
30 : adapter_(adapter), 30 : adapter_(adapter),
31 remote_service_(remote_service), 31 remote_service_(remote_service),
32 to_peripheral_char_(to_peripheral_char), 32 to_peripheral_char_(to_peripheral_char),
33 from_peripheral_char_(from_peripheral_char), 33 from_peripheral_char_(from_peripheral_char),
34 success_callback_(success_callback), 34 success_callback_(success_callback),
35 error_callback_(error_callback) { 35 error_callback_(error_callback) {
36 if (!adapter_) { 36 if (!adapter_) {
37 error_callback_.Run(to_peripheral_char_, from_peripheral_char_); 37 error_callback_.Run(to_peripheral_char_, from_peripheral_char_);
38 ResetCallbacks(); 38 ResetCallbacks();
39 return; 39 return;
40 } 40 }
41 41
42 adapter_->AddObserver(this); 42 adapter_->AddObserver(this);
43 ScanRemoteCharacteristics(device, remote_service_.uuid); 43 ScanRemoteCharacteristics(device, remote_service_.uuid);
44 44
45 // TODO(sacomoto): implement a timeout for characteristic discovery. 45 // TODO(sacomoto): implement a timeout for characteristic discovery.
46 } 46 }
47 47
48 BluetoothLowEnergyCharacteristicsFinder:: 48 BluetoothLowEnergyCharacteristicsFinder::
49 BluetoothLowEnergyCharacteristicsFinder() { 49 BluetoothLowEnergyCharacteristicsFinder() {}
50 }
51 50
52 BluetoothLowEnergyCharacteristicsFinder:: 51 BluetoothLowEnergyCharacteristicsFinder::
53 ~BluetoothLowEnergyCharacteristicsFinder() { 52 ~BluetoothLowEnergyCharacteristicsFinder() {
54 ResetCallbacks(); 53 ResetCallbacks();
55 if (adapter_) { 54 if (adapter_) {
56 adapter_->RemoveObserver(this); 55 adapter_->RemoveObserver(this);
57 adapter_ = NULL; 56 adapter_ = NULL;
58 } 57 }
59 } 58 }
60 59
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 BluetoothRemoteGattService* service = characteristic->GetService(); 132 BluetoothRemoteGattService* service = characteristic->GetService();
134 remote_service_.id = service->GetIdentifier(); 133 remote_service_.id = service->GetIdentifier();
135 } 134 }
136 } 135 }
137 136
138 void BluetoothLowEnergyCharacteristicsFinder::ResetCallbacks() { 137 void BluetoothLowEnergyCharacteristicsFinder::ResetCallbacks() {
139 success_callback_.Reset(); 138 success_callback_.Reset();
140 error_callback_.Reset(); 139 error_callback_.Reset();
141 } 140 }
142 141
143 } // namespace proximity_auth 142 } // namespace cryptauth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698