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

Unified Diff: chromeos/components/tether/tether_host_response_recorder.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
Index: chromeos/components/tether/tether_host_response_recorder.h
diff --git a/chromeos/components/tether/tether_host_response_recorder.h b/chromeos/components/tether/tether_host_response_recorder.h
index f87dd936ccc7777b3ef6aa67c41d0b0069739955..fed179e8c1dc0300fd5b6cb330452ddf5f00b9b9 100644
--- a/chromeos/components/tether/tether_host_response_recorder.h
+++ b/chromeos/components/tether/tether_host_response_recorder.h
@@ -9,6 +9,7 @@
#include <vector>
#include "base/macros.h"
+#include "base/observer_list.h"
#include "components/cryptauth/remote_device.h"
class PrefService;
@@ -24,15 +25,23 @@ namespace tether {
// Responses can be retrieved at a later time via getter methods.
class TetherHostResponseRecorder {
public:
- // Note: The PrefService* passed here must be created using the same registry
- // passed to RegisterPrefs().
- TetherHostResponseRecorder(PrefService* pref_service);
- virtual ~TetherHostResponseRecorder();
+ class Observer {
+ public:
+ virtual void OnPreviouslyConnectedHostIdsChanged() = 0;
+ };
// Registers the prefs used by this class to |registry|. Must be called before
// this class is utilized.
static void RegisterPrefs(PrefRegistrySimple* registry);
+ // Note: The PrefService* passed here must be created using the same registry
+ // passed to RegisterPrefs().
+ explicit TetherHostResponseRecorder(PrefService* pref_service);
+ virtual ~TetherHostResponseRecorder();
+
+ void AddObserver(Observer* observer);
+ void RemoveObserver(Observer* observer);
+
// Records a TetherAvailabilityResponse. This function should be called each
// time that a response is received from a potential host, even if a
// connection is not started.
@@ -60,12 +69,18 @@ class TetherHostResponseRecorder {
virtual std::vector<std::string> GetPreviouslyConnectedHostIds() const;
private:
- void AddRecentResponse(const std::string& device_id,
+ friend class HostScanCacheTest;
+
+ void NotifyObserversPreviouslyConnectedHostIdsChanged();
+
+ // Returns whether the list was changed due to adding the response.
+ bool AddRecentResponse(const std::string& device_id,
const std::string& pref_name);
std::vector<std::string> GetDeviceIdsForPref(
const std::string& pref_name) const;
PrefService* pref_service_;
+ base::ObserverList<Observer> observer_list_;
DISALLOW_COPY_AND_ASSIGN(TetherHostResponseRecorder);
};
« no previous file with comments | « chromeos/components/tether/initializer.cc ('k') | chromeos/components/tether/tether_host_response_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698