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

Unified Diff: components/cronet/android/cronet_url_request_context_adapter.cc

Issue 2146563002: Expose effective connection type to Cronet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Patch 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: components/cronet/android/cronet_url_request_context_adapter.cc
diff --git a/components/cronet/android/cronet_url_request_context_adapter.cc b/components/cronet/android/cronet_url_request_context_adapter.cc
index 91267abeee7f37cc011bc12d81f740c585988bd0..b5a308e3161ec5723ae1ae198d7ee95c6d7da64f 100644
--- a/components/cronet/android/cronet_url_request_context_adapter.cc
+++ b/components/cronet/android/cronet_url_request_context_adapter.cc
@@ -416,6 +416,7 @@ CronetURLRequestContextAdapter::~CronetURLRequestContextAdapter() {
if (network_quality_estimator_) {
network_quality_estimator_->RemoveRTTObserver(this);
network_quality_estimator_->RemoveThroughputObserver(this);
+ network_quality_estimator_->RemoveEffectiveConnectionTypeObserver(this);
}
// Stop |write_to_file_observer_| if there is one.
StopNetLogHelper();
@@ -616,13 +617,19 @@ void CronetURLRequestContextAdapter::InitializeOnNetworkThread(
if (config->enable_network_quality_estimator) {
DCHECK(!network_quality_estimator_);
+ std::map<std::string, std::string> variation_params;
+ // Specify the algorithm that should be used for computing the effective
+ // connection type.
+ variation_params["effective_connection_type_algorithm"] =
+ "TransportRTTOrDownstreamThroughput";
network_quality_estimator_.reset(new net::NetworkQualityEstimator(
- std::unique_ptr<net::ExternalEstimateProvider>(),
- std::map<std::string, std::string>(), false, false));
+ std::unique_ptr<net::ExternalEstimateProvider>(), variation_params,
+ false, false));
// Set the socket performance watcher factory so that network quality
// estimator is notified of socket performance metrics from TCP and QUIC.
context_builder.set_socket_performance_watcher_factory(
network_quality_estimator_->GetSocketPerformanceWatcherFactory());
+ network_quality_estimator_->AddEffectiveConnectionTypeObserver(this);
}
context_ = context_builder.Build();
@@ -841,6 +848,15 @@ base::Thread* CronetURLRequestContextAdapter::GetFileThread() {
return file_thread_.get();
}
+void CronetURLRequestContextAdapter::OnEffectiveConnectionTypeChanged(
+ net::NetworkQualityEstimator::EffectiveConnectionType
+ effective_connection_type) {
+ DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread());
+ Java_CronetUrlRequestContext_onEffectiveConnectionTypeChanged(
+ base::android::AttachCurrentThread(), jcronet_url_request_context_.obj(),
+ effective_connection_type);
+}
+
void CronetURLRequestContextAdapter::OnRTTObservation(
int32_t rtt_ms,
const base::TimeTicks& timestamp,

Powered by Google App Engine
This is Rietveld 408576698