| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROMEOS_COMPONENTS_TETHER_HOST_SCAN_DEVICE_PRIORITIZER_H_ | 5 #ifndef CHROMEOS_COMPONENTS_TETHER_HOST_SCAN_DEVICE_PRIORITIZER_H_ |
| 6 #define CHROMEOS_COMPONENTS_TETHER_HOST_SCAN_DEVICE_PRIORITIZER_H_ | 6 #define CHROMEOS_COMPONENTS_TETHER_HOST_SCAN_DEVICE_PRIORITIZER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "components/cryptauth/remote_device.h" | 9 #include "components/cryptauth/remote_device.h" |
| 10 | 10 |
| 11 namespace chromeos { | 11 namespace chromeos { |
| 12 | 12 |
| 13 namespace tether { | 13 namespace tether { |
| 14 | 14 |
| 15 class TetherHostResponseRecorder; | |
| 16 | |
| 17 // Prioritizes the order of devices when performing a host scan. To optimize for | 15 // Prioritizes the order of devices when performing a host scan. To optimize for |
| 18 // the most common tethering operations, this class uses the following rules: | 16 // the most common tethering operations, this class uses the following rules: |
| 19 // * The device which has most recently sent a successful | 17 // * The device which has most recently sent a successful |
| 20 // ConnectTetheringResponse is always at the front of the queue. | 18 // ConnectTetheringResponse is always at the front of the queue. |
| 21 // * Devices which have most recently sent a successful | 19 // * Devices which have most recently sent a successful |
| 22 // TetherAvailabilityResponse are next in the order, as long as they do not | 20 // TetherAvailabilityResponse are next in the order, as long as they do not |
| 23 // violate the first rule. | 21 // violate the first rule. |
| 24 // * All other devices are left in the order they are passed. | 22 // * All other devices are left in the order they are passed. |
| 25 class HostScanDevicePrioritizer { | 23 class HostScanDevicePrioritizer { |
| 26 public: | 24 public: |
| 27 HostScanDevicePrioritizer( | 25 HostScanDevicePrioritizer() {} |
| 28 TetherHostResponseRecorder* tether_host_response_recorder); | 26 virtual ~HostScanDevicePrioritizer() {} |
| 29 virtual ~HostScanDevicePrioritizer(); | |
| 30 | 27 |
| 31 // Prioritizes |remote_devices| using the rules described above. | 28 // Prioritizes |remote_devices| using the rules described above. |
| 32 virtual void SortByHostScanOrder( | 29 virtual void SortByHostScanOrder( |
| 33 std::vector<cryptauth::RemoteDevice>* remote_devices) const; | 30 std::vector<cryptauth::RemoteDevice>* remote_devices) const = 0; |
| 34 | 31 |
| 35 private: | 32 private: |
| 36 TetherHostResponseRecorder* tether_host_response_recorder_; | |
| 37 | |
| 38 DISALLOW_COPY_AND_ASSIGN(HostScanDevicePrioritizer); | 33 DISALLOW_COPY_AND_ASSIGN(HostScanDevicePrioritizer); |
| 39 }; | 34 }; |
| 40 | 35 |
| 41 } // namespace tether | 36 } // namespace tether |
| 42 | 37 |
| 43 } // namespace chromeos | 38 } // namespace chromeos |
| 44 | 39 |
| 45 #endif // CHROMEOS_COMPONENTS_TETHER_HOST_SCAN_DEVICE_PRIORITIZER_H_ | 40 #endif // CHROMEOS_COMPONENTS_TETHER_HOST_SCAN_DEVICE_PRIORITIZER_H_ |
| OLD | NEW |