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

Unified Diff: chromeos/components/tether/host_scan_device_prioritizer.h

Issue 2945643002: [CrOS Tether] Sort Tether network lists. (Closed)
Patch Set: Cleanup - now ready for review. Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chromeos/components/tether/host_scan_device_prioritizer.h
diff --git a/chromeos/components/tether/host_scan_device_prioritizer.h b/chromeos/components/tether/host_scan_device_prioritizer.h
index 43997e45572793765463c0f219f7dff873b5a5fa..f57a03a1d245f68a8488c9c21f65afa232d9194d 100644
--- a/chromeos/components/tether/host_scan_device_prioritizer.h
+++ b/chromeos/components/tether/host_scan_device_prioritizer.h
@@ -6,13 +6,17 @@
#define CHROMEOS_COMPONENTS_TETHER_HOST_SCAN_DEVICE_PRIORITIZER_H_
#include "base/macros.h"
+#include "chromeos/network/network_state_handler.h"
#include "components/cryptauth/remote_device.h"
namespace chromeos {
+class NetworkStateHandler;
+
namespace tether {
class TetherHostResponseRecorder;
+class DeviceIdTetherNetworkGuidMap;
// Prioritizes the order of devices when performing a host scan. To optimize for
// the most common tethering operations, this class uses the following rules:
@@ -22,18 +26,42 @@ class TetherHostResponseRecorder;
// TetherAvailabilityResponse are next in the order, as long as they do not
// violate the first rule.
// * All other devices are left in the order they are passed.
-class HostScanDevicePrioritizer {
+class HostScanDevicePrioritizer
+ : public NetworkStateHandler::TetherNetworkListSorter {
public:
HostScanDevicePrioritizer(
- TetherHostResponseRecorder* tether_host_response_recorder);
+ NetworkStateHandler* network_state_handler,
+ TetherHostResponseRecorder* tether_host_response_recorder,
+ DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map);
virtual ~HostScanDevicePrioritizer();
// Prioritizes |remote_devices| using the rules described above.
virtual void SortByHostScanOrder(
std::vector<cryptauth::RemoteDevice>* remote_devices) const;
+ // NetworkStateHandler::TetherNetworkListSorter:
+ void SortTetherNetworkList(
+ NetworkStateHandler::ManagedStateList* tether_networks) const override;
+
private:
+ // Performs sorting for both SortByHostScanOrder() and
+ // SortTetherNetworkList().
+ template <typename T>
+ void SortNetworks(std::vector<T>* list_to_sort) const;
+
+ // GetDeviceId() and Move() are used internally by SortNetworks() to sort
+ // lists of both cryptauth::RemoteDevice and std::unique_ptr<ManagedState>.
+ std::string GetDeviceId(const cryptauth::RemoteDevice& remote_device) const;
+ std::string GetDeviceId(
+ const std::unique_ptr<ManagedState>& tether_network_state) const;
+ cryptauth::RemoteDevice Move(
+ const cryptauth::RemoteDevice& remote_device) const;
+ std::unique_ptr<ManagedState> Move(
Ryan Hansberry 2017/06/19 19:17:48 Why ManagedState instead of NetworkState?
Kyle Horimoto 2017/06/20 23:44:54 The vector stored in NetworkStateHandler is a Mana
+ std::unique_ptr<ManagedState>& tether_network_state) const;
+
+ NetworkStateHandler* network_state_handler_;
TetherHostResponseRecorder* tether_host_response_recorder_;
+ DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map_;
DISALLOW_COPY_AND_ASSIGN(HostScanDevicePrioritizer);
};

Powered by Google App Engine
This is Rietveld 408576698