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

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

Issue 2713073002: [CrOS Tether] Create HostScanDevicePrioritizer, a class which prioritizes the order of connection a… (Closed)
Patch Set: Add dep. Created 3 years, 10 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
OLDNEW
(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 SortByHostScanOrder(
50 std::vector<cryptauth::RemoteDevice>* remote_devices) const;
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_
OLDNEW
« no previous file with comments | « chromeos/components/tether/BUILD.gn ('k') | chromeos/components/tether/host_scan_device_prioritizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698