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

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: hansberry@ comments. 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,
35 NotificationPresenter* notification_presenter); 33 NotificationPresenter* notification_presenter);
36 virtual ~HostScanner(); 34 virtual ~HostScanner();
37 35
38 // Starts a host scan if there is no current scan. If a scan is ongoing, this 36 // Starts a host scan if there is no current scan. If a scan is ongoing, this
39 // function is a no-op. 37 // function is a no-op.
40 virtual void StartScan(); 38 virtual void StartScan();
41 39
42 bool IsScanActive(); 40 bool IsScanActive();
43 41
44 std::vector<HostScannerOperation::ScannedDeviceInfo> 42 std::vector<HostScannerOperation::ScannedDeviceInfo>
45 most_recent_scan_results() { 43 most_recent_scan_results() {
46 return most_recent_scan_results_; 44 return most_recent_scan_results_;
47 } 45 }
48 46
49 // HostScannerOperation::Observer: 47 // HostScannerOperation::Observer:
50 void OnTetherAvailabilityResponse( 48 void OnTetherAvailabilityResponse(
51 std::vector<HostScannerOperation::ScannedDeviceInfo>& 49 std::vector<HostScannerOperation::ScannedDeviceInfo>&
52 scanned_device_list_so_far, 50 scanned_device_list_so_far,
53 bool is_final_scan_result) override; 51 bool is_final_scan_result) override;
54 52
55 private: 53 private:
56 friend class HostScannerTest; 54 friend class HostScannerTest;
55 friend class HostScanSchedulerTest;
56
57 HostScanner(TetherHostFetcher* tether_host_fetcher,
58 BleConnectionManager* connection_manager,
59 HostScanDevicePrioritizer* host_scan_device_prioritizer,
60 NetworkStateHandler* network_state_handler,
61 NotificationPresenter* notification_presenter);
stevenjb 2017/04/10 20:26:59 Don't do this. Multiple constructors are messy and
Kyle Horimoto 2017/04/11 01:40:40 Done.
57 62
58 void OnTetherHostsFetched(const cryptauth::RemoteDeviceList& tether_hosts); 63 void OnTetherHostsFetched(const cryptauth::RemoteDeviceList& tether_hosts);
59 64
60 TetherHostFetcher* tether_host_fetcher_; 65 TetherHostFetcher* tether_host_fetcher_;
61 BleConnectionManager* connection_manager_; 66 BleConnectionManager* connection_manager_;
62 HostScanDevicePrioritizer* host_scan_device_prioritizer_; 67 HostScanDevicePrioritizer* host_scan_device_prioritizer_;
63 NetworkStateHandler* network_state_handler_; 68 NetworkStateHandler* network_state_handler_;
64 NotificationPresenter* notification_presenter_; 69 NotificationPresenter* notification_presenter_;
65 70
66 bool is_fetching_hosts_; 71 bool is_fetching_hosts_;
67 std::unique_ptr<HostScannerOperation> host_scanner_operation_; 72 std::unique_ptr<HostScannerOperation> host_scanner_operation_;
68 std::vector<HostScannerOperation::ScannedDeviceInfo> 73 std::vector<HostScannerOperation::ScannedDeviceInfo>
69 most_recent_scan_results_; 74 most_recent_scan_results_;
70 75
71 base::WeakPtrFactory<HostScanner> weak_ptr_factory_; 76 base::WeakPtrFactory<HostScanner> weak_ptr_factory_;
72 77
73 DISALLOW_COPY_AND_ASSIGN(HostScanner); 78 DISALLOW_COPY_AND_ASSIGN(HostScanner);
74 }; 79 };
75 80
76 } // namespace tether 81 } // namespace tether
77 82
78 } // namespace chromeos 83 } // namespace chromeos
79 84
80 #endif // CHROMEOS_COMPONENTS_TETHER_HOST_SCANNER_H 85 #endif // CHROMEOS_COMPONENTS_TETHER_HOST_SCANNER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698