| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 CHROMEOS_COMPONENTS_TETHER_BLE_CONNECTION_MANAGER_H_ | 5 #ifndef CHROMEOS_COMPONENTS_TETHER_BLE_CONNECTION_MANAGER_H_ |
| 6 #define CHROMEOS_COMPONENTS_TETHER_BLE_CONNECTION_MANAGER_H_ | 6 #define CHROMEOS_COMPONENTS_TETHER_BLE_CONNECTION_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 namespace cryptauth { | 23 namespace cryptauth { |
| 24 class BluetoothThrottler; | 24 class BluetoothThrottler; |
| 25 class CryptAuthService; | 25 class CryptAuthService; |
| 26 } // namespace cryptauth | 26 } // namespace cryptauth |
| 27 | 27 |
| 28 namespace chromeos { | 28 namespace chromeos { |
| 29 | 29 |
| 30 namespace tether { | 30 namespace tether { |
| 31 | 31 |
| 32 class TimerFactory; |
| 33 |
| 32 // Manages connections to remote devices. When a device is registered, | 34 // Manages connections to remote devices. When a device is registered, |
| 33 // BleConnectionManager intiates a connection to that device. If the connection | 35 // BleConnectionManager intiates a connection to that device. If the connection |
| 34 // succeeds and authenticates successfully, messages can be sent/received | 36 // succeeds and authenticates successfully, messages can be sent/received |
| 35 // to/from the device. If the connection does not succeed, BleConnectionManager | 37 // to/from the device. If the connection does not succeed, BleConnectionManager |
| 36 // continues attempting connections until a connection is established or the | 38 // continues attempting connections until a connection is established or the |
| 37 // device is unregistered. | 39 // device is unregistered. |
| 38 // | 40 // |
| 39 // To use this class, construct an instance and observe it via AddObserver(). | 41 // To use this class, construct an instance and observe it via AddObserver(). |
| 40 // Then, register device(s) to connect to via RegisterRemoteDevice() and wait | 42 // Then, register device(s) to connect to via RegisterRemoteDevice() and wait |
| 41 // for the OnSecureChannelStatusChanged() callback to be invoked. If the | 43 // for the OnSecureChannelStatusChanged() callback to be invoked. If the |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 104 |
| 103 void AddObserver(Observer* observer); | 105 void AddObserver(Observer* observer); |
| 104 void RemoveObserver(Observer* observer); | 106 void RemoveObserver(Observer* observer); |
| 105 | 107 |
| 106 // BleScanner::Observer: | 108 // BleScanner::Observer: |
| 107 void OnReceivedAdvertisementFromDevice( | 109 void OnReceivedAdvertisementFromDevice( |
| 108 const std::string& device_address, | 110 const std::string& device_address, |
| 109 cryptauth::RemoteDevice remote_device) override; | 111 cryptauth::RemoteDevice remote_device) override; |
| 110 | 112 |
| 111 protected: | 113 protected: |
| 112 class TimerFactory { | |
| 113 public: | |
| 114 virtual std::unique_ptr<base::Timer> CreateTimer(); | |
| 115 }; | |
| 116 | |
| 117 BleConnectionManager( | 114 BleConnectionManager( |
| 118 cryptauth::CryptAuthService* cryptauth_service, | 115 cryptauth::CryptAuthService* cryptauth_service, |
| 119 scoped_refptr<device::BluetoothAdapter> adapter, | 116 scoped_refptr<device::BluetoothAdapter> adapter, |
| 120 std::unique_ptr<BleScanner> ble_scanner, | 117 std::unique_ptr<BleScanner> ble_scanner, |
| 121 std::unique_ptr<BleAdvertiser> ble_advertiser, | 118 std::unique_ptr<BleAdvertiser> ble_advertiser, |
| 122 std::unique_ptr<BleAdvertisementDeviceQueue> device_queue, | 119 std::unique_ptr<BleAdvertisementDeviceQueue> device_queue, |
| 123 std::unique_ptr<TimerFactory> timer_factory, | 120 std::unique_ptr<TimerFactory> timer_factory, |
| 124 cryptauth::BluetoothThrottler* bluetooth_throttler); | 121 cryptauth::BluetoothThrottler* bluetooth_throttler); |
| 125 | 122 |
| 126 void SendMessageReceivedEvent(const cryptauth::RemoteDevice& remote_device, | 123 void SendMessageReceivedEvent(const cryptauth::RemoteDevice& remote_device, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 base::WeakPtrFactory<BleConnectionManager> weak_ptr_factory_; | 216 base::WeakPtrFactory<BleConnectionManager> weak_ptr_factory_; |
| 220 | 217 |
| 221 DISALLOW_COPY_AND_ASSIGN(BleConnectionManager); | 218 DISALLOW_COPY_AND_ASSIGN(BleConnectionManager); |
| 222 }; | 219 }; |
| 223 | 220 |
| 224 } // namespace tether | 221 } // namespace tether |
| 225 | 222 |
| 226 } // namespace chromeos | 223 } // namespace chromeos |
| 227 | 224 |
| 228 #endif // CHROMEOS_COMPONENTS_TETHER_BLE_CONNECTION_MANAGER_H_ | 225 #endif // CHROMEOS_COMPONENTS_TETHER_BLE_CONNECTION_MANAGER_H_ |
| OLD | NEW |