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

Side by Side Diff: chromeos/components/tether/ble_connection_manager.h

Issue 2803153002: [CrOS Tether] Refactor BleScanner so that it takes a BluetoothAdapter in its constructor instead of… (Closed)
Patch Set: Created 3 years, 8 months 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
« no previous file with comments | « no previous file | chromeos/components/tether/ble_connection_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 102
103 void AddObserver(Observer* observer); 103 void AddObserver(Observer* observer);
104 void RemoveObserver(Observer* observer); 104 void RemoveObserver(Observer* observer);
105 105
106 // BleScanner::Observer: 106 // BleScanner::Observer:
107 void OnReceivedAdvertisementFromDevice( 107 void OnReceivedAdvertisementFromDevice(
108 const std::string& device_address, 108 const std::string& device_address,
109 cryptauth::RemoteDevice remote_device) override; 109 cryptauth::RemoteDevice remote_device) override;
110 110
111 protected: 111 protected:
112 class TimerFactory {
113 public:
114 virtual std::unique_ptr<base::Timer> CreateTimer();
115 };
116
117 BleConnectionManager(
118 cryptauth::CryptAuthService* cryptauth_service,
119 scoped_refptr<device::BluetoothAdapter> adapter,
120 std::unique_ptr<BleScanner> ble_scanner,
121 std::unique_ptr<BleAdvertiser> ble_advertiser,
122 std::unique_ptr<BleAdvertisementDeviceQueue> device_queue,
123 std::unique_ptr<TimerFactory> timer_factory,
124 cryptauth::BluetoothThrottler* bluetooth_throttler);
125
112 void SendMessageReceivedEvent(const cryptauth::RemoteDevice& remote_device, 126 void SendMessageReceivedEvent(const cryptauth::RemoteDevice& remote_device,
113 const std::string& payload); 127 const std::string& payload);
114 void SendSecureChannelStatusChangeEvent( 128 void SendSecureChannelStatusChangeEvent(
115 const cryptauth::RemoteDevice& remote_device, 129 const cryptauth::RemoteDevice& remote_device,
116 const cryptauth::SecureChannel::Status& old_status, 130 const cryptauth::SecureChannel::Status& old_status,
117 const cryptauth::SecureChannel::Status& new_status); 131 const cryptauth::SecureChannel::Status& new_status);
118 132
119 private: 133 private:
120 friend class BleConnectionManagerTest; 134 friend class BleConnectionManagerTest;
121 135
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 177
164 cryptauth::RemoteDevice remote_device_; 178 cryptauth::RemoteDevice remote_device_;
165 std::set<MessageType> active_connection_reasons_; 179 std::set<MessageType> active_connection_reasons_;
166 std::shared_ptr<cryptauth::SecureChannel> secure_channel_; 180 std::shared_ptr<cryptauth::SecureChannel> secure_channel_;
167 std::shared_ptr<base::Timer> connection_attempt_timeout_timer_; 181 std::shared_ptr<base::Timer> connection_attempt_timeout_timer_;
168 base::WeakPtr<BleConnectionManager> manager_; 182 base::WeakPtr<BleConnectionManager> manager_;
169 183
170 base::WeakPtrFactory<ConnectionMetadata> weak_ptr_factory_; 184 base::WeakPtrFactory<ConnectionMetadata> weak_ptr_factory_;
171 }; 185 };
172 186
173 class TimerFactory {
174 public:
175 virtual std::unique_ptr<base::Timer> CreateTimer();
176 };
177
178 BleConnectionManager(
179 cryptauth::CryptAuthService* cryptauth_service,
180 scoped_refptr<device::BluetoothAdapter> adapter,
181 std::unique_ptr<BleScanner> ble_scanner,
182 std::unique_ptr<BleAdvertiser> ble_advertiser,
183 std::unique_ptr<BleAdvertisementDeviceQueue> device_queue,
184 std::unique_ptr<TimerFactory> timer_factory,
185 cryptauth::BluetoothThrottler* bluetooth_throttler);
186 187
187 std::shared_ptr<ConnectionMetadata> GetConnectionMetadata( 188 std::shared_ptr<ConnectionMetadata> GetConnectionMetadata(
188 const cryptauth::RemoteDevice& remote_device) const; 189 const cryptauth::RemoteDevice& remote_device) const;
189 std::shared_ptr<ConnectionMetadata> AddMetadataForDevice( 190 std::shared_ptr<ConnectionMetadata> AddMetadataForDevice(
190 const cryptauth::RemoteDevice& remote_device); 191 const cryptauth::RemoteDevice& remote_device);
191 192
192 void UpdateConnectionAttempts(); 193 void UpdateConnectionAttempts();
193 void UpdateAdvertisementQueue(); 194 void UpdateAdvertisementQueue();
194 195
195 void StartConnectionAttempt(const cryptauth::RemoteDevice& remote_device); 196 void StartConnectionAttempt(const cryptauth::RemoteDevice& remote_device);
(...skipping 22 matching lines...) Expand all
218 base::WeakPtrFactory<BleConnectionManager> weak_ptr_factory_; 219 base::WeakPtrFactory<BleConnectionManager> weak_ptr_factory_;
219 220
220 DISALLOW_COPY_AND_ASSIGN(BleConnectionManager); 221 DISALLOW_COPY_AND_ASSIGN(BleConnectionManager);
221 }; 222 };
222 223
223 } // namespace tether 224 } // namespace tether
224 225
225 } // namespace chromeos 226 } // namespace chromeos
226 227
227 #endif // CHROMEOS_COMPONENTS_TETHER_BLE_CONNECTION_MANAGER_H_ 228 #endif // CHROMEOS_COMPONENTS_TETHER_BLE_CONNECTION_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | chromeos/components/tether/ble_connection_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698