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

Unified Diff: net/nqe/network_quality_estimator.h

Issue 2103323007: Exposing NQE on the Browser UI thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 4 years, 5 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
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..5491ae93796b4b9b84ca10d5c658072c7daa597e 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,29 @@ 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 from
+ // ReportEffectiveConnectionTypeForTesting.
+ void StopReportingEffectiveConnectionTypeForTesting();
tbansal1 2016/07/20 03:32:36 I do not think that this method is necessary. Repo
RyanSturm 2016/07/20 16:36:46 This will definitely be required later; I'll leave
tbansal1 2016/07/20 17:14:18 Acknowledged.
+
+ // 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 +644,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 from ReportEffectiveConnectionTypeForTesting.
+ 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_

Powered by Google App Engine
This is Rietveld 408576698