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

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

Issue 2945643002: [CrOS Tether] Sort Tether network lists. (Closed)
Patch Set: stevenjb@ comments. 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_impl.h
diff --git a/chromeos/components/tether/host_scan_device_prioritizer_impl.h b/chromeos/components/tether/host_scan_device_prioritizer_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..b02b131d569a5cc8b2ada1501322f071f6fe21da
--- /dev/null
+++ b/chromeos/components/tether/host_scan_device_prioritizer_impl.h
@@ -0,0 +1,60 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROMEOS_COMPONENTS_TETHER_HOST_SCAN_DEVICE_PRIORITIZER_IMPL_H_
+#define CHROMEOS_COMPONENTS_TETHER_HOST_SCAN_DEVICE_PRIORITIZER_IMPL_H_
+
+#include "base/macros.h"
+#include "chromeos/components/tether/host_scan_device_prioritizer.h"
+#include "chromeos/network/network_state_handler.h"
+#include "components/cryptauth/remote_device.h"
+
+namespace chromeos {
+
+class NetworkStateHandler;
+
+namespace tether {
+
+class TetherHostResponseRecorder;
+class DeviceIdTetherNetworkGuidMap;
+
+// Implementation of HostScanDevicePrioritizer.
+class HostScanDevicePrioritizerImpl
+ : public HostScanDevicePrioritizer,
+ public NetworkStateHandler::TetherSortDelegate {
+ public:
+ HostScanDevicePrioritizerImpl(
+ TetherHostResponseRecorder* tether_host_response_recorder,
+ DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map);
+ ~HostScanDevicePrioritizerImpl() override;
+
+ // HostScanDevicePrioritizer:
+ void SortByHostScanOrder(
+ std::vector<cryptauth::RemoteDevice>* remote_devices) const override;
+
+ // 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;
+
+ std::string GetDeviceId(const cryptauth::RemoteDevice& remote_device) const;
+ std::string GetDeviceId(
+ const std::unique_ptr<ManagedState>& tether_network_state) const;
+
+ TetherHostResponseRecorder* tether_host_response_recorder_;
+ DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map_;
+
+ DISALLOW_COPY_AND_ASSIGN(HostScanDevicePrioritizerImpl);
+};
+
+} // namespace tether
+
+} // namespace chromeos
+
+#endif // CHROMEOS_COMPONENTS_TETHER_HOST_SCAN_DEVICE_PRIORITIZER_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698