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

Side by Side Diff: components/cronet/android/cronet_url_request_context_adapter.cc

Issue 2416473004: Add functionality for embedders to configure NQE (Closed)
Patch Set: ps Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/cronet/android/cronet_url_request_context_adapter.h" 5 #include "components/cronet/android/cronet_url_request_context_adapter.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 // Explicitly disable the persister for Cronet to avoid persistence of dynamic 670 // Explicitly disable the persister for Cronet to avoid persistence of dynamic
671 // HPKP. This is a safety measure ensuring that nobody enables the persistence 671 // HPKP. This is a safety measure ensuring that nobody enables the persistence
672 // of HPKP by specifying transport_security_persister_path in the future. 672 // of HPKP by specifying transport_security_persister_path in the future.
673 context_builder.set_transport_security_persister_path(base::FilePath()); 673 context_builder.set_transport_security_persister_path(base::FilePath());
674 674
675 // Disable net::CookieStore and net::ChannelIDService. 675 // Disable net::CookieStore and net::ChannelIDService.
676 context_builder.SetCookieAndChannelIdStores(nullptr, nullptr); 676 context_builder.SetCookieAndChannelIdStores(nullptr, nullptr);
677 677
678 if (config->enable_network_quality_estimator) { 678 if (config->enable_network_quality_estimator) {
679 DCHECK(!network_quality_estimator_); 679 DCHECK(!network_quality_estimator_);
680 std::map<std::string, std::string> variation_params; 680 // It's ok to clear thread association for |config->nqe_params| since the
681 // Configure network quality estimator: Specify the algorithm that should 681 // object is being moved, and so can no longer be modified on the other
682 // be used for computing the effective connection type. The algorithm 682 // thread.
683 // is specified using the key-value pairs defined in 683 config->nqe_params->DetachFromThread();
mgersh 2017/06/28 18:26:50 This shouldn't be necessary, since experimental op
tbansal1 2017/06/29 01:17:58 Done.
684 // //net/nqe/network_quality_estimator.cc.
685 // TODO(tbansal): Investigate a more robust way of configuring the network
686 // quality estimator.
687 variation_params["effective_connection_type_algorithm"] =
688 "TransportRTTOrDownstreamThroughput";
689 network_quality_estimator_ = base::MakeUnique<net::NetworkQualityEstimator>( 684 network_quality_estimator_ = base::MakeUnique<net::NetworkQualityEstimator>(
690 std::unique_ptr<net::ExternalEstimateProvider>(), 685 std::unique_ptr<net::ExternalEstimateProvider>(),
691 base::MakeUnique<net::NetworkQualityEstimatorParams>(variation_params), 686 std::move(config->nqe_params), g_net_log.Get().net_log());
mgersh 2017/06/28 18:26:50 Moving a pointer not owned by this object defeats
tbansal1 2017/06/29 01:17:58 Done.
692 g_net_log.Get().net_log());
693 network_quality_estimator_->AddEffectiveConnectionTypeObserver(this); 687 network_quality_estimator_->AddEffectiveConnectionTypeObserver(this);
694 network_quality_estimator_->AddRTTAndThroughputEstimatesObserver(this); 688 network_quality_estimator_->AddRTTAndThroughputEstimatesObserver(this);
695
696 // Set up network quality prefs if the storage path is specified. 689 // Set up network quality prefs if the storage path is specified.
697 if (!config->storage_path.empty()) { 690 if (!config->storage_path.empty()) {
698 DCHECK(!network_qualities_prefs_manager_); 691 DCHECK(!network_qualities_prefs_manager_);
699 network_qualities_prefs_manager_ = 692 network_qualities_prefs_manager_ =
700 base::MakeUnique<net::NetworkQualitiesPrefsManager>( 693 base::MakeUnique<net::NetworkQualitiesPrefsManager>(
701 base::MakeUnique<NetworkQualitiesPrefDelegateImpl>( 694 base::MakeUnique<NetworkQualitiesPrefDelegateImpl>(
702 pref_service_.get())); 695 pref_service_.get()));
703 network_qualities_prefs_manager_->InitializeOnNetworkThread(
704 network_quality_estimator_.get());
705 } 696 }
706 context_builder.set_network_quality_estimator( 697 context_builder.set_network_quality_estimator(
707 network_quality_estimator_.get()); 698 network_quality_estimator_.get());
708 } 699 }
709 700
710 context_ = context_builder.Build(); 701 context_ = context_builder.Build();
711 702
712 context_->set_check_cleartext_permitted(true); 703 context_->set_check_cleartext_permitted(true);
713 context_->set_enable_brotli(config->enable_brotli); 704 context_->set_enable_brotli(config->enable_brotli);
714 705
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 context_->transport_security_state() 779 context_->transport_security_state()
789 ->SetEnablePublicKeyPinningBypassForLocalTrustAnchors( 780 ->SetEnablePublicKeyPinningBypassForLocalTrustAnchors(
790 config->bypass_public_key_pinning_for_local_trust_anchors); 781 config->bypass_public_key_pinning_for_local_trust_anchors);
791 782
792 JNIEnv* env = base::android::AttachCurrentThread(); 783 JNIEnv* env = base::android::AttachCurrentThread();
793 jcronet_url_request_context_.Reset(env, jcronet_url_request_context.obj()); 784 jcronet_url_request_context_.Reset(env, jcronet_url_request_context.obj());
794 Java_CronetUrlRequestContext_initNetworkThread(env, 785 Java_CronetUrlRequestContext_initNetworkThread(env,
795 jcronet_url_request_context); 786 jcronet_url_request_context);
796 787
797 is_context_initialized_ = true; 788 is_context_initialized_ = true;
789 if (config->enable_network_quality_estimator &&
790 !config->storage_path.empty()) {
mgersh 2017/06/28 18:26:50 This block logically goes together with HostCacheP
tbansal1 2017/06/29 01:17:58 This code block should run after |jcronet_url_requ
mgersh 2017/06/29 19:02:31 Ah, ok, I misread which object needs to be initial
tbansal1 2017/06/29 22:45:05 The problem is that it is not a posted task. I am
791 // Initializing |network_qualities_prefs_manager_| may post a callback to
792 // |this|. So, initialize it after |jcronet_url_request_context_| has been
793 // constructed.
794 network_qualities_prefs_manager_->InitializeOnNetworkThread(
795 network_quality_estimator_.get());
796 }
797
798 while (!tasks_waiting_for_context_.empty()) { 798 while (!tasks_waiting_for_context_.empty()) {
799 tasks_waiting_for_context_.front().Run(); 799 tasks_waiting_for_context_.front().Run();
800 tasks_waiting_for_context_.pop(); 800 tasks_waiting_for_context_.pop();
801 } 801 }
802 } 802 }
803 803
804 void CronetURLRequestContextAdapter::Destroy( 804 void CronetURLRequestContextAdapter::Destroy(
805 JNIEnv* env, 805 JNIEnv* env,
806 const JavaParamRef<jobject>& jcaller) { 806 const JavaParamRef<jobject>& jcaller) {
807 DCHECK(!GetNetworkTaskRunner()->BelongsToCurrentThread()); 807 DCHECK(!GetNetworkTaskRunner()->BelongsToCurrentThread());
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 JNIEnv* env, 1171 JNIEnv* env,
1172 const JavaParamRef<jclass>& jcaller) { 1172 const JavaParamRef<jclass>& jcaller) {
1173 DCHECK(base::StatisticsRecorder::IsActive()); 1173 DCHECK(base::StatisticsRecorder::IsActive());
1174 std::vector<uint8_t> data; 1174 std::vector<uint8_t> data;
1175 if (!HistogramManager::GetInstance()->GetDeltas(&data)) 1175 if (!HistogramManager::GetInstance()->GetDeltas(&data))
1176 return ScopedJavaLocalRef<jbyteArray>(); 1176 return ScopedJavaLocalRef<jbyteArray>();
1177 return base::android::ToJavaByteArray(env, &data[0], data.size()); 1177 return base::android::ToJavaByteArray(env, &data[0], data.size());
1178 } 1178 }
1179 1179
1180 } // namespace cronet 1180 } // namespace cronet
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698