Index: net/base/network_quality_estimator.h |
diff --git a/net/base/network_quality_estimator.h b/net/base/network_quality_estimator.h |
index 9fa0ad1817604c0472f8e5bafb9f78b619cfe477..74100dc51addaecdb6408e261617c58bb2d85c24 100644 |
--- a/net/base/network_quality_estimator.h |
+++ b/net/base/network_quality_estimator.h |
@@ -13,6 +13,7 @@ |
#include <string> |
#include <tuple> |
+#include "base/compiler_specific.h" |
#include "base/gtest_prod_util.h" |
#include "base/macros.h" |
#include "base/memory/ref_counted.h" |
@@ -69,9 +70,9 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator |
// Observes measurements of round trip time. |
class NET_EXPORT_PRIVATE RTTObserver { |
public: |
- // Will be called when a new RTT observation is available. The round trip |
- // time is specified in milliseconds. The time when the observation was |
- // taken and the source of the observation are provided. |
+ // OnRTTObservation will be called when a new RTT observation is available. |
+ // The round trip time is specified in milliseconds. The time when the |
+ // observation was taken and the source of the observation are provided. |
virtual void OnRTTObservation(int32_t rtt_ms, |
const base::TimeTicks& timestamp, |
ObservationSource source) = 0; |
@@ -101,6 +102,37 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator |
DISALLOW_COPY_AND_ASSIGN(ThroughputObserver); |
}; |
+ // Observes measurements of packet counts. |
+ class NET_EXPORT_PRIVATE PacketCountObserver { |
+ public: |
+ // OnIncrementalPacketCountObservation will be called when incremental |
+ // packet counts are available. |packets_missing| is the number of packets |
+ // newly missing, but they may be received later and will be counted as out |
+ // of order. |packets_received_in_order| is the number of packets received |
+ // in order. |packets_received_out_of_order| is the number of packets |
+ // received out of order. |
+ |
+ // An example: |
+ // Last observation after packet #1. Packets #5 and #6 are received: |
+ // missing = 3, in_order = 2, out_of_order = 0. |
Jana
2016/03/12 03:11:28
Inferring missing packets is something that QUIC/T
|
+ |
+ // Last observation after packet #6. Packet #3 received: |
+ // missing = 0, in_order = 0, out_of_order = 1. |
+ virtual void OnIncrementalPacketCountObservation( |
+ size_t packets_missing, |
+ size_t packets_received_in_order, |
+ size_t packets_received_out_of_order, |
+ const base::TimeTicks& timestamp, |
+ ObservationSource source) = 0; |
+ |
+ protected: |
+ PacketCountObserver() {} |
+ virtual ~PacketCountObserver() {} |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(PacketCountObserver); |
+ }; |
+ |
// Creates a new NetworkQualityEstimator. |
// |variation_params| is the map containing all field trial parameters |
// related to NetworkQualityEstimator field trial. |
@@ -131,13 +163,14 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator |
~NetworkQualityEstimator() override; |
// Returns true if RTT is available and sets |rtt| to estimated RTT. |
- // Virtualized for testing. |rtt| should not be null. |
- virtual bool GetRTTEstimate(base::TimeDelta* rtt) const; |
+ // Virtualized for testing. |rtt| must not be null. |
+ virtual bool GetRTTEstimate(base::TimeDelta* rtt) const WARN_UNUSED_RESULT; |
// Returns true if downlink throughput is available and sets |kbps| to |
// estimated downlink throughput (in kilobits per second). |
- // Virtualized for testing. |kbps| should not be null. |
- virtual bool GetDownlinkThroughputKbpsEstimate(int32_t* kbps) const; |
+ // Virtualized for testing. |kbps| must not be null. |
+ virtual bool GetDownlinkThroughputKbpsEstimate(int32_t* kbps) const |
+ WARN_UNUSED_RESULT; |
// Notifies NetworkQualityEstimator that the response header of |request| has |
// been received. |
@@ -149,23 +182,29 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator |
// Returns true if median RTT is available and sets |rtt| to the median of |
// RTT observations since |begin_timestamp|. |
- // Virtualized for testing. |rtt| should not be null. |
+ // Virtualized for testing. |rtt| must not be null. |
virtual bool GetRecentMedianRTT(const base::TimeTicks& begin_timestamp, |
- base::TimeDelta* rtt) const; |
+ base::TimeDelta* rtt) const |
+ WARN_UNUSED_RESULT; |
// Returns true if median downstream throughput is available and sets |kbps| |
// to the median of downstream throughput (in kilobits per second) |
// observations since |begin_timestamp|. Virtualized for testing. |kbps| |
- // should not be null. |
+ // must not be null. |
virtual bool GetRecentMedianDownlinkThroughputKbps( |
const base::TimeTicks& begin_timestamp, |
- int32_t* kbps) const; |
+ int32_t* kbps) const WARN_UNUSED_RESULT; |
// SocketPerformanceWatcherFactory implementation: |
scoped_ptr<SocketPerformanceWatcher> CreateSocketPerformanceWatcher( |
const Protocol protocol) override; |
void OnUpdatedRTTAvailable(const Protocol protocol, |
const base::TimeDelta& rtt) override; |
+ void OnIncrementalPacketCountAvailable( |
+ Protocol protocol, |
+ size_t packets_missing, |
+ size_t packets_received_in_order, |
+ size_t packets_received_out_of_order) override; |
// Adds |rtt_observer| to the list of round trip time observers. Must be |
// called on the IO thread. |
@@ -183,6 +222,14 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator |
// is on the list of observers. Must be called on the IO thread. |
void RemoveThroughputObserver(ThroughputObserver* throughput_observer); |
+ // Adds |packet_count_observer| to the list of packet count observers. Must be |
+ // called on the IO thread. |
+ void AddPacketCountObserver(PacketCountObserver* packet_count_observer); |
+ |
+ // Removes |packet_count_observer| from the list of packet count observers if |
+ // it is on the list of observers. Must be called on the IO thread. |
+ void RemovePacketCountObserver(PacketCountObserver* packet_count_observer); |
+ |
protected: |
// NetworkID is used to uniquely identify a network. |
// For the purpose of network quality estimation and caching, a network is |
@@ -389,11 +436,10 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator |
// Returns true iff the |percentile| value of the observations in this |
// buffer is available. Sets |result| to the computed |percentile| |
- // value among all observations since |begin_timestamp|. If the value is |
- // unavailable, false is returned and |result| is not modified. Percentile |
- // value is unavailable if all the values in observation buffer are older |
- // than |begin_timestamp|. |
- // |result| must not be null. |
+ // value among all observations since |begin_timestamp| (inclusive). If the |
+ // value is unavailable, false is returned and |result| is not modified. |
+ // Percentile value is unavailable if all the values in observation buffer |
+ // are older than |begin_timestamp|. |result| must not be null. |
bool GetPercentile(const base::TimeTicks& begin_timestamp, |
ValueType* result, |
int percentile) const; |
@@ -504,10 +550,11 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator |
// returned estimate with 0.9 probability. Similarly, network is expected to |
// be slower than the returned estimate with 0.1 probability. |
base::TimeDelta GetRTTEstimateInternal(const base::TimeTicks& begin_timestamp, |
- int percentile) const; |
+ int percentile) const |
+ WARN_UNUSED_RESULT; |
int32_t GetDownlinkThroughputKbpsEstimateInternal( |
const base::TimeTicks& begin_timestamp, |
- int percentile) const; |
+ int percentile) const WARN_UNUSED_RESULT; |
// Returns the current network ID checking by calling the platform APIs. |
// Virtualized for testing. |
@@ -520,6 +567,13 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator |
void NotifyObserversOfThroughput(const ThroughputObservation& observation); |
+ void NotifyObserversOfIncrementalPacketCount( |
+ size_t packets_missing, |
+ size_t packets_received_in_order, |
+ size_t packets_received_out_of_order, |
+ const base::TimeTicks& timestamp, |
+ ObservationSource source); |
+ |
// Records the UMA related to RTT. |
void RecordRTTUMA(int32_t estimated_value_msec, |
int32_t actual_value_msec) const; |
@@ -545,6 +599,14 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator |
void RecordExternalEstimateProviderMetrics( |
NQEExternalEstimateProviderStatus status) const; |
+ // Gets the ObservationSource that corresponds to the given |protocol|, |
+ // updates |observation_source| and returns true. If the corresponding |
+ // ObservationSource is unknown, false is returned and |observation_source| is |
+ // not modified. |
+ bool GetObservationSourceForProtocol( |
+ Protocol protocol, |
+ ObservationSource* observation_source) const; |
+ |
// Determines if the requests to local host can be used in estimating the |
// network quality. Set to true only for tests. |
const bool allow_localhost_requests_; |
@@ -591,9 +653,11 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator |
// system APIs. May be NULL. |
const scoped_ptr<ExternalEstimateProvider> external_estimate_provider_; |
- // Observer lists for round trip times and throughput measurements. |
+ // Observer lists for round trip times, throughput and packet count |
+ // measurements. |
base::ObserverList<RTTObserver> rtt_observer_list_; |
base::ObserverList<ThroughputObserver> throughput_observer_list_; |
+ base::ObserverList<PacketCountObserver> packet_count_observer_list_; |
base::ThreadChecker thread_checker_; |