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

Side by Side Diff: chromeos/components/tether/host_scanner.h

Issue 2801353002: [CrOS Tether] Fill out the Initializer class. Tether will now initialize fully once the flag is ena… (Closed)
Patch Set: Added missing dep. Created 3 years, 8 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 unified diff | Download patch
OLDNEW
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 HostScanDevicePrioritizer; 21 class HostScanDevicePrioritizer;
22 class TetherHostFetcher; 22 class TetherHostFetcher;
23 23
24 // Scans for nearby tether hosts. 24 // Scans for nearby tether hosts.
25 // TODO(khorimoto): Add some sort of "staleness" timeout which removes scan 25 // TODO(khorimoto): Add some sort of "staleness" timeout which removes scan
26 // results which occurred long enough ago that they are no 26 // results which occurred long enough ago that they are no
27 // longer valid. 27 // longer valid.
28 // TODO(hansberry): Implement handling for scan results.
29 class HostScanner : public HostScannerOperation::Observer { 28 class HostScanner : public HostScannerOperation::Observer {
30 public: 29 public:
31 HostScanner(TetherHostFetcher* tether_host_fetcher, 30 HostScanner(TetherHostFetcher* tether_host_fetcher,
32 BleConnectionManager* connection_manager, 31 BleConnectionManager* connection_manager,
33 HostScanDevicePrioritizer* host_scan_device_prioritizer, 32 HostScanDevicePrioritizer* host_scan_device_prioritizer,
34 NetworkStateHandler* network_state_handler, 33 NetworkStateHandler* network_state_handler,
35 NotificationPresenter* notification_presenter); 34 NotificationPresenter* notification_presenter);
36 virtual ~HostScanner(); 35 virtual ~HostScanner();
37 36
38 // Starts a host scan if there is no current scan. If a scan is ongoing, this 37 // Starts a host scan if there is no current scan. If a scan is ongoing, this
39 // function is a no-op. 38 // function is a no-op.
40 virtual void StartScan(); 39 virtual void StartScan();
41 40
42 bool IsScanActive(); 41 bool IsScanActive();
43 42
44 std::vector<HostScannerOperation::ScannedDeviceInfo> 43 std::vector<HostScannerOperation::ScannedDeviceInfo>
45 most_recent_scan_results() { 44 most_recent_scan_results() {
46 return most_recent_scan_results_; 45 return most_recent_scan_results_;
47 } 46 }
48 47
49 // HostScannerOperation::Observer: 48 // HostScannerOperation::Observer:
50 void OnTetherAvailabilityResponse( 49 void OnTetherAvailabilityResponse(
51 std::vector<HostScannerOperation::ScannedDeviceInfo>& 50 std::vector<HostScannerOperation::ScannedDeviceInfo>&
52 scanned_device_list_so_far, 51 scanned_device_list_so_far,
53 bool is_final_scan_result) override; 52 bool is_final_scan_result) override;
54 53
55 private: 54 private:
56 friend class HostScannerTest; 55 friend class HostScannerTest;
56 friend class HostScanSchedulerTest;
57 57
58 void OnTetherHostsFetched(const cryptauth::RemoteDeviceList& tether_hosts); 58 void OnTetherHostsFetched(const cryptauth::RemoteDeviceList& tether_hosts);
59 59
60 TetherHostFetcher* tether_host_fetcher_; 60 TetherHostFetcher* tether_host_fetcher_;
61 BleConnectionManager* connection_manager_; 61 BleConnectionManager* connection_manager_;
62 HostScanDevicePrioritizer* host_scan_device_prioritizer_; 62 HostScanDevicePrioritizer* host_scan_device_prioritizer_;
63 NetworkStateHandler* network_state_handler_; 63 NetworkStateHandler* network_state_handler_;
64 NotificationPresenter* notification_presenter_; 64 NotificationPresenter* notification_presenter_;
65 65
66 bool is_fetching_hosts_; 66 bool is_fetching_hosts_;
67 std::unique_ptr<HostScannerOperation> host_scanner_operation_; 67 std::unique_ptr<HostScannerOperation> host_scanner_operation_;
68 std::vector<HostScannerOperation::ScannedDeviceInfo> 68 std::vector<HostScannerOperation::ScannedDeviceInfo>
69 most_recent_scan_results_; 69 most_recent_scan_results_;
70 70
71 base::WeakPtrFactory<HostScanner> weak_ptr_factory_; 71 base::WeakPtrFactory<HostScanner> weak_ptr_factory_;
72 72
73 DISALLOW_COPY_AND_ASSIGN(HostScanner); 73 DISALLOW_COPY_AND_ASSIGN(HostScanner);
74 }; 74 };
75 75
76 } // namespace tether 76 } // namespace tether
77 77
78 } // namespace chromeos 78 } // namespace chromeos
79 79
80 #endif // CHROMEOS_COMPONENTS_TETHER_HOST_SCANNER_H 80 #endif // CHROMEOS_COMPONENTS_TETHER_HOST_SCANNER_H_
OLDNEW
« no previous file with comments | « chromeos/components/tether/fake_tether_host_fetcher.cc ('k') | chromeos/components/tether/host_scanner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698