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

Unified Diff: chromeos/components/tether/fake_host_scan_cache.h

Issue 2852693004: [CrOS Tether] Create HostScanCache, which caches scan results and inserts them into the network sta… (Closed)
Patch Set: stevenjb@ 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/components/tether/BUILD.gn ('k') | chromeos/components/tether/fake_host_scan_cache.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/components/tether/fake_host_scan_cache.h
diff --git a/chromeos/components/tether/fake_host_scan_cache.h b/chromeos/components/tether/fake_host_scan_cache.h
new file mode 100644
index 0000000000000000000000000000000000000000..1b390187e164cc9b89aad7522fc95de53d80506f
--- /dev/null
+++ b/chromeos/components/tether/fake_host_scan_cache.h
@@ -0,0 +1,71 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROMEOS_COMPONENTS_TETHER_FAKE_HOST_SCAN_CACHE_H_
+#define CHROMEOS_COMPONENTS_TETHER_FAKE_HOST_SCAN_CACHE_H_
+
+#include <string>
+#include <unordered_map>
+
+#include "base/macros.h"
+#include "chromeos/components/tether/host_scan_cache.h"
+
+namespace chromeos {
+
+namespace tether {
+
+// Test double for HostScanCache which stores cache results in memory.
+class FakeHostScanCache : public HostScanCache {
+ public:
+ struct CacheEntry {
+ std::string device_name;
+ std::string carrier;
+ int battery_percentage;
+ int signal_strength;
+ };
+
+ FakeHostScanCache();
+ ~FakeHostScanCache() override;
+
+ // Getter and setter for the active host Tether network GUID. This value is
+ // used to implement the ClearCacheExceptForActiveHost() function.
+ std::string& active_host_tether_network_guid() {
+ return active_host_tether_network_guid_;
+ }
+ void set_active_host_tether_network_guid(
+ const std::string& active_host_tether_network_guid) {
+ active_host_tether_network_guid_ = active_host_tether_network_guid;
+ }
+
+ // Getters for contents of the cache.
+ const FakeHostScanCache::CacheEntry* GetCacheEntry(
+ const std::string& tether_network_guid);
+ size_t size() { return cache_.size(); }
+ bool empty() { return cache_.empty(); }
+ const std::unordered_map<std::string, FakeHostScanCache::CacheEntry> cache() {
+ return cache_;
+ }
+
+ // HostScanCache:
+ void SetHostScanResult(const std::string& tether_network_guid,
+ const std::string& device_name,
+ const std::string& carrier,
+ int battery_percentage,
+ int signal_strength) override;
+ bool RemoveHostScanResult(const std::string& tether_network_guid) override;
+ void ClearCacheExceptForActiveHost() override;
+ void OnPreviouslyConnectedHostIdsChanged() override;
+
+ private:
+ std::string active_host_tether_network_guid_;
+ std::unordered_map<std::string, CacheEntry> cache_;
+
+ DISALLOW_COPY_AND_ASSIGN(FakeHostScanCache);
+};
+
+} // namespace tether
+
+} // namespace chromeos
+
+#endif // CHROMEOS_COMPONENTS_TETHER_FAKE_HOST_SCAN_CACHE_H_
« no previous file with comments | « chromeos/components/tether/BUILD.gn ('k') | chromeos/components/tether/fake_host_scan_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698