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

Unified Diff: net/nqe/network_quality_estimator.h

Issue 2007713002: Expose NQE::OnEffectiveConnectionTypeChanged API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | « no previous file | net/nqe/network_quality_estimator.cc » ('j') | net/nqe/network_quality_estimator.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/nqe/network_quality_estimator.h
diff --git a/net/nqe/network_quality_estimator.h b/net/nqe/network_quality_estimator.h
index 37117c1799dc0a7436e640363de9620b014f639f..9749817d2226741d983ad8032e1bb84910a6367f 100644
--- a/net/nqe/network_quality_estimator.h
+++ b/net/nqe/network_quality_estimator.h
@@ -32,6 +32,7 @@
namespace base {
class SingleThreadTaskRunner;
+class TickClock;
} // namespace base
namespace net {
@@ -76,6 +77,21 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator
EFFECTIVE_CONNECTION_TYPE_LAST,
};
+ // Observes changes in effective connection type.
bengr 2016/05/27 19:46:01 What is the contract? The consumer will be notifie
tbansal1 2016/05/28 01:20:42 Done.
+ class NET_EXPORT_PRIVATE EffectiveConnectionTypeObserver {
+ public:
+ // Will be called when the effective connection type changes.
+ virtual void OnEffectiveConnectionTypeChanged(
+ EffectiveConnectionType type) = 0;
+
+ protected:
+ EffectiveConnectionTypeObserver() {}
+ virtual ~EffectiveConnectionTypeObserver() {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(EffectiveConnectionTypeObserver);
+ };
+
// Observes measurements of round trip time.
class NET_EXPORT_PRIVATE RTTObserver {
public:
@@ -144,6 +160,16 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator
// testing.
virtual EffectiveConnectionType GetEffectiveConnectionType() const;
+ // Adds |observer| to the list of effective connection type observers. Must be
+ // called on the IO thread.
+ void AddEffectiveConnectionTypeObserver(
+ EffectiveConnectionTypeObserver* observer);
+
+ // Removes |observer| from the list of effective connection type observers.
+ // Must be called on the IO thread.
+ void RemoveEffectiveConnectionTypeObserver(
+ EffectiveConnectionTypeObserver* observer);
+
// Returns true if the RTT is available and sets |rtt| to the RTT estimated at
// the HTTP layer. Virtualized for testing. |rtt| should not be null. The RTT
// at the HTTP layer measures the time from when the request was sent (this
@@ -271,6 +297,8 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator
const char* GetNameForEffectiveConnectionType(
EffectiveConnectionType type) const;
+ void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock);
bengr 2016/05/27 19:46:02 Add a comment.
tbansal1 2016/05/28 01:20:42 Done.
+
private:
FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, StoreObservations);
FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestAddObservation);
@@ -391,6 +419,10 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator
// Returns true only if the |request| can be used for RTT estimation.
bool RequestProvidesRTTObservation(const URLRequest& request) const;
+ void MaybeRecomputeEffectiveConnectionType();
bengr 2016/05/27 19:46:02 Add a comment.
tbansal1 2016/05/28 01:20:42 Done.
+
+ void NotifyObserversOfEffectiveConnectionTypeChanged();
bengr 2016/05/27 19:46:02 Add a comment.
tbansal1 2016/05/28 01:20:42 Done.
+
// Values of external estimate provider status. This enum must remain
// synchronized with the enum of the same name in
// metrics/histograms/histograms.xml.
@@ -421,6 +453,12 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator
// The factor by which the weight of an observation reduces every second.
const double weight_multiplier_per_second_;
+ std::unique_ptr<base::TickClock> tick_clock_;
bengr 2016/05/27 19:46:01 Add a comment.
tbansal1 2016/05/28 01:20:42 Done, but this one seems pretty self-explanatory.
+
+ // Minimum duration between two consecutive computations of effective
+ // connection type.
+ const base::TimeDelta effective_connection_type_recomputation_interval_;
bengr 2016/05/27 19:46:02 Is this for hysteresis or performance or both?
tbansal1 2016/05/28 01:20:42 Performance. Hysteresis means we notify observers
+
// Time when last connection change was observed.
base::TimeTicks last_connection_change_;
@@ -465,6 +503,10 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator
// system APIs. May be NULL.
const std::unique_ptr<ExternalEstimateProvider> external_estimate_provider_;
+ // Observer list for changes in effective connection type.
+ base::ObserverList<EffectiveConnectionTypeObserver>
+ effective_connection_type_observer_list_;
+
// Observer lists for round trip times and throughput measurements.
base::ObserverList<RTTObserver> rtt_observer_list_;
base::ObserverList<ThroughputObserver> throughput_observer_list_;
@@ -477,6 +519,15 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator
// estimating the throughput.
std::unique_ptr<nqe::internal::ThroughputAnalyzer> throughput_analyzer_;
+ // Time when the effective connection type was last computed.
+ base::TimeTicks last_effective_connection_type_computation_;
bengr 2016/05/27 19:46:01 Should this be listed together with line 460?
tbansal1 2016/05/28 01:20:42 Done.
+
+ // Current effective connection type. It is updated on connection change
+ // events. It is also updated every time there is network traffic (provided
+ // the last computation was more than
+ // |effective_connection_type_recomputation_interval_| ago).
+ EffectiveConnectionType effective_connection_type_;
+
base::ThreadChecker thread_checker_;
base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_;
« no previous file with comments | « no previous file | net/nqe/network_quality_estimator.cc » ('j') | net/nqe/network_quality_estimator.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698