OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROMEOS_COMPONENTS_TETHER_HOST_SCAN_DEVICE_PRIORITIZER_H_ | |
6 #define CHROMEOS_COMPONENTS_TETHER_HOST_SCAN_DEVICE_PRIORITIZER_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "components/cryptauth/remote_device.h" | |
10 | |
11 class PrefService; | |
12 class PrefRegistrySimple; | |
13 | |
14 namespace chromeos { | |
15 | |
16 namespace tether { | |
17 | |
18 // 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: | |
20 // * The device which has most recently sent a successful | |
21 // ConnectTetheringResponse is always at the front of the queue. | |
22 // * Devices which have most recently sent a successful | |
23 // TetherAvailabilityResponse are next in the order, as long as they do not | |
24 // violate the first rule. | |
25 // * All other devices are left in the order they are passed. | |
26 class HostScanDevicePrioritizer { | |
27 public: | |
28 // Note: The PrefService* passed here must be created using the same registry | |
29 // passed to RegisterPrefs(). | |
30 HostScanDevicePrioritizer(PrefService* pref_service); | |
31 ~HostScanDevicePrioritizer(); | |
32 | |
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 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 void RecordSuccessfulConnectTetheringResponse( | |
46 const cryptauth::RemoteDevice& remote_device); | |
47 | |
48 // Prioritizes |remote_devices| using the rules described above. | |
49 void PrioritizeHostScanDeviceOrder( | |
50 std::vector<cryptauth::RemoteDevice>& remote_devices) const; | |
Tim Song
2017/02/24 18:57:40
According to the Google style guide, all arguments
Kyle Horimoto
2017/02/24 19:21:30
Done.
| |
51 | |
52 private: | |
53 PrefService* pref_service_; | |
54 | |
55 DISALLOW_COPY_AND_ASSIGN(HostScanDevicePrioritizer); | |
56 }; | |
57 | |
58 } // namespace tether | |
59 | |
60 } // namespace chromeos | |
61 | |
62 #endif // CHROMEOS_COMPONENTS_TETHER_HOST_SCAN_DEVICE_PRIORITIZER_H_ | |
OLD | NEW |