| OLD | NEW |
| 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_FINDER_H | 5 #ifndef COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_LOW_ENERGY_CONNECTION_FINDER_H |
| 6 #define COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_LOW_ENERGY_CONNECTION_FINDER_H | 6 #define COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_LOW_ENERGY_CONNECTION_FINDER_H |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "components/cryptauth/remote_device.h" |
| 16 #include "components/proximity_auth/connection.h" | 17 #include "components/proximity_auth/connection.h" |
| 17 #include "components/proximity_auth/connection_finder.h" | 18 #include "components/proximity_auth/connection_finder.h" |
| 18 #include "components/proximity_auth/connection_observer.h" | 19 #include "components/proximity_auth/connection_observer.h" |
| 19 #include "components/proximity_auth/remote_device.h" | |
| 20 #include "device/bluetooth/bluetooth_adapter.h" | 20 #include "device/bluetooth/bluetooth_adapter.h" |
| 21 #include "device/bluetooth/bluetooth_device.h" | 21 #include "device/bluetooth/bluetooth_device.h" |
| 22 #include "device/bluetooth/bluetooth_discovery_session.h" | 22 #include "device/bluetooth/bluetooth_discovery_session.h" |
| 23 #include "device/bluetooth/bluetooth_gatt_connection.h" | 23 #include "device/bluetooth/bluetooth_gatt_connection.h" |
| 24 | 24 |
| 25 namespace proximity_auth { | 25 namespace proximity_auth { |
| 26 | 26 |
| 27 class BluetoothLowEnergyDeviceWhitelist; | 27 class BluetoothLowEnergyDeviceWhitelist; |
| 28 class BluetoothThrottler; | 28 class BluetoothThrottler; |
| 29 | 29 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 46 // |remote_device|: The BLE remote device. |remote_device.bluetooth_adress| | 46 // |remote_device|: The BLE remote device. |remote_device.bluetooth_adress| |
| 47 // should be empty when |has_public_bluetooth_address| is false. | 47 // should be empty when |has_public_bluetooth_address| is false. |
| 48 // |remote_service_uuid|: The UUID of the service used to send/receive data in | 48 // |remote_service_uuid|: The UUID of the service used to send/receive data in |
| 49 // remote device. | 49 // remote device. |
| 50 // |bluetooth_throttler|: The reconnection throttler. | 50 // |bluetooth_throttler|: The reconnection throttler. |
| 51 // |max_number_of_tries|: Maximum number attempts to send a message before | 51 // |max_number_of_tries|: Maximum number attempts to send a message before |
| 52 // disconnecting. | 52 // disconnecting. |
| 53 // TODO(sacomoto): Remove |device_whitelist| when ProximityAuthBleSystem is | 53 // TODO(sacomoto): Remove |device_whitelist| when ProximityAuthBleSystem is |
| 54 // not needed anymore. | 54 // not needed anymore. |
| 55 BluetoothLowEnergyConnectionFinder( | 55 BluetoothLowEnergyConnectionFinder( |
| 56 const RemoteDevice remote_device, | 56 const cryptauth::RemoteDevice remote_device, |
| 57 const std::string& remote_service_uuid, | 57 const std::string& remote_service_uuid, |
| 58 const FinderStrategy finder_strategy, | 58 const FinderStrategy finder_strategy, |
| 59 const BluetoothLowEnergyDeviceWhitelist* device_whitelist, | 59 const BluetoothLowEnergyDeviceWhitelist* device_whitelist, |
| 60 BluetoothThrottler* bluetooth_throttler, | 60 BluetoothThrottler* bluetooth_throttler, |
| 61 int max_number_of_tries); | 61 int max_number_of_tries); |
| 62 | 62 |
| 63 ~BluetoothLowEnergyConnectionFinder() override; | 63 ~BluetoothLowEnergyConnectionFinder() override; |
| 64 | 64 |
| 65 // Finds a connection to the remote device. | 65 // Finds a connection to the remote device. |
| 66 void Find(const ConnectionCallback& connection_callback) override; | 66 void Find(const ConnectionCallback& connection_callback) override; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // Used to invoke |connection_callback_| asynchronously, decoupling the | 118 // Used to invoke |connection_callback_| asynchronously, decoupling the |
| 119 // callback invocation from the ConnectionObserver callstack. | 119 // callback invocation from the ConnectionObserver callstack. |
| 120 void InvokeCallbackAsync(); | 120 void InvokeCallbackAsync(); |
| 121 | 121 |
| 122 // Returns the device with |device_address|. | 122 // Returns the device with |device_address|. |
| 123 device::BluetoothDevice* GetDevice(const std::string& device_address); | 123 device::BluetoothDevice* GetDevice(const std::string& device_address); |
| 124 | 124 |
| 125 // The remote BLE device being searched. It maybe empty, in this case the | 125 // The remote BLE device being searched. It maybe empty, in this case the |
| 126 // remote device should advertise |remote_service_uuid_| and | 126 // remote device should advertise |remote_service_uuid_| and |
| 127 // |advertised_name_|. | 127 // |advertised_name_|. |
| 128 RemoteDevice remote_device_; | 128 cryptauth::RemoteDevice remote_device_; |
| 129 | 129 |
| 130 // The uuid of the service it looks for to establish a GattConnection. | 130 // The uuid of the service it looks for to establish a GattConnection. |
| 131 device::BluetoothUUID remote_service_uuid_; | 131 device::BluetoothUUID remote_service_uuid_; |
| 132 | 132 |
| 133 // The finder strategy being used. See |IsRightDevice()|. | 133 // The finder strategy being used. See |IsRightDevice()|. |
| 134 const FinderStrategy finder_strategy_; | 134 const FinderStrategy finder_strategy_; |
| 135 | 135 |
| 136 // Devices in |device_whitelist_| don't need to have |remote_service_uuid_| | 136 // Devices in |device_whitelist_| don't need to have |remote_service_uuid_| |
| 137 // cached or advertised. Not owned, must outlive this instance. | 137 // cached or advertised. Not owned, must outlive this instance. |
| 138 // TODO(sacomoto): Remove |device_whitelist_| when ProximityAuthBleSystem is | 138 // TODO(sacomoto): Remove |device_whitelist_| when ProximityAuthBleSystem is |
| (...skipping 21 matching lines...) Expand all Loading... |
| 160 int max_number_of_tries_; | 160 int max_number_of_tries_; |
| 161 | 161 |
| 162 base::WeakPtrFactory<BluetoothLowEnergyConnectionFinder> weak_ptr_factory_; | 162 base::WeakPtrFactory<BluetoothLowEnergyConnectionFinder> weak_ptr_factory_; |
| 163 | 163 |
| 164 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyConnectionFinder); | 164 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyConnectionFinder); |
| 165 }; | 165 }; |
| 166 | 166 |
| 167 } // namespace proximity_auth | 167 } // namespace proximity_auth |
| 168 | 168 |
| 169 #endif // COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_CONNECTION_FINDER_H | 169 #endif // COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_CONNECTION_FINDER_H |
| OLD | NEW |