Chromium Code Reviews| Index: net/nqe/network_qualities_prefs_manager.h |
| diff --git a/net/nqe/network_qualities_prefs_manager.h b/net/nqe/network_qualities_prefs_manager.h |
| index 9978409606843d1e3d4a0b866ba69932e2bd0674..195ca7152372feab108ef87f7a700edbe809a891 100644 |
| --- a/net/nqe/network_qualities_prefs_manager.h |
| +++ b/net/nqe/network_qualities_prefs_manager.h |
| @@ -5,26 +5,23 @@ |
| #ifndef NET_NQE_NETWORK_QUALITIES_PREFS_MANAGER_H_ |
| #define NET_NQE_NETWORK_QUALITIES_PREFS_MANAGER_H_ |
| +#include <map> |
| #include <memory> |
| #include "base/macros.h" |
| #include "base/memory/weak_ptr.h" |
| +#include "base/values.h" |
| #include "net/base/net_export.h" |
| +#include "net/nqe/cached_network_quality.h" |
| #include "net/nqe/effective_connection_type.h" |
| #include "net/nqe/network_id.h" |
| #include "net/nqe/network_quality_store.h" |
| namespace base { |
| -class DictionaryValue; |
| class SequencedTaskRunner; |
| } |
| namespace net { |
| -namespace nqe { |
| -namespace internal { |
| -class CachedNetworkQuality; |
| -} |
| -} |
| class NetworkQualityEstimator; |
| typedef base::Callback<void( |
| @@ -48,8 +45,13 @@ class NET_EXPORT NetworkQualitiesPrefsManager |
| // Provides an interface that must be implemented by the embedder. |
| class NET_EXPORT PrefDelegate { |
| public: |
| + virtual ~PrefDelegate() {} |
| + |
| // Sets the persistent pref to the given value. |
| virtual void SetDictionaryValue(const base::DictionaryValue& value) = 0; |
| + |
| + // Returns the peristent prefs. |
| + virtual const base::DictionaryValue& GetDictionaryValue() = 0; |
| }; |
| // Creates an instance of the NetworkQualitiesPrefsManager. Ownership of |
| @@ -66,6 +68,11 @@ class NET_EXPORT NetworkQualitiesPrefsManager |
| // Prepare for shutdown. Must be called on the pref thread before destruction. |
| void ShutdownOnPrefThread(); |
| + // Reads the prefs again, parses them into a map of NetworkIDs and |
| + // CachedNetworkQualities, and returns the map. |
| + std::map<nqe::internal::NetworkID, nqe::internal::CachedNetworkQuality> |
|
bengr
2016/10/14 22:37:13
It might be a little more readable to typedef this
tbansal1
2016/10/14 23:25:53
Done.
|
| + ForceReadPrefsForTesting() const; |
| + |
| private: |
| // Pref thread members: |
| // Called on pref thread when there is a change in the cached network quality. |
| @@ -78,6 +85,9 @@ class NET_EXPORT NetworkQualitiesPrefsManager |
| scoped_refptr<base::SequencedTaskRunner> pref_task_runner_; |
| + // Current prefs on the disk. Should be accessed only on the pref thread. |
| + std::unique_ptr<base::DictionaryValue> prefs_; |
| + |
| // Should be accessed only on the pref thread. |
| base::WeakPtr<NetworkQualitiesPrefsManager> pref_weak_ptr_; |
| @@ -93,6 +103,11 @@ class NET_EXPORT NetworkQualitiesPrefsManager |
| scoped_refptr<base::SequencedTaskRunner> network_task_runner_; |
| + // Network quality prefs read from the disk at the time of startup. Can be |
| + // accessed on any thread. |
| + const std::map<nqe::internal::NetworkID, nqe::internal::CachedNetworkQuality> |
| + read_prefs_startup_; |
| + |
| // Used to get |weak_ptr_| to self on the pref thread. |
| base::WeakPtrFactory<NetworkQualitiesPrefsManager> pref_weak_ptr_factory_; |