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" |
| 13 #include "chromeos/network/network_state_handler.h" |
12 #include "components/cryptauth/remote_device.h" | 14 #include "components/cryptauth/remote_device.h" |
13 | 15 |
14 namespace chromeos { | 16 namespace chromeos { |
15 | 17 |
16 namespace tether { | 18 namespace tether { |
17 | 19 |
18 class BleConnectionManager; | 20 class BleConnectionManager; |
19 class HostScanDevicePrioritizer; | 21 class HostScanDevicePrioritizer; |
20 class TetherHostFetcher; | 22 class TetherHostFetcher; |
21 | 23 |
22 // Scans for nearby tether hosts. | 24 // Scans for nearby tether hosts. |
23 // TODO(khorimoto): Add some sort of "staleness" timeout which removes scan | 25 // TODO(khorimoto): Add some sort of "staleness" timeout which removes scan |
24 // results which occurred long enough ago that they are no | 26 // results which occurred long enough ago that they are no |
25 // longer valid. | 27 // longer valid. |
26 // TODO(hansberry): Implement handling for scan results. | 28 // TODO(hansberry): Implement handling for scan results. |
27 class HostScanner : public HostScannerOperation::Observer { | 29 class HostScanner : public HostScannerOperation::Observer { |
28 public: | 30 public: |
29 HostScanner(TetherHostFetcher* tether_host_fetcher, | 31 HostScanner(TetherHostFetcher* tether_host_fetcher, |
30 BleConnectionManager* connection_manager, | 32 BleConnectionManager* connection_manager, |
31 HostScanDevicePrioritizer* host_scan_device_prioritizer); | 33 HostScanDevicePrioritizer* host_scan_device_prioritizer, |
| 34 NetworkStateHandler* network_state_handler, |
| 35 NotificationPresenter* notification_presenter); |
32 virtual ~HostScanner(); | 36 virtual ~HostScanner(); |
33 | 37 |
34 // Starts a host scan if there is no current scan. If a scan is ongoing, this | 38 // Starts a host scan if there is no current scan. If a scan is ongoing, this |
35 // function is a no-op. | 39 // function is a no-op. |
36 virtual void StartScan(); | 40 virtual void StartScan(); |
37 | 41 |
38 bool IsScanActive(); | 42 bool IsScanActive(); |
39 | 43 |
40 std::vector<HostScannerOperation::ScannedDeviceInfo> | 44 std::vector<HostScannerOperation::ScannedDeviceInfo> |
41 most_recent_scan_results() { | 45 most_recent_scan_results() { |
42 return most_recent_scan_results_; | 46 return most_recent_scan_results_; |
43 } | 47 } |
44 | 48 |
45 // HostScannerOperation::Observer: | 49 // HostScannerOperation::Observer: |
46 void OnTetherAvailabilityResponse( | 50 void OnTetherAvailabilityResponse( |
47 std::vector<HostScannerOperation::ScannedDeviceInfo>& | 51 std::vector<HostScannerOperation::ScannedDeviceInfo>& |
48 scanned_device_list_so_far, | 52 scanned_device_list_so_far, |
49 bool is_final_scan_result) override; | 53 bool is_final_scan_result) override; |
50 | 54 |
51 private: | 55 private: |
52 friend class HostScannerTest; | 56 friend class HostScannerTest; |
53 | 57 |
54 void OnTetherHostsFetched(const cryptauth::RemoteDeviceList& tether_hosts); | 58 void OnTetherHostsFetched(const cryptauth::RemoteDeviceList& tether_hosts); |
55 | 59 |
56 TetherHostFetcher* tether_host_fetcher_; | 60 TetherHostFetcher* tether_host_fetcher_; |
57 BleConnectionManager* connection_manager_; | 61 BleConnectionManager* connection_manager_; |
58 HostScanDevicePrioritizer* host_scan_device_prioritizer_; | 62 HostScanDevicePrioritizer* host_scan_device_prioritizer_; |
| 63 NetworkStateHandler* network_state_handler_; |
| 64 NotificationPresenter* notification_presenter_; |
59 | 65 |
60 bool is_fetching_hosts_; | 66 bool is_fetching_hosts_; |
61 std::unique_ptr<HostScannerOperation> host_scanner_operation_; | 67 std::unique_ptr<HostScannerOperation> host_scanner_operation_; |
62 std::vector<HostScannerOperation::ScannedDeviceInfo> | 68 std::vector<HostScannerOperation::ScannedDeviceInfo> |
63 most_recent_scan_results_; | 69 most_recent_scan_results_; |
64 | 70 |
65 base::WeakPtrFactory<HostScanner> weak_ptr_factory_; | 71 base::WeakPtrFactory<HostScanner> weak_ptr_factory_; |
66 | 72 |
67 DISALLOW_COPY_AND_ASSIGN(HostScanner); | 73 DISALLOW_COPY_AND_ASSIGN(HostScanner); |
68 }; | 74 }; |
69 | 75 |
70 } // namespace tether | 76 } // namespace tether |
71 | 77 |
72 } // namespace chromeos | 78 } // namespace chromeos |
73 | 79 |
74 #endif // CHROMEOS_COMPONENTS_TETHER_HOST_SCANNER_H | 80 #endif // CHROMEOS_COMPONENTS_TETHER_HOST_SCANNER_H |
OLD | NEW |