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_HOST_SCAN_DEVICE_PRIORITIZER_H_ | 5 #ifndef CHROMEOS_COMPONENTS_TETHER_HOST_SCAN_DEVICE_PRIORITIZER_H_ |
6 #define CHROMEOS_COMPONENTS_TETHER_HOST_SCAN_DEVICE_PRIORITIZER_H_ | 6 #define CHROMEOS_COMPONENTS_TETHER_HOST_SCAN_DEVICE_PRIORITIZER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "components/cryptauth/remote_device.h" | 9 #include "components/cryptauth/remote_device.h" |
10 | 10 |
11 class PrefService; | |
12 class PrefRegistrySimple; | |
13 | |
14 namespace chromeos { | 11 namespace chromeos { |
15 | 12 |
16 namespace tether { | 13 namespace tether { |
17 | 14 |
15 class TetherHostResponseRecorder; | |
16 | |
18 // Prioritizes the order of devices when performing a host scan. To optimize for | 17 // Prioritizes the order of devices when performing a host scan. To optimize for |
19 // the most common tethering operations, this class uses the following rules: | 18 // the most common tethering operations, this class uses the following rules: |
20 // * The device which has most recently sent a successful | 19 // * The device which has most recently sent a successful |
21 // ConnectTetheringResponse is always at the front of the queue. | 20 // ConnectTetheringResponse is always at the front of the queue. |
Ryan Hansberry
2017/04/27 17:45:54
Now that we capture all of the devices we've conne
Kyle Horimoto
2017/04/27 17:51:42
No, I don't think this should be the case. Here's
Ryan Hansberry
2017/04/27 18:08:25
Alright, I agree. Thanks.
| |
22 // * Devices which have most recently sent a successful | 21 // * Devices which have most recently sent a successful |
23 // TetherAvailabilityResponse are next in the order, as long as they do not | 22 // TetherAvailabilityResponse are next in the order, as long as they do not |
24 // violate the first rule. | 23 // violate the first rule. |
Ryan Hansberry
2017/04/27 18:08:25
Re-reading this is kind of odd. How can the first
| |
25 // * All other devices are left in the order they are passed. | 24 // * All other devices are left in the order they are passed. |
26 class HostScanDevicePrioritizer { | 25 class HostScanDevicePrioritizer { |
27 public: | 26 public: |
28 // Note: The PrefService* passed here must be created using the same registry | 27 HostScanDevicePrioritizer( |
29 // passed to RegisterPrefs(). | 28 TetherHostResponseRecorder* tether_host_response_recorder); |
30 HostScanDevicePrioritizer(PrefService* pref_service); | |
31 virtual ~HostScanDevicePrioritizer(); | 29 virtual ~HostScanDevicePrioritizer(); |
32 | 30 |
33 // Registers the prefs used by this class to |registry|. Must be called before | |
34 // this class is utilized. | |
35 static void RegisterPrefs(PrefRegistrySimple* registry); | |
36 | |
37 // Records a TetherAvailabilityResponse. This function should be called each | |
38 // time that a response is received from a potential host, even if a | |
39 // connection is not started. | |
40 virtual void RecordSuccessfulTetherAvailabilityResponse( | |
41 const cryptauth::RemoteDevice& remote_device); | |
42 | |
43 // Records a ConnectTetheringResponse. This function should be called each | |
44 // time that a response is received from a host. | |
45 virtual void RecordSuccessfulConnectTetheringResponse( | |
46 const cryptauth::RemoteDevice& remote_device); | |
47 | |
48 // Prioritizes |remote_devices| using the rules described above. | 31 // Prioritizes |remote_devices| using the rules described above. |
49 virtual void SortByHostScanOrder( | 32 virtual void SortByHostScanOrder( |
50 std::vector<cryptauth::RemoteDevice>* remote_devices) const; | 33 std::vector<cryptauth::RemoteDevice>* remote_devices) const; |
51 | 34 |
52 private: | 35 private: |
53 PrefService* pref_service_; | 36 TetherHostResponseRecorder* tether_host_response_recorder_; |
54 | 37 |
55 DISALLOW_COPY_AND_ASSIGN(HostScanDevicePrioritizer); | 38 DISALLOW_COPY_AND_ASSIGN(HostScanDevicePrioritizer); |
56 }; | 39 }; |
57 | 40 |
58 } // namespace tether | 41 } // namespace tether |
59 | 42 |
60 } // namespace chromeos | 43 } // namespace chromeos |
61 | 44 |
62 #endif // CHROMEOS_COMPONENTS_TETHER_HOST_SCAN_DEVICE_PRIORITIZER_H_ | 45 #endif // CHROMEOS_COMPONENTS_TETHER_HOST_SCAN_DEVICE_PRIORITIZER_H_ |
OLD | NEW |