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

Unified Diff: chromeos/network/network_state_handler.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/network/network_state_handler.h
diff --git a/chromeos/network/network_state_handler.h b/chromeos/network/network_state_handler.h
index d695b40186a6ce12f9f59ee5e9654933304b9435..5cfc503ce03f98a946799279872ba5c0ada8b8ec 100644
--- a/chromeos/network/network_state_handler.h
+++ b/chromeos/network/network_state_handler.h
@@ -69,6 +69,16 @@ class CHROMEOS_EXPORT NetworkStateHandler
typedef std::vector<const NetworkState*> NetworkStateList;
typedef std::vector<const DeviceState*> DeviceStateList;
+ // Sorts Tether networks. Because sorting rules are determined by the Tether
+ // component, a delegate is required to sort the list.
+ class TetherNetworkListSorter {
+ public:
+ // Sorts the list so that the highest-priority networks are in the front of
+ // the list.
+ virtual void SortTetherNetworkList(
+ ManagedStateList* tether_networks) const = 0;
Ryan Hansberry 2017/06/19 19:17:49 Why ManagedState and not NetworkState?
Kyle Horimoto 2017/06/20 23:44:54 tether_network_list_ is a ManagedStateList.
+ };
+
enum TechnologyState {
TECHNOLOGY_UNAVAILABLE,
TECHNOLOGY_AVAILABLE,
@@ -267,6 +277,10 @@ class CHROMEOS_EXPORT NetworkStateHandler
// provided |guid| to "Connected". This will be reflected in the UI.
void SetTetherNetworkStateConnected(const std::string& guid);
+ // Sets the sorting delegate for Tether networks.
+ void SetTetherNetworkListSorter(
+ const TetherNetworkListSorter* tether_network_list_sorter);
+
// Sets |list| to contain the list of devices. The returned list contains
// a copy of DeviceState pointers which should not be stored or used beyond
// the scope of the calling function (i.e. they may later become invalid, but
@@ -523,6 +537,9 @@ class CHROMEOS_EXPORT NetworkStateHandler
TechnologyState tether_technology_state_ =
TechnologyState::TECHNOLOGY_UNAVAILABLE;
+ // Not owned by this instance.
+ const TetherNetworkListSorter* tether_network_list_sorter_ = nullptr;
+
// Ensure that Shutdown() gets called exactly once.
bool did_shutdown_ = false;

Powered by Google App Engine
This is Rietveld 408576698