Chromium Code Reviews| Index: net/nqe/network_quality_estimator.h |
| diff --git a/net/nqe/network_quality_estimator.h b/net/nqe/network_quality_estimator.h |
| index afeca4eb01e1220879cb01bf87a644ebe06a9775..7a6e69043becb96b5caa0c2e18e9c1c2f9f7ca9a 100644 |
| --- a/net/nqe/network_quality_estimator.h |
| +++ b/net/nqe/network_quality_estimator.h |
| @@ -45,21 +45,21 @@ class ThroughputAnalyzer; |
| class URLRequest; |
| // NetworkQualityEstimator provides network quality estimates (quality of the |
| // full paths to all origins that have been connected to). |
| // The estimates are based on the observed organic traffic. |
| // A NetworkQualityEstimator instance is attached to URLRequestContexts and |
| // observes the traffic of URLRequests spawned from the URLRequestContexts. |
| // A single instance of NQE can be attached to multiple URLRequestContexts, |
| // thereby increasing the single NQE instance's accuracy by providing more |
| // observed traffic characteristics. |
| -class NET_EXPORT_PRIVATE NetworkQualityEstimator |
| +class NET_EXPORT NetworkQualityEstimator |
| : public NetworkChangeNotifier::ConnectionTypeObserver, |
| public ExternalEstimateProvider::UpdatedEstimateDelegate { |
| public: |
| // EffectiveConnectionType is the connection type whose typical performance is |
| // most similar to the measured performance of the network in use. In many |
| // cases, the "effective" connection type and the actual type of connection in |
| // use are the same, but often a network connection performs significantly |
| // different, usually worse, from its expected capabilities. |
| // EffectiveConnectionType of a network is independent of if the current |
| // connection is metered or not. For example, an unmetered slow connection may |
| @@ -70,21 +70,21 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator |
| EFFECTIVE_CONNECTION_TYPE_OFFLINE, |
| EFFECTIVE_CONNECTION_TYPE_SLOW_2G, |
| EFFECTIVE_CONNECTION_TYPE_2G, |
| EFFECTIVE_CONNECTION_TYPE_3G, |
| EFFECTIVE_CONNECTION_TYPE_4G, |
| EFFECTIVE_CONNECTION_TYPE_BROADBAND, |
| EFFECTIVE_CONNECTION_TYPE_LAST, |
| }; |
| // Observes changes in effective connection type. |
| - class NET_EXPORT_PRIVATE EffectiveConnectionTypeObserver { |
| + class NET_EXPORT EffectiveConnectionTypeObserver { |
| public: |
| // Notifies the observer of a change in the effective connection type. |
| // NetworkQualityEstimator computes the effective connection type once in |
| // every interval of duration |
| // |effective_connection_type_recomputation_interval_|. Additionally, when |
| // there is a change in the connection type of the device, then the |
| // effective connection type is immediately recomputed. The observer must |
| // register and unregister itself on the IO thread. All the observers would |
| // be notified on the IO thread. |
| // |
| @@ -230,20 +230,30 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator |
| // |use_localhost_requests| should only be true when testing against local |
| // HTTP server and allows the requests to local host to be used for network |
| // quality estimation. |
| void SetUseLocalHostRequestsForTesting(bool use_localhost_requests); |
| // |use_smaller_responses_for_tests| should only be true when testing. |
| // Allows the responses smaller than |kMinTransferSizeInBits| to be used for |
| // network quality estimation. |
| void SetUseSmallResponsesForTesting(bool use_small_responses); |
| + // Prevents updates to EffectiveConnectionTypeObservers aside from calls to |
| + // ReportEffectiveConnectionTypeForTesting. |
| + void StopReportingEffectiveConnectionTypeForTesting( |
| + bool stop_reporting_effective_connection_type); |
|
tbansal1
2016/07/19 23:05:22
I would suggest not including any param in the fun
RyanSturm
2016/07/19 23:31:03
Done.
|
| + |
| + // Reports |effective_connection_type| to all |
| + // EffectiveConnectionTypeObservers. |
| + void ReportEffectiveConnectionTypeForTesting( |
| + 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) {} |
| @@ -635,20 +645,24 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator |
| // 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_; |
| // Minimum and Maximum signal strength (in dbM) observed since last connection |
| // change. Updated on connection change and main frame requests. |
| int32_t min_signal_strength_since_connection_change_; |
| int32_t max_signal_strength_since_connection_change_; |
| + // When true, no updates to EffectiveConnectionTypeObservers will occur aside |
| + // from calls to ReportEffectiveConnectionTypeForTesting. |
|
tbansal1
2016/07/19 23:05:22
s/to/from/
RyanSturm
2016/07/19 23:31:03
Done.
|
| + bool stop_reporting_effective_connection_type_; |
| + |
| base::ThreadChecker thread_checker_; |
| base::WeakPtrFactory<NetworkQualityEstimator> weak_ptr_factory_; |
| DISALLOW_COPY_AND_ASSIGN(NetworkQualityEstimator); |
| }; |
| } // namespace net |
| #endif // NET_NQE_NETWORK_QUALITY_ESTIMATOR_H_ |