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

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

Issue 2913313002: Tether: Persist if first-time setup is required to HostScanCache. (Closed)
Patch Set: khorimoto@ comments. Created 3 years, 6 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 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_CACHE_H_ 5 #ifndef CHROMEOS_COMPONENTS_TETHER_HOST_SCAN_CACHE_H_
6 #define CHROMEOS_COMPONENTS_TETHER_HOST_SCAN_CACHE_H_ 6 #define CHROMEOS_COMPONENTS_TETHER_HOST_SCAN_CACHE_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <unordered_map> 9 #include <unordered_map>
10 10
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 // Updates the cache to include this scan result. If no scan result for 51 // Updates the cache to include this scan result. If no scan result for
52 // |tether_network_guid| exists in the cache, a scan result will be added; 52 // |tether_network_guid| exists in the cache, a scan result will be added;
53 // if a scan result is already present, it is updated with the new data 53 // if a scan result is already present, it is updated with the new data
54 // provided as parameters to this function. Once scan results have been 54 // provided as parameters to this function. Once scan results have been
55 // updated, a timer starts counting down |kNumMinutesBeforeCacheEntryExpires| 55 // updated, a timer starts counting down |kNumMinutesBeforeCacheEntryExpires|
56 // minutes. Once the timer fires, the scan result is automatically removed 56 // minutes. Once the timer fires, the scan result is automatically removed
57 // from the cache unless it corresponds to the active host. 57 // from the cache unless it corresponds to the active host.
58 // Note: |signal_strength| should be in the range [0, 100]. This is different 58 // Note: |signal_strength| should be in the range [0, 100]. This is different
59 // from the |connection_strength| field received in ConnectTetheringResponse 59 // from the |connection_strength| field received in ConnectTetheringResponse
60 // and KeepAliveTickleResponse messages (the range is [0, 4] in those cases). 60 // and KeepAliveTickleResponse messages (the range is [0, 4] in those cases).
61 // |battery_percentage| should also be in the range [0, 100].
62 // |setup_required| indicates that the host device requires first-time setup,
63 // i.e., user interaction to allow tethering.
61 virtual void SetHostScanResult(const std::string& tether_network_guid, 64 virtual void SetHostScanResult(const std::string& tether_network_guid,
62 const std::string& device_name, 65 const std::string& device_name,
63 const std::string& carrier, 66 const std::string& carrier,
64 int battery_percentage, 67 int battery_percentage,
65 int signal_strength); 68 int signal_strength,
69 bool setup_required);
66 70
67 // Removes the scan result with GUID |tether_network_guid| from the cache. If 71 // Removes the scan result with GUID |tether_network_guid| from the cache. If
68 // no cache result with that GUID was present in the cache, this function is 72 // no cache result with that GUID was present in the cache, this function is
69 // a no-op. Returns whether a scan result was actually removed. 73 // a no-op. Returns whether a scan result was actually removed.
70 virtual bool RemoveHostScanResult(const std::string& tether_network_guid); 74 virtual bool RemoveHostScanResult(const std::string& tether_network_guid);
71 75
72 // Removes all scan results from the cache unless they correspond to the 76 // Removes all scan results from the cache unless they correspond to the
73 // active host; the active host must always remain in the cache while 77 // active host; the active host must always remain in the cache while
74 // connecting/connected to ensure the UI is up to date. 78 // connecting/connected to ensure the UI is up to date.
75 virtual void ClearCacheExceptForActiveHost(); 79 virtual void ClearCacheExceptForActiveHost();
76 80
81 // Returns true if the host device requires first-time setup, i.e., user
82 // interaction to allow tethering.
83 virtual bool DoesHostRequireSetup(const std::string& tether_network_guid);
84
77 // TetherHostResponseRecorder::Observer: 85 // TetherHostResponseRecorder::Observer:
78 void OnPreviouslyConnectedHostIdsChanged() override; 86 void OnPreviouslyConnectedHostIdsChanged() override;
79 87
80 private: 88 private:
81 friend class HostScanCacheTest; 89 friend class HostScanCacheTest;
82 90
83 void SetTimerFactoryForTest( 91 void SetTimerFactoryForTest(
84 std::unique_ptr<TimerFactory> timer_factory_for_test); 92 std::unique_ptr<TimerFactory> timer_factory_for_test);
85 93
86 bool HasConnectedToHost(const std::string& tether_network_guid); 94 bool HasConnectedToHost(const std::string& tether_network_guid);
87 void StartTimer(const std::string& tether_network_guid); 95 void StartTimer(const std::string& tether_network_guid);
88 void OnTimerFired(const std::string& tether_network_guid); 96 void OnTimerFired(const std::string& tether_network_guid);
89 97
90 std::unique_ptr<TimerFactory> timer_factory_; 98 std::unique_ptr<TimerFactory> timer_factory_;
91 NetworkStateHandler* network_state_handler_; 99 NetworkStateHandler* network_state_handler_;
92 ActiveHost* active_host_; 100 ActiveHost* active_host_;
93 TetherHostResponseRecorder* tether_host_response_recorder_; 101 TetherHostResponseRecorder* tether_host_response_recorder_;
94 DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map_; 102 DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map_;
95 103
96 // Maps from the Tether network GUID to a Timer object. While a scan result is 104 // Maps from the Tether network GUID to a Timer object. While a scan result is
97 // active in the cache, the corresponding Timer object starts running; if the 105 // active in the cache, the corresponding Timer object starts running; if the
98 // timer fires, the result is removed (unless it corresponds to the active 106 // timer fires, the result is removed (unless it corresponds to the active
99 // host). 107 // host).
100 std::unordered_map<std::string, std::unique_ptr<base::Timer>> 108 std::unordered_map<std::string, std::unique_ptr<base::Timer>>
101 tether_guid_to_timer_map_; 109 tether_guid_to_timer_map_;
110 std::unordered_set<std::string> setup_required_tether_guids_;
102 base::WeakPtrFactory<HostScanCache> weak_ptr_factory_; 111 base::WeakPtrFactory<HostScanCache> weak_ptr_factory_;
103 112
104 DISALLOW_COPY_AND_ASSIGN(HostScanCache); 113 DISALLOW_COPY_AND_ASSIGN(HostScanCache);
105 }; 114 };
106 115
107 } // namespace tether 116 } // namespace tether
108 117
109 } // namespace chromeos 118 } // namespace chromeos
110 119
111 #endif // CHROMEOS_COMPONENTS_TETHER_HOST_SCAN_CACHE_H_ 120 #endif // CHROMEOS_COMPONENTS_TETHER_HOST_SCAN_CACHE_H_
OLDNEW
« no previous file with comments | « chromeos/components/tether/fake_host_scan_cache.cc ('k') | chromeos/components/tether/host_scan_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698