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

Side by Side 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: Updated comments 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 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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 CronetURLRequestContextAdapter::~CronetURLRequestContextAdapter() { 409 CronetURLRequestContextAdapter::~CronetURLRequestContextAdapter() {
410 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); 410 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread());
411 411
412 if (http_server_properties_manager_) 412 if (http_server_properties_manager_)
413 http_server_properties_manager_->ShutdownOnPrefThread(); 413 http_server_properties_manager_->ShutdownOnPrefThread();
414 if (pref_service_) 414 if (pref_service_)
415 pref_service_->CommitPendingWrite(); 415 pref_service_->CommitPendingWrite();
416 if (network_quality_estimator_) { 416 if (network_quality_estimator_) {
417 network_quality_estimator_->RemoveRTTObserver(this); 417 network_quality_estimator_->RemoveRTTObserver(this);
418 network_quality_estimator_->RemoveThroughputObserver(this); 418 network_quality_estimator_->RemoveThroughputObserver(this);
419 network_quality_estimator_->RemoveEffectiveConnectionTypeObserver(this);
419 } 420 }
420 // Stop |write_to_file_observer_| if there is one. 421 // Stop |write_to_file_observer_| if there is one.
421 StopNetLogHelper(); 422 StopNetLogHelper();
422 } 423 }
423 424
424 void CronetURLRequestContextAdapter::InitRequestContextOnMainThread( 425 void CronetURLRequestContextAdapter::InitRequestContextOnMainThread(
425 JNIEnv* env, 426 JNIEnv* env,
426 const JavaParamRef<jobject>& jcaller) { 427 const JavaParamRef<jobject>& jcaller) {
427 base::android::ScopedJavaGlobalRef<jobject> jcaller_ref; 428 base::android::ScopedJavaGlobalRef<jobject> jcaller_ref;
428 jcaller_ref.Reset(env, jcaller); 429 jcaller_ref.Reset(env, jcaller);
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 // Explicitly disable the persister for Cronet to avoid persistence of dynamic 610 // Explicitly disable the persister for Cronet to avoid persistence of dynamic
610 // HPKP. This is a safety measure ensuring that nobody enables the persistence 611 // HPKP. This is a safety measure ensuring that nobody enables the persistence
611 // of HPKP by specifying transport_security_persister_path in the future. 612 // of HPKP by specifying transport_security_persister_path in the future.
612 context_builder.set_transport_security_persister_path(base::FilePath()); 613 context_builder.set_transport_security_persister_path(base::FilePath());
613 614
614 // Disable net::CookieStore and net::ChannelIDService. 615 // Disable net::CookieStore and net::ChannelIDService.
615 context_builder.SetCookieAndChannelIdStores(nullptr, nullptr); 616 context_builder.SetCookieAndChannelIdStores(nullptr, nullptr);
616 617
617 if (config->enable_network_quality_estimator) { 618 if (config->enable_network_quality_estimator) {
618 DCHECK(!network_quality_estimator_); 619 DCHECK(!network_quality_estimator_);
620 std::map<std::string, std::string> variation_params;
621 // Configure network quality estimator: Specify the algorithm that should
622 // be used for computing the effective connection type. The algorithm
623 // is specified using the key-value pairs defined in
624 // //net/nqe/network_quality_estimator.cc.
625 // TODO(tbansal): Investigate a more robust way of configuring the network
626 // quality estimator.
627 variation_params["effective_connection_type_algorithm"] =
628 "TransportRTTOrDownstreamThroughput";
619 network_quality_estimator_.reset(new net::NetworkQualityEstimator( 629 network_quality_estimator_.reset(new net::NetworkQualityEstimator(
620 std::unique_ptr<net::ExternalEstimateProvider>(), 630 std::unique_ptr<net::ExternalEstimateProvider>(), variation_params,
621 std::map<std::string, std::string>(), false, false)); 631 false, false));
622 // Set the socket performance watcher factory so that network quality 632 // Set the socket performance watcher factory so that network quality
623 // estimator is notified of socket performance metrics from TCP and QUIC. 633 // estimator is notified of socket performance metrics from TCP and QUIC.
624 context_builder.set_socket_performance_watcher_factory( 634 context_builder.set_socket_performance_watcher_factory(
625 network_quality_estimator_->GetSocketPerformanceWatcherFactory()); 635 network_quality_estimator_->GetSocketPerformanceWatcherFactory());
636 network_quality_estimator_->AddEffectiveConnectionTypeObserver(this);
626 } 637 }
627 638
628 context_ = context_builder.Build(); 639 context_ = context_builder.Build();
629 if (network_quality_estimator_) 640 if (network_quality_estimator_)
630 context_->set_network_quality_estimator(network_quality_estimator_.get()); 641 context_->set_network_quality_estimator(network_quality_estimator_.get());
631 642
632 if (config->load_disable_cache) 643 if (config->load_disable_cache)
633 default_load_flags_ |= net::LOAD_DISABLE_CACHE; 644 default_load_flags_ |= net::LOAD_DISABLE_CACHE;
634 645
635 if (config->enable_sdch) { 646 if (config->enable_sdch) {
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 845
835 base::Thread* CronetURLRequestContextAdapter::GetFileThread() { 846 base::Thread* CronetURLRequestContextAdapter::GetFileThread() {
836 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); 847 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread());
837 if (!file_thread_) { 848 if (!file_thread_) {
838 file_thread_.reset(new base::Thread("Network File Thread")); 849 file_thread_.reset(new base::Thread("Network File Thread"));
839 file_thread_->Start(); 850 file_thread_->Start();
840 } 851 }
841 return file_thread_.get(); 852 return file_thread_.get();
842 } 853 }
843 854
855 void CronetURLRequestContextAdapter::OnEffectiveConnectionTypeChanged(
856 net::NetworkQualityEstimator::EffectiveConnectionType
857 effective_connection_type) {
858 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread());
859 Java_CronetUrlRequestContext_onEffectiveConnectionTypeChanged(
860 base::android::AttachCurrentThread(), jcronet_url_request_context_.obj(),
861 effective_connection_type);
862 }
863
844 void CronetURLRequestContextAdapter::OnRTTObservation( 864 void CronetURLRequestContextAdapter::OnRTTObservation(
845 int32_t rtt_ms, 865 int32_t rtt_ms,
846 const base::TimeTicks& timestamp, 866 const base::TimeTicks& timestamp,
847 net::NetworkQualityObservationSource source) { 867 net::NetworkQualityObservationSource source) {
848 Java_CronetUrlRequestContext_onRttObservation( 868 Java_CronetUrlRequestContext_onRttObservation(
849 base::android::AttachCurrentThread(), jcronet_url_request_context_.obj(), 869 base::android::AttachCurrentThread(), jcronet_url_request_context_.obj(),
850 rtt_ms, (timestamp - base::TimeTicks::UnixEpoch()).InMilliseconds(), 870 rtt_ms, (timestamp - base::TimeTicks::UnixEpoch()).InMilliseconds(),
851 source); 871 source);
852 } 872 }
853 873
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 JNIEnv* env, 1017 JNIEnv* env,
998 const JavaParamRef<jclass>& jcaller) { 1018 const JavaParamRef<jclass>& jcaller) {
999 base::StatisticsRecorder::Initialize(); 1019 base::StatisticsRecorder::Initialize();
1000 std::vector<uint8_t> data; 1020 std::vector<uint8_t> data;
1001 if (!HistogramManager::GetInstance()->GetDeltas(&data)) 1021 if (!HistogramManager::GetInstance()->GetDeltas(&data))
1002 return ScopedJavaLocalRef<jbyteArray>(); 1022 return ScopedJavaLocalRef<jbyteArray>();
1003 return base::android::ToJavaByteArray(env, &data[0], data.size()); 1023 return base::android::ToJavaByteArray(env, &data[0], data.size());
1004 } 1024 }
1005 1025
1006 } // namespace cronet 1026 } // namespace cronet
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698