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

Unified Diff: net/nqe/network_qualities_prefs_manager.h

Issue 2369673004: Wire NQE Prefs to Profile (Closed)
Patch Set: Added functionality for reading and writing multiple network IDs, Rebased, Addressed Ryan's comments Created 4 years, 2 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: 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..cd238555ef03cbe8ce1b5436ff5a04410aeb6250 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:
- // Sets the persistent pref to the given value.
+ virtual ~PrefDelegate() {}
+
+ // Sets the persistent pref on the disk to the given value.
RyanSturm 2016/10/12 21:33:34 nit: "on the disk" probably isn't necessary, I thi
tbansal1 2016/10/12 22:04:01 Done.
virtual void SetDictionaryValue(const base::DictionaryValue& value) = 0;
+
+ // Returns the peristent prefs from the disk.
+ 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>
+ 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_;

Powered by Google App Engine
This is Rietveld 408576698