OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_SCANNER_H_ | 5 #ifndef CHROMEOS_COMPONENTS_TETHER_HOST_SCANNER_H_ |
6 #define CHROMEOS_COMPONENTS_TETHER_HOST_SCANNER_H_ | 6 #define CHROMEOS_COMPONENTS_TETHER_HOST_SCANNER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "chromeos/components/tether/host_scanner_operation.h" | 11 #include "chromeos/components/tether/host_scanner_operation.h" |
12 #include "chromeos/components/tether/notification_presenter.h" | 12 #include "chromeos/components/tether/notification_presenter.h" |
13 #include "chromeos/network/network_state_handler.h" | 13 #include "chromeos/network/network_state_handler.h" |
14 #include "components/cryptauth/remote_device.h" | 14 #include "components/cryptauth/remote_device.h" |
15 | 15 |
16 namespace chromeos { | 16 namespace chromeos { |
17 | 17 |
18 namespace tether { | 18 namespace tether { |
19 | 19 |
20 class BleConnectionManager; | 20 class BleConnectionManager; |
21 class DeviceIdTetherNetworkGuidMap; | 21 class DeviceIdTetherNetworkGuidMap; |
22 class HostScanDevicePrioritizer; | 22 class HostScanDevicePrioritizer; |
23 class TetherHostFetcher; | 23 class TetherHostFetcher; |
| 24 class TetherHostResponseRecorder; |
24 | 25 |
25 // Scans for nearby tether hosts. | 26 // Scans for nearby tether hosts. |
26 // TODO(khorimoto): Add some sort of "staleness" timeout which removes scan | 27 // TODO(khorimoto): Add some sort of "staleness" timeout which removes scan |
27 // results which occurred long enough ago that they are no | 28 // results which occurred long enough ago that they are no |
28 // longer valid. | 29 // longer valid. |
29 class HostScanner : public HostScannerOperation::Observer { | 30 class HostScanner : public HostScannerOperation::Observer { |
30 public: | 31 public: |
31 HostScanner(TetherHostFetcher* tether_host_fetcher, | 32 HostScanner(TetherHostFetcher* tether_host_fetcher, |
32 BleConnectionManager* connection_manager, | 33 BleConnectionManager* connection_manager, |
33 HostScanDevicePrioritizer* host_scan_device_prioritizer, | 34 HostScanDevicePrioritizer* host_scan_device_prioritizer, |
| 35 TetherHostResponseRecorder* tether_host_response_recorder, |
34 NetworkStateHandler* network_state_handler, | 36 NetworkStateHandler* network_state_handler, |
35 NotificationPresenter* notification_presenter, | 37 NotificationPresenter* notification_presenter, |
36 DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map); | 38 DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map); |
37 virtual ~HostScanner(); | 39 virtual ~HostScanner(); |
38 | 40 |
39 // Starts a host scan if there is no current scan. If a scan is ongoing, this | 41 // Starts a host scan if there is no current scan. If a scan is ongoing, this |
40 // function is a no-op. | 42 // function is a no-op. |
41 virtual void StartScan(); | 43 virtual void StartScan(); |
42 | 44 |
43 bool IsScanActive(); | 45 bool IsScanActive(); |
(...skipping 11 matching lines...) Expand all Loading... |
55 | 57 |
56 private: | 58 private: |
57 friend class HostScannerTest; | 59 friend class HostScannerTest; |
58 friend class HostScanSchedulerTest; | 60 friend class HostScanSchedulerTest; |
59 | 61 |
60 void OnTetherHostsFetched(const cryptauth::RemoteDeviceList& tether_hosts); | 62 void OnTetherHostsFetched(const cryptauth::RemoteDeviceList& tether_hosts); |
61 | 63 |
62 TetherHostFetcher* tether_host_fetcher_; | 64 TetherHostFetcher* tether_host_fetcher_; |
63 BleConnectionManager* connection_manager_; | 65 BleConnectionManager* connection_manager_; |
64 HostScanDevicePrioritizer* host_scan_device_prioritizer_; | 66 HostScanDevicePrioritizer* host_scan_device_prioritizer_; |
| 67 TetherHostResponseRecorder* tether_host_response_recorder_; |
65 NetworkStateHandler* network_state_handler_; | 68 NetworkStateHandler* network_state_handler_; |
66 NotificationPresenter* notification_presenter_; | 69 NotificationPresenter* notification_presenter_; |
67 DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map_; | 70 DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map_; |
68 | 71 |
69 bool is_fetching_hosts_; | 72 bool is_fetching_hosts_; |
70 std::unique_ptr<HostScannerOperation> host_scanner_operation_; | 73 std::unique_ptr<HostScannerOperation> host_scanner_operation_; |
71 std::vector<HostScannerOperation::ScannedDeviceInfo> | 74 std::vector<HostScannerOperation::ScannedDeviceInfo> |
72 most_recent_scan_results_; | 75 most_recent_scan_results_; |
73 | 76 |
74 base::WeakPtrFactory<HostScanner> weak_ptr_factory_; | 77 base::WeakPtrFactory<HostScanner> weak_ptr_factory_; |
75 | 78 |
76 DISALLOW_COPY_AND_ASSIGN(HostScanner); | 79 DISALLOW_COPY_AND_ASSIGN(HostScanner); |
77 }; | 80 }; |
78 | 81 |
79 } // namespace tether | 82 } // namespace tether |
80 | 83 |
81 } // namespace chromeos | 84 } // namespace chromeos |
82 | 85 |
83 #endif // CHROMEOS_COMPONENTS_TETHER_HOST_SCANNER_H_ | 86 #endif // CHROMEOS_COMPONENTS_TETHER_HOST_SCANNER_H_ |
OLD | NEW |