| 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 e2b6068188437ac44bdefe9877af66a2a25418c5..31bf2832cfeac810c588bf4cf39843209ada7151 100644
|
| --- a/components/cronet/android/cronet_url_request_context_adapter.cc
|
| +++ b/components/cronet/android/cronet_url_request_context_adapter.cc
|
| @@ -607,6 +607,17 @@ void CronetURLRequestContextAdapter::ProvideThroughputObservations(
|
| base::Unretained(this), should));
|
| }
|
|
|
| +void CronetURLRequestContextAdapter::InitializeNQEPrefsOnNetworkThread() const {
|
| + DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread());
|
| +
|
| + // Initializing |network_qualities_prefs_manager_| may post a callback to
|
| + // |this|. So, |network_qualities_prefs_manager_| should be initialized after
|
| + // |jcronet_url_request_context_| has been constructed.
|
| + DCHECK(jcronet_url_request_context_.obj() != nullptr);
|
| + network_qualities_prefs_manager_->InitializeOnNetworkThread(
|
| + network_quality_estimator_.get());
|
| +}
|
| +
|
| void CronetURLRequestContextAdapter::InitializeOnNetworkThread(
|
| std::unique_ptr<URLRequestContextConfig> config,
|
| const base::android::ScopedJavaGlobalRef<jobject>&
|
| @@ -688,18 +699,18 @@ void CronetURLRequestContextAdapter::InitializeOnNetworkThread(
|
|
|
| if (config->enable_network_quality_estimator) {
|
| DCHECK(!network_quality_estimator_);
|
| - std::map<std::string, std::string> variation_params;
|
| - // Configure network quality estimator: Specify the algorithm that should
|
| - // be used for computing the effective connection type. The algorithm
|
| - // is specified using the key-value pairs defined in
|
| - // //net/nqe/network_quality_estimator.cc.
|
| - // TODO(tbansal): Investigate a more robust way of configuring the network
|
| - // quality estimator.
|
| - variation_params["effective_connection_type_algorithm"] =
|
| - "TransportRTTOrDownstreamThroughput";
|
| + std::unique_ptr<net::NetworkQualityEstimatorParams> nqe_params =
|
| + base::MakeUnique<net::NetworkQualityEstimatorParams>(
|
| + std::map<std::string, std::string>());
|
| + nqe_params->set_persistent_cache_reading_enabled(
|
| + config->nqe_persistent_caching_enabled);
|
| + if (config->nqe_forced_effective_connection_type) {
|
| + nqe_params->SetForcedEffectiveConnectionType(
|
| + config->nqe_forced_effective_connection_type.value());
|
| + }
|
| +
|
| network_quality_estimator_ = base::MakeUnique<net::NetworkQualityEstimator>(
|
| - std::unique_ptr<net::ExternalEstimateProvider>(),
|
| - base::MakeUnique<net::NetworkQualityEstimatorParams>(variation_params),
|
| + std::unique_ptr<net::ExternalEstimateProvider>(), std::move(nqe_params),
|
| g_net_log.Get().net_log());
|
| network_quality_estimator_->AddEffectiveConnectionTypeObserver(this);
|
| network_quality_estimator_->AddRTTAndThroughputEstimatesObserver(this);
|
| @@ -711,8 +722,10 @@ void CronetURLRequestContextAdapter::InitializeOnNetworkThread(
|
| base::MakeUnique<net::NetworkQualitiesPrefsManager>(
|
| base::MakeUnique<NetworkQualitiesPrefDelegateImpl>(
|
| pref_service_.get()));
|
| - network_qualities_prefs_manager_->InitializeOnNetworkThread(
|
| - network_quality_estimator_.get());
|
| + PostTaskToNetworkThread(FROM_HERE,
|
| + base::Bind(&CronetURLRequestContextAdapter::
|
| + InitializeNQEPrefsOnNetworkThread,
|
| + base::Unretained(this)));
|
| }
|
| context_builder.set_network_quality_estimator(
|
| network_quality_estimator_.get());
|
|
|