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

Side by Side Diff: chromeos/components/tether/fake_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
« no previous file with comments | « no previous file | chromeos/components/tether/fake_host_scan_cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_FAKE_HOST_SCAN_CACHE_H_ 5 #ifndef CHROMEOS_COMPONENTS_TETHER_FAKE_HOST_SCAN_CACHE_H_
6 #define CHROMEOS_COMPONENTS_TETHER_FAKE_HOST_SCAN_CACHE_H_ 6 #define CHROMEOS_COMPONENTS_TETHER_FAKE_HOST_SCAN_CACHE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <unordered_map> 9 #include <unordered_map>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "chromeos/components/tether/host_scan_cache.h" 12 #include "chromeos/components/tether/host_scan_cache.h"
13 13
14 namespace chromeos { 14 namespace chromeos {
15 15
16 namespace tether { 16 namespace tether {
17 17
18 // Test double for HostScanCache which stores cache results in memory. 18 // Test double for HostScanCache which stores cache results in memory.
19 class FakeHostScanCache : public HostScanCache { 19 class FakeHostScanCache : public HostScanCache {
20 public: 20 public:
21 struct CacheEntry { 21 struct CacheEntry {
22 std::string device_name; 22 std::string device_name;
23 std::string carrier; 23 std::string carrier;
24 int battery_percentage; 24 int battery_percentage;
25 int signal_strength; 25 int signal_strength;
26 bool setup_required;
26 }; 27 };
27 28
28 FakeHostScanCache(); 29 FakeHostScanCache();
29 ~FakeHostScanCache() override; 30 ~FakeHostScanCache() override;
30 31
31 // Getter and setter for the active host Tether network GUID. This value is 32 // Getter and setter for the active host Tether network GUID. This value is
32 // used to implement the ClearCacheExceptForActiveHost() function. 33 // used to implement the ClearCacheExceptForActiveHost() function.
33 std::string& active_host_tether_network_guid() { 34 std::string& active_host_tether_network_guid() {
34 return active_host_tether_network_guid_; 35 return active_host_tether_network_guid_;
35 } 36 }
36 void set_active_host_tether_network_guid( 37 void set_active_host_tether_network_guid(
37 const std::string& active_host_tether_network_guid) { 38 const std::string& active_host_tether_network_guid) {
38 active_host_tether_network_guid_ = active_host_tether_network_guid; 39 active_host_tether_network_guid_ = active_host_tether_network_guid;
39 } 40 }
40 41
41 // Getters for contents of the cache. 42 // Getters for contents of the cache.
42 const FakeHostScanCache::CacheEntry* GetCacheEntry( 43 const FakeHostScanCache::CacheEntry* GetCacheEntry(
43 const std::string& tether_network_guid); 44 const std::string& tether_network_guid);
44 size_t size() { return cache_.size(); } 45 size_t size() { return cache_.size(); }
45 bool empty() { return cache_.empty(); } 46 bool empty() { return cache_.empty(); }
46 const std::unordered_map<std::string, FakeHostScanCache::CacheEntry> cache() { 47 const std::unordered_map<std::string, FakeHostScanCache::CacheEntry> cache() {
47 return cache_; 48 return cache_;
48 } 49 }
49 50
50 // HostScanCache: 51 // HostScanCache:
51 void SetHostScanResult(const std::string& tether_network_guid, 52 void SetHostScanResult(const std::string& tether_network_guid,
52 const std::string& device_name, 53 const std::string& device_name,
53 const std::string& carrier, 54 const std::string& carrier,
54 int battery_percentage, 55 int battery_percentage,
55 int signal_strength) override; 56 int signal_strength,
57 bool setup_required) override;
56 bool RemoveHostScanResult(const std::string& tether_network_guid) override; 58 bool RemoveHostScanResult(const std::string& tether_network_guid) override;
57 void ClearCacheExceptForActiveHost() override; 59 void ClearCacheExceptForActiveHost() override;
60 bool DoesHostRequireSetup(const std::string& tether_network_guid) override;
58 void OnPreviouslyConnectedHostIdsChanged() override; 61 void OnPreviouslyConnectedHostIdsChanged() override;
59 62
60 private: 63 private:
61 std::string active_host_tether_network_guid_; 64 std::string active_host_tether_network_guid_;
62 std::unordered_map<std::string, CacheEntry> cache_; 65 std::unordered_map<std::string, CacheEntry> cache_;
63 66
64 DISALLOW_COPY_AND_ASSIGN(FakeHostScanCache); 67 DISALLOW_COPY_AND_ASSIGN(FakeHostScanCache);
65 }; 68 };
66 69
67 } // namespace tether 70 } // namespace tether
68 71
69 } // namespace chromeos 72 } // namespace chromeos
70 73
71 #endif // CHROMEOS_COMPONENTS_TETHER_FAKE_HOST_SCAN_CACHE_H_ 74 #endif // CHROMEOS_COMPONENTS_TETHER_FAKE_HOST_SCAN_CACHE_H_
OLDNEW
« no previous file with comments | « no previous file | chromeos/components/tether/fake_host_scan_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698