| OLD | NEW |
| 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 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 // is specified using the key-value pairs defined in | 683 // is specified using the key-value pairs defined in |
| 684 // //net/nqe/network_quality_estimator.cc. | 684 // //net/nqe/network_quality_estimator.cc. |
| 685 // TODO(tbansal): Investigate a more robust way of configuring the network | 685 // TODO(tbansal): Investigate a more robust way of configuring the network |
| 686 // quality estimator. | 686 // quality estimator. |
| 687 variation_params["effective_connection_type_algorithm"] = | 687 variation_params["effective_connection_type_algorithm"] = |
| 688 "TransportRTTOrDownstreamThroughput"; | 688 "TransportRTTOrDownstreamThroughput"; |
| 689 network_quality_estimator_ = base::MakeUnique<net::NetworkQualityEstimator>( | 689 network_quality_estimator_ = base::MakeUnique<net::NetworkQualityEstimator>( |
| 690 std::unique_ptr<net::ExternalEstimateProvider>(), | 690 std::unique_ptr<net::ExternalEstimateProvider>(), |
| 691 base::MakeUnique<net::NetworkQualityEstimatorParams>(variation_params), | 691 base::MakeUnique<net::NetworkQualityEstimatorParams>(variation_params), |
| 692 g_net_log.Get().net_log()); | 692 g_net_log.Get().net_log()); |
| 693 // Set the socket performance watcher factory so that network quality | |
| 694 // estimator is notified of socket performance metrics from TCP and QUIC. | |
| 695 context_builder.set_socket_performance_watcher_factory( | |
| 696 network_quality_estimator_->GetSocketPerformanceWatcherFactory()); | |
| 697 network_quality_estimator_->AddEffectiveConnectionTypeObserver(this); | 693 network_quality_estimator_->AddEffectiveConnectionTypeObserver(this); |
| 698 network_quality_estimator_->AddRTTAndThroughputEstimatesObserver(this); | 694 network_quality_estimator_->AddRTTAndThroughputEstimatesObserver(this); |
| 699 | 695 |
| 700 // Set up network quality prefs if the storage path is specified. | 696 // Set up network quality prefs if the storage path is specified. |
| 701 if (!config->storage_path.empty()) { | 697 if (!config->storage_path.empty()) { |
| 702 DCHECK(!network_qualities_prefs_manager_); | 698 DCHECK(!network_qualities_prefs_manager_); |
| 703 network_qualities_prefs_manager_ = | 699 network_qualities_prefs_manager_ = |
| 704 base::MakeUnique<net::NetworkQualitiesPrefsManager>( | 700 base::MakeUnique<net::NetworkQualitiesPrefsManager>( |
| 705 base::MakeUnique<NetworkQualitiesPrefDelegateImpl>( | 701 base::MakeUnique<NetworkQualitiesPrefDelegateImpl>( |
| 706 pref_service_.get())); | 702 pref_service_.get())); |
| 707 network_qualities_prefs_manager_->InitializeOnNetworkThread( | 703 network_qualities_prefs_manager_->InitializeOnNetworkThread( |
| 708 network_quality_estimator_.get()); | 704 network_quality_estimator_.get()); |
| 709 } | 705 } |
| 706 context_builder.set_network_quality_estimator( |
| 707 network_quality_estimator_.get()); |
| 710 } | 708 } |
| 711 | 709 |
| 712 context_ = context_builder.Build(); | 710 context_ = context_builder.Build(); |
| 713 | 711 |
| 714 context_->set_check_cleartext_permitted(true); | 712 context_->set_check_cleartext_permitted(true); |
| 715 context_->set_enable_brotli(config->enable_brotli); | 713 context_->set_enable_brotli(config->enable_brotli); |
| 716 | 714 |
| 717 if (network_quality_estimator_) | |
| 718 context_->set_network_quality_estimator(network_quality_estimator_.get()); | |
| 719 | |
| 720 if (config->load_disable_cache) | 715 if (config->load_disable_cache) |
| 721 default_load_flags_ |= net::LOAD_DISABLE_CACHE; | 716 default_load_flags_ |= net::LOAD_DISABLE_CACHE; |
| 722 | 717 |
| 723 if (config->enable_sdch) { | 718 if (config->enable_sdch) { |
| 724 DCHECK(context_->sdch_manager()); | 719 DCHECK(context_->sdch_manager()); |
| 725 sdch_owner_.reset( | 720 sdch_owner_.reset( |
| 726 new net::SdchOwner(context_->sdch_manager(), context_.get())); | 721 new net::SdchOwner(context_->sdch_manager(), context_.get())); |
| 727 if (json_pref_store_) { | 722 if (json_pref_store_) { |
| 728 sdch_owner_->EnablePersistentStorage( | 723 sdch_owner_->EnablePersistentStorage( |
| 729 base::MakeUnique<SdchOwnerPrefStorage>(json_pref_store_.get())); | 724 base::MakeUnique<SdchOwnerPrefStorage>(json_pref_store_.get())); |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 JNIEnv* env, | 1172 JNIEnv* env, |
| 1178 const JavaParamRef<jclass>& jcaller) { | 1173 const JavaParamRef<jclass>& jcaller) { |
| 1179 DCHECK(base::StatisticsRecorder::IsActive()); | 1174 DCHECK(base::StatisticsRecorder::IsActive()); |
| 1180 std::vector<uint8_t> data; | 1175 std::vector<uint8_t> data; |
| 1181 if (!HistogramManager::GetInstance()->GetDeltas(&data)) | 1176 if (!HistogramManager::GetInstance()->GetDeltas(&data)) |
| 1182 return ScopedJavaLocalRef<jbyteArray>(); | 1177 return ScopedJavaLocalRef<jbyteArray>(); |
| 1183 return base::android::ToJavaByteArray(env, &data[0], data.size()); | 1178 return base::android::ToJavaByteArray(env, &data[0], data.size()); |
| 1184 } | 1179 } |
| 1185 | 1180 |
| 1186 } // namespace cronet | 1181 } // namespace cronet |
| OLD | NEW |