| Index: net/nqe/network_quality_estimator.h
|
| diff --git a/net/nqe/network_quality_estimator.h b/net/nqe/network_quality_estimator.h
|
| index 44fb30393014ae0b05b806e7912263ed3f5e4028..04329ef134fb7b1148715fbca9f3da63c66efdc9 100644
|
| --- a/net/nqe/network_quality_estimator.h
|
| +++ b/net/nqe/network_quality_estimator.h
|
| @@ -10,7 +10,6 @@
|
| #include <map>
|
| #include <memory>
|
| #include <string>
|
| -#include <tuple>
|
|
|
| #include "base/compiler_specific.h"
|
| #include "base/gtest_prod_util.h"
|
| @@ -24,9 +23,11 @@
|
| #include "net/base/network_change_notifier.h"
|
| #include "net/nqe/cached_network_quality.h"
|
| #include "net/nqe/external_estimate_provider.h"
|
| +#include "net/nqe/network_id.h"
|
| #include "net/nqe/network_quality.h"
|
| #include "net/nqe/network_quality_observation.h"
|
| #include "net/nqe/network_quality_observation_source.h"
|
| +#include "net/nqe/network_quality_store.h"
|
| #include "net/nqe/observation_buffer.h"
|
| #include "net/socket/socket_performance_watcher_factory.h"
|
|
|
| @@ -243,46 +244,6 @@ class NET_EXPORT NetworkQualityEstimator
|
| EffectiveConnectionType effective_connection_type);
|
|
|
| protected:
|
| - // NetworkID is used to uniquely identify a network.
|
| - // For the purpose of network quality estimation and caching, a network is
|
| - // uniquely identified by a combination of |type| and
|
| - // |id|. This approach is unable to distinguish networks with
|
| - // same name (e.g., different Wi-Fi networks with same SSID).
|
| - // This is a protected member to expose it to tests.
|
| - struct NET_EXPORT_PRIVATE NetworkID {
|
| - NetworkID(NetworkChangeNotifier::ConnectionType type, const std::string& id)
|
| - : type(type), id(id) {}
|
| - NetworkID(const NetworkID& other) : type(other.type), id(other.id) {}
|
| - ~NetworkID() {}
|
| -
|
| - NetworkID& operator=(const NetworkID& other) {
|
| - type = other.type;
|
| - id = other.id;
|
| - return *this;
|
| - }
|
| -
|
| - // Overloaded because NetworkID is used as key in a map.
|
| - bool operator<(const NetworkID& other) const {
|
| - return std::tie(type, id) < std::tie(other.type, other.id);
|
| - }
|
| -
|
| - // Connection type of the network.
|
| - NetworkChangeNotifier::ConnectionType type;
|
| -
|
| - // Name of this network. This is set to:
|
| - // - Wi-Fi SSID if the device is connected to a Wi-Fi access point and the
|
| - // SSID name is available, or
|
| - // - MCC/MNC code of the cellular carrier if the device is connected to a
|
| - // cellular network, or
|
| - // - "Ethernet" in case the device is connected to ethernet.
|
| - // - An empty string in all other cases or if the network name is not
|
| - // exposed by platform APIs.
|
| - std::string id;
|
| - };
|
| -
|
| - // Returns true if the cached network quality estimate was successfully read.
|
| - bool ReadCachedNetworkQualityEstimate();
|
| -
|
| // NetworkChangeNotifier::ConnectionTypeObserver implementation:
|
| void OnConnectionTypeChanged(
|
| NetworkChangeNotifier::ConnectionType type) override;
|
| @@ -360,9 +321,6 @@ class NET_EXPORT NetworkQualityEstimator
|
| ObtainAlgorithmToUseFromParams);
|
| FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, HalfLifeParam);
|
| FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, ComputedPercentiles);
|
| - FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestCaching);
|
| - FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest,
|
| - TestLRUCacheMaximumSize);
|
| FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest, TestGetMetricsSince);
|
| FRIEND_TEST_ALL_PREFIXES(NetworkQualityEstimatorTest,
|
| TestExternalEstimateProviderMergeEstimates);
|
| @@ -376,12 +334,6 @@ class NET_EXPORT NetworkQualityEstimator
|
| typedef nqe::internal::Observation<int32_t> ThroughputObservation;
|
| typedef nqe::internal::ObservationBuffer<int32_t> ThroughputObservationBuffer;
|
|
|
| - // This does not use a unordered_map or hash_map for code simplicity (key just
|
| - // implements operator<, rather than hash and equality) and because the map is
|
| - // tiny.
|
| - typedef std::map<NetworkID, nqe::internal::CachedNetworkQuality>
|
| - CachedNetworkQualities;
|
| -
|
| // Algorithms supported by network quality estimator for computing effective
|
| // connection type.
|
| enum class EffectiveConnectionTypeAlgorithm {
|
| @@ -424,11 +376,6 @@ class NET_EXPORT NetworkQualityEstimator
|
| // kilobits per second) values.
|
| static const int kMinimumThroughputVariationParameterKbps = 1;
|
|
|
| - // Maximum size of the cache that holds network quality estimates.
|
| - // Smaller size may reduce the cache hit rate due to frequent evictions.
|
| - // Larger size may affect performance.
|
| - static const size_t kMaximumNetworkQualityCacheSize = 10;
|
| -
|
| // Returns the RTT value to be used when the valid RTT is unavailable. Readers
|
| // should discard RTT if it is set to the value returned by |InvalidRTT()|.
|
| static const base::TimeDelta InvalidRTT();
|
| @@ -487,10 +434,7 @@ class NET_EXPORT NetworkQualityEstimator
|
|
|
| // Returns the current network ID checking by calling the platform APIs.
|
| // Virtualized for testing.
|
| - virtual NetworkID GetCurrentNetworkID() const;
|
| -
|
| - // Writes the estimated quality of the current network to the cache.
|
| - void CacheNetworkQualityEstimate();
|
| + virtual nqe::internal::NetworkID GetCurrentNetworkID() const;
|
|
|
| void NotifyObserversOfRTT(const RttObservation& observation);
|
|
|
| @@ -546,6 +490,9 @@ class NET_EXPORT NetworkQualityEstimator
|
| void RecordExternalEstimateProviderMetrics(
|
| NQEExternalEstimateProviderStatus status) const;
|
|
|
| + // Returns true if the cached network quality estimate was successfully read.
|
| + bool ReadCachedNetworkQualityEstimate();
|
| +
|
| // Records a correlation metric that can be used for computing the correlation
|
| // between HTTP-layer RTT, transport-layer RTT, throughput and the time
|
| // taken to complete |request|.
|
| @@ -591,7 +538,7 @@ class NET_EXPORT NetworkQualityEstimator
|
| base::TimeTicks last_connection_change_;
|
|
|
| // ID of the current network.
|
| - NetworkID current_network_id_;
|
| + nqe::internal::NetworkID current_network_id_;
|
|
|
| // Peak network quality (fastest round-trip-time (RTT) and highest
|
| // downstream throughput) measured since last connectivity change. RTT is
|
| @@ -601,9 +548,6 @@ class NET_EXPORT NetworkQualityEstimator
|
| // 2) Includes server processing time.
|
| nqe::internal::NetworkQuality peak_network_quality_;
|
|
|
| - // Cache that stores quality of previously seen networks.
|
| - CachedNetworkQualities cached_network_qualities_;
|
| -
|
| // Buffer that holds throughput observations (in kilobits per second) sorted
|
| // by timestamp.
|
| ThroughputObservationBuffer downstream_throughput_kbps_observations_;
|
| @@ -670,6 +614,9 @@ class NET_EXPORT NetworkQualityEstimator
|
| // if it is 1.0, then it will be recorded for all valid HTTP requests.
|
| const double correlation_uma_logging_probability_;
|
|
|
| + // Stores the qualities of different networks.
|
| + nqe::internal::NetworkQualityStore network_quality_store_;
|
| +
|
| base::ThreadChecker thread_checker_;
|
|
|
| base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_;
|
|
|