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

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

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 #ifndef COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_LOW_ENERGY_CONNECTION_H_ 5 #ifndef COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_LOW_ENERGY_CONNECTION_H_
6 #define COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_LOW_ENERGY_CONNECTION_H_ 6 #define COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_LOW_ENERGY_CONNECTION_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <memory> 11 #include <memory>
12 #include <queue> 12 #include <queue>
13 #include <string> 13 #include <string>
14 14
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
18 #include "base/time/time.h" 18 #include "base/time/time.h"
19 #include "components/proximity_auth/ble/bluetooth_low_energy_characteristics_fin der.h" 19 #include "components/cryptauth/ble/bluetooth_low_energy_characteristics_finder.h "
20 #include "components/proximity_auth/ble/fake_wire_message.h" 20 #include "components/cryptauth/ble/fake_wire_message.h"
21 #include "components/proximity_auth/ble/remote_attribute.h" 21 #include "components/cryptauth/ble/remote_attribute.h"
22 #include "components/proximity_auth/connection.h" 22 #include "components/proximity_auth/connection.h"
23 #include "device/bluetooth/bluetooth_adapter.h" 23 #include "device/bluetooth/bluetooth_adapter.h"
24 #include "device/bluetooth/bluetooth_device.h" 24 #include "device/bluetooth/bluetooth_device.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"
28 28
29 namespace base { 29 namespace base {
30 class TaskRunner; 30 class TaskRunner;
31 } 31 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 102
103 protected: 103 protected:
104 // Exposed for testing. 104 // Exposed for testing.
105 void SetSubStatus(SubStatus status); 105 void SetSubStatus(SubStatus status);
106 SubStatus sub_status() { return sub_status_; } 106 SubStatus sub_status() { return sub_status_; }
107 107
108 // Sets |task_runner_| for testing. 108 // Sets |task_runner_| for testing.
109 void SetTaskRunnerForTesting(scoped_refptr<base::TaskRunner> task_runner); 109 void SetTaskRunnerForTesting(scoped_refptr<base::TaskRunner> task_runner);
110 110
111 // Virtual for testing. 111 // Virtual for testing.
112 virtual BluetoothLowEnergyCharacteristicsFinder* CreateCharacteristicsFinder( 112 virtual cryptauth::BluetoothLowEnergyCharacteristicsFinder*
113 const BluetoothLowEnergyCharacteristicsFinder::SuccessCallback& 113 CreateCharacteristicsFinder(
114 const cryptauth::BluetoothLowEnergyCharacteristicsFinder::SuccessCallback&
114 success_callback, 115 success_callback,
115 const BluetoothLowEnergyCharacteristicsFinder::ErrorCallback& 116 const cryptauth::BluetoothLowEnergyCharacteristicsFinder::ErrorCallback&
116 error_callback); 117 error_callback);
117 118
118 // proximity_auth::Connection: 119 // proximity_auth::Connection:
119 void SendMessageImpl(std::unique_ptr<WireMessage> message) override; 120 void SendMessageImpl(std::unique_ptr<WireMessage> message) override;
120 121
121 // device::BluetoothAdapter::Observer: 122 // device::BluetoothAdapter::Observer:
122 void DeviceChanged(device::BluetoothAdapter* adapter, 123 void DeviceChanged(device::BluetoothAdapter* adapter,
123 device::BluetoothDevice* device) override; 124 device::BluetoothDevice* device) override;
124 void DeviceRemoved(device::BluetoothAdapter* adapter, 125 void DeviceRemoved(device::BluetoothAdapter* adapter,
125 device::BluetoothDevice* device) override; 126 device::BluetoothDevice* device) override;
(...skipping 25 matching lines...) Expand all
151 // Called when a GATT connection is created. 152 // Called when a GATT connection is created.
152 void OnGattConnectionCreated( 153 void OnGattConnectionCreated(
153 std::unique_ptr<device::BluetoothGattConnection> gatt_connection); 154 std::unique_ptr<device::BluetoothGattConnection> gatt_connection);
154 155
155 // Callback called when there is an error creating the GATT connection. 156 // Callback called when there is an error creating the GATT connection.
156 void OnCreateGattConnectionError( 157 void OnCreateGattConnectionError(
157 device::BluetoothDevice::ConnectErrorCode error_code); 158 device::BluetoothDevice::ConnectErrorCode error_code);
158 159
159 // Callback called when |to_peripheral_char_| and |from_peripheral_char_| were 160 // Callback called when |to_peripheral_char_| and |from_peripheral_char_| were
160 // found. 161 // found.
161 void OnCharacteristicsFound(const RemoteAttribute& service, 162 void OnCharacteristicsFound(
162 const RemoteAttribute& to_peripheral_char, 163 const cryptauth::RemoteAttribute& service,
163 const RemoteAttribute& from_peripheral_char); 164 const cryptauth::RemoteAttribute& to_peripheral_char,
165 const cryptauth::RemoteAttribute& from_peripheral_char);
164 166
165 // Callback called there was an error finding the characteristics. 167 // Callback called there was an error finding the characteristics.
166 void OnCharacteristicsFinderError( 168 void OnCharacteristicsFinderError(
167 const RemoteAttribute& to_peripheral_char, 169 const cryptauth::RemoteAttribute& to_peripheral_char,
168 const RemoteAttribute& from_peripheral_char); 170 const cryptauth::RemoteAttribute& from_peripheral_char);
169 171
170 // Starts a notify session for |from_peripheral_char_| when ready 172 // Starts a notify session for |from_peripheral_char_| when ready
171 // (SubStatus::CHARACTERISTICS_FOUND). 173 // (SubStatus::CHARACTERISTICS_FOUND).
172 void StartNotifySession(); 174 void StartNotifySession();
173 175
174 // Called when a notification session is successfully started for 176 // Called when a notification session is successfully started for
175 // |from_peripheral_char_| characteristic. 177 // |from_peripheral_char_| characteristic.
176 void OnNotifySessionStarted( 178 void OnNotifySessionStarted(
177 std::unique_ptr<device::BluetoothGattNotifySession> notify_session); 179 std::unique_ptr<device::BluetoothGattNotifySession> notify_session);
178 180
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 // Convert the first 4 bytes from a byte vector to a uint32_t. 243 // Convert the first 4 bytes from a byte vector to a uint32_t.
242 uint32_t ToUint32(const std::vector<uint8_t>& bytes); 244 uint32_t ToUint32(const std::vector<uint8_t>& bytes);
243 245
244 // Convert an uint32_t to a byte vector. 246 // Convert an uint32_t to a byte vector.
245 const std::vector<uint8_t> ToByteVector(uint32_t value); 247 const std::vector<uint8_t> ToByteVector(uint32_t value);
246 248
247 // The Bluetooth adapter over which the Bluetooth connection will be made. 249 // The Bluetooth adapter over which the Bluetooth connection will be made.
248 scoped_refptr<device::BluetoothAdapter> adapter_; 250 scoped_refptr<device::BluetoothAdapter> adapter_;
249 251
250 // Remote service the |gatt_connection_| was established with. 252 // Remote service the |gatt_connection_| was established with.
251 RemoteAttribute remote_service_; 253 cryptauth::RemoteAttribute remote_service_;
252 254
253 // Characteristic used to send data to the remote device. 255 // Characteristic used to send data to the remote device.
254 RemoteAttribute to_peripheral_char_; 256 cryptauth::RemoteAttribute to_peripheral_char_;
255 257
256 // Characteristic used to receive data from the remote device. 258 // Characteristic used to receive data from the remote device.
257 RemoteAttribute from_peripheral_char_; 259 cryptauth::RemoteAttribute from_peripheral_char_;
258 260
259 // Throttles repeated connection attempts to the same device. This is a 261 // Throttles repeated connection attempts to the same device. This is a
260 // workaround for crbug.com/508919. Not owned, must outlive this instance. 262 // workaround for crbug.com/508919. Not owned, must outlive this instance.
261 BluetoothThrottler* bluetooth_throttler_; 263 BluetoothThrottler* bluetooth_throttler_;
262 264
263 scoped_refptr<base::TaskRunner> task_runner_; 265 scoped_refptr<base::TaskRunner> task_runner_;
264 266
265 // The GATT connection with the remote device. 267 // The GATT connection with the remote device.
266 std::unique_ptr<device::BluetoothGattConnection> gatt_connection_; 268 std::unique_ptr<device::BluetoothGattConnection> gatt_connection_;
267 269
268 // The characteristics finder for remote device. 270 // The characteristics finder for remote device.
269 std::unique_ptr<BluetoothLowEnergyCharacteristicsFinder> 271 std::unique_ptr<cryptauth::BluetoothLowEnergyCharacteristicsFinder>
270 characteristic_finder_; 272 characteristic_finder_;
271 273
272 // The notify session for |from_peripheral_char|. 274 // The notify session for |from_peripheral_char|.
273 std::unique_ptr<device::BluetoothGattNotifySession> notify_session_; 275 std::unique_ptr<device::BluetoothGattNotifySession> notify_session_;
274 276
275 // Internal connection status 277 // Internal connection status
276 SubStatus sub_status_; 278 SubStatus sub_status_;
277 279
278 // Indicates a receiving operation is in progress. This is set after a 280 // Indicates a receiving operation is in progress. This is set after a
279 // ControlSignal::kSendSignal was received from the remote device. 281 // ControlSignal::kSendSignal was received from the remote device.
(...skipping 26 matching lines...) Expand all
306 base::TimeTicks start_time_; 308 base::TimeTicks start_time_;
307 309
308 base::WeakPtrFactory<BluetoothLowEnergyConnection> weak_ptr_factory_; 310 base::WeakPtrFactory<BluetoothLowEnergyConnection> weak_ptr_factory_;
309 311
310 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyConnection); 312 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyConnection);
311 }; 313 };
312 314
313 } // namespace proximity_auth 315 } // namespace proximity_auth
314 316
315 #endif // COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_LOW_ENERGY_CONNECTION_H_ 317 #endif // COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_LOW_ENERGY_CONNECTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698