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

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: 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 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 // Specify the algorithm that should be used for computing the effective
622 // connection type.
623 variation_params["effective_connection_type_algorithm"] =
624 "TransportRTTOrDownstreamThroughput";
619 network_quality_estimator_.reset(new net::NetworkQualityEstimator( 625 network_quality_estimator_.reset(new net::NetworkQualityEstimator(
620 std::unique_ptr<net::ExternalEstimateProvider>(), 626 std::unique_ptr<net::ExternalEstimateProvider>(), variation_params,
621 std::map<std::string, std::string>(), false, false)); 627 false, false));
622 // Set the socket performance watcher factory so that network quality 628 // Set the socket performance watcher factory so that network quality
623 // estimator is notified of socket performance metrics from TCP and QUIC. 629 // estimator is notified of socket performance metrics from TCP and QUIC.
624 context_builder.set_socket_performance_watcher_factory( 630 context_builder.set_socket_performance_watcher_factory(
625 network_quality_estimator_->GetSocketPerformanceWatcherFactory()); 631 network_quality_estimator_->GetSocketPerformanceWatcherFactory());
632 network_quality_estimator_->AddEffectiveConnectionTypeObserver(this);
626 } 633 }
627 634
628 context_ = context_builder.Build(); 635 context_ = context_builder.Build();
629 if (network_quality_estimator_) 636 if (network_quality_estimator_)
630 context_->set_network_quality_estimator(network_quality_estimator_.get()); 637 context_->set_network_quality_estimator(network_quality_estimator_.get());
631 638
632 if (config->load_disable_cache) 639 if (config->load_disable_cache)
633 default_load_flags_ |= net::LOAD_DISABLE_CACHE; 640 default_load_flags_ |= net::LOAD_DISABLE_CACHE;
634 641
635 if (config->enable_sdch) { 642 if (config->enable_sdch) {
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 841
835 base::Thread* CronetURLRequestContextAdapter::GetFileThread() { 842 base::Thread* CronetURLRequestContextAdapter::GetFileThread() {
836 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); 843 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread());
837 if (!file_thread_) { 844 if (!file_thread_) {
838 file_thread_.reset(new base::Thread("Network File Thread")); 845 file_thread_.reset(new base::Thread("Network File Thread"));
839 file_thread_->Start(); 846 file_thread_->Start();
840 } 847 }
841 return file_thread_.get(); 848 return file_thread_.get();
842 } 849 }
843 850
851 void CronetURLRequestContextAdapter::OnEffectiveConnectionTypeChanged(
852 net::NetworkQualityEstimator::EffectiveConnectionType
853 effective_connection_type) {
854 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread());
855 Java_CronetUrlRequestContext_onEffectiveConnectionTypeChanged(
856 base::android::AttachCurrentThread(), jcronet_url_request_context_.obj(),
857 effective_connection_type);
858 }
859
844 void CronetURLRequestContextAdapter::OnRTTObservation( 860 void CronetURLRequestContextAdapter::OnRTTObservation(
845 int32_t rtt_ms, 861 int32_t rtt_ms,
846 const base::TimeTicks& timestamp, 862 const base::TimeTicks& timestamp,
847 net::NetworkQualityObservationSource source) { 863 net::NetworkQualityObservationSource source) {
848 Java_CronetUrlRequestContext_onRttObservation( 864 Java_CronetUrlRequestContext_onRttObservation(
849 base::android::AttachCurrentThread(), jcronet_url_request_context_.obj(), 865 base::android::AttachCurrentThread(), jcronet_url_request_context_.obj(),
850 rtt_ms, (timestamp - base::TimeTicks::UnixEpoch()).InMilliseconds(), 866 rtt_ms, (timestamp - base::TimeTicks::UnixEpoch()).InMilliseconds(),
851 source); 867 source);
852 } 868 }
853 869
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 JNIEnv* env, 1013 JNIEnv* env,
998 const JavaParamRef<jclass>& jcaller) { 1014 const JavaParamRef<jclass>& jcaller) {
999 base::StatisticsRecorder::Initialize(); 1015 base::StatisticsRecorder::Initialize();
1000 std::vector<uint8_t> data; 1016 std::vector<uint8_t> data;
1001 if (!HistogramManager::GetInstance()->GetDeltas(&data)) 1017 if (!HistogramManager::GetInstance()->GetDeltas(&data))
1002 return ScopedJavaLocalRef<jbyteArray>(); 1018 return ScopedJavaLocalRef<jbyteArray>();
1003 return base::android::ToJavaByteArray(env, &data[0], data.size()); 1019 return base::android::ToJavaByteArray(env, &data[0], data.size());
1004 } 1020 }
1005 1021
1006 } // namespace cronet 1022 } // namespace cronet
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698