| Index: net/base/network_quality_estimator.h
|
| diff --git a/net/base/network_quality_estimator.h b/net/base/network_quality_estimator.h
|
| index ecfa08af6b8341b3a9bb06897a89baa42651c7b7..4026d0806fb7bc4688e2f66414e137e4cfb57531 100644
|
| --- a/net/base/network_quality_estimator.h
|
| +++ b/net/base/network_quality_estimator.h
|
| @@ -7,15 +7,18 @@
|
|
|
| #include <stdint.h>
|
|
|
| +#include <deque>
|
| +
|
| #include "base/gtest_prod_util.h"
|
| #include "base/macros.h"
|
| #include "base/threading/thread_checker.h"
|
| #include "base/time/time.h"
|
| +#include "net/base/net_export.h"
|
| #include "net/base/network_change_notifier.h"
|
|
|
| namespace net {
|
|
|
| -struct NetworkQuality;
|
| +class NetworkQuality;
|
|
|
| // NetworkQualityEstimator provides network quality estimates (quality of the
|
| // full paths to all origins that have been connected to).
|
| @@ -33,21 +36,61 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator
|
|
|
| ~NetworkQualityEstimator() override;
|
|
|
| - // Returns an estimate of the current network quality.
|
| - NetworkQuality GetEstimate() const;
|
| + // Returns the peak estimates (fastest RTT and peak throughput) of the
|
| + // current network.
|
| + NetworkQuality GetPeakEstimate() const;
|
|
|
| // Notifies NetworkQualityEstimator that a response has been received.
|
| - // |prefilter_bytes_read| is the count of the bytes received prior to
|
| - // applying filters (e.g. decompression, SDCH) from request creation time
|
| + // |cummulative_prefilter_bytes_read| is the count of the bytes received prior
|
| + // to applying filters (e.g. decompression, SDCH) from request creation time
|
| // until now.
|
| + // |prefiltered_bytes_read| is the count of the bytes received prior
|
| + // to applying filters in the most recent read.
|
| void NotifyDataReceived(const URLRequest& request,
|
| - int64_t prefilter_bytes_read);
|
| + int64_t cummulative_prefilter_bytes_read,
|
| + int64_t prefiltered_bytes_read);
|
|
|
| private:
|
| FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest,
|
| TestPeakKbpsFastestRTTUpdates);
|
| FRIEND_TEST_ALL_PREFIXES(URLRequestTestHTTP, NetworkQualityEstimator);
|
|
|
| + // Observation is used to store RTT and Kbps observation in buffers. An
|
| + // observation has a value and a timestamp (when the observation was taken).
|
| + struct Observation {
|
| + Observation(int value, base::TimeTicks timestamp);
|
| +
|
| + ~Observation();
|
| +
|
| + // Value of the observation.
|
| + const int value;
|
| +
|
| + // Time when the observation was taken.
|
| + const base::TimeTicks timestamp;
|
| + };
|
| +
|
| + // ObservationBuffer is used to store observations sorted by time.
|
| + class ObservationBuffer {
|
| + public:
|
| + ObservationBuffer();
|
| +
|
| + ~ObservationBuffer();
|
| +
|
| + // Adds an observation to the buffer. The oldest observation in the buffer
|
| + // will be popped out and discarded if the buffer is already full.
|
| + void AddObservation(int value);
|
| +
|
| + private:
|
| + // Maximum number of observations to hold in the ObservationBuffer.
|
| + static const size_t kMaximumObservations;
|
| +
|
| + // Buffer that holds observations sorted by time.
|
| + // Oldest observation is at the front of the queue.
|
| + std::deque<Observation> observations_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ObservationBuffer);
|
| + };
|
| +
|
| // Tiny transfer sizes may give inaccurate throughput results.
|
| // Minimum size of the transfer over which the throughput is computed.
|
| static const int kMinTransferSizeInBytes = 10000;
|
| @@ -93,6 +136,12 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator
|
| // 2) The transfer time includes at least one RTT while no bytes are read.
|
| uint64_t peak_kbps_since_last_connection_change_;
|
|
|
| + // Buffer that holds Kbps observations.
|
| + ObservationBuffer kbps_observations_;
|
| +
|
| + // Buffer that holds RTT (in milliseconds) observations.
|
| + ObservationBuffer rtt_msec_observations_;
|
| +
|
| base::ThreadChecker thread_checker_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator);
|
|
|