| 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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); | 420 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); |
| 421 | 421 |
| 422 if (http_server_properties_manager_) | 422 if (http_server_properties_manager_) |
| 423 http_server_properties_manager_->ShutdownOnPrefThread(); | 423 http_server_properties_manager_->ShutdownOnPrefThread(); |
| 424 if (pref_service_) | 424 if (pref_service_) |
| 425 pref_service_->CommitPendingWrite(); | 425 pref_service_->CommitPendingWrite(); |
| 426 if (network_quality_estimator_) { | 426 if (network_quality_estimator_) { |
| 427 network_quality_estimator_->RemoveRTTObserver(this); | 427 network_quality_estimator_->RemoveRTTObserver(this); |
| 428 network_quality_estimator_->RemoveThroughputObserver(this); | 428 network_quality_estimator_->RemoveThroughputObserver(this); |
| 429 network_quality_estimator_->RemoveEffectiveConnectionTypeObserver(this); | 429 network_quality_estimator_->RemoveEffectiveConnectionTypeObserver(this); |
| 430 network_quality_estimator_->RemoveRTTAndThroughputEstimatesObserver(this); |
| 430 } | 431 } |
| 431 | 432 |
| 432 // Stop NetLog observer if there is one. | 433 // Stop NetLog observer if there is one. |
| 433 StopNetLogHelper(); | 434 StopNetLogHelper(); |
| 434 } | 435 } |
| 435 | 436 |
| 436 void CronetURLRequestContextAdapter::InitRequestContextOnMainThread( | 437 void CronetURLRequestContextAdapter::InitRequestContextOnMainThread( |
| 437 JNIEnv* env, | 438 JNIEnv* env, |
| 438 const JavaParamRef<jobject>& jcaller) { | 439 const JavaParamRef<jobject>& jcaller) { |
| 439 base::android::ScopedJavaGlobalRef<jobject> jcaller_ref; | 440 base::android::ScopedJavaGlobalRef<jobject> jcaller_ref; |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 variation_params["effective_connection_type_algorithm"] = | 620 variation_params["effective_connection_type_algorithm"] = |
| 620 "TransportRTTOrDownstreamThroughput"; | 621 "TransportRTTOrDownstreamThroughput"; |
| 621 network_quality_estimator_.reset(new net::NetworkQualityEstimator( | 622 network_quality_estimator_.reset(new net::NetworkQualityEstimator( |
| 622 std::unique_ptr<net::ExternalEstimateProvider>(), variation_params, | 623 std::unique_ptr<net::ExternalEstimateProvider>(), variation_params, |
| 623 false, false)); | 624 false, false)); |
| 624 // Set the socket performance watcher factory so that network quality | 625 // Set the socket performance watcher factory so that network quality |
| 625 // estimator is notified of socket performance metrics from TCP and QUIC. | 626 // estimator is notified of socket performance metrics from TCP and QUIC. |
| 626 context_builder.set_socket_performance_watcher_factory( | 627 context_builder.set_socket_performance_watcher_factory( |
| 627 network_quality_estimator_->GetSocketPerformanceWatcherFactory()); | 628 network_quality_estimator_->GetSocketPerformanceWatcherFactory()); |
| 628 network_quality_estimator_->AddEffectiveConnectionTypeObserver(this); | 629 network_quality_estimator_->AddEffectiveConnectionTypeObserver(this); |
| 630 network_quality_estimator_->AddRTTAndThroughputEstimatesObserver(this); |
| 629 } | 631 } |
| 630 | 632 |
| 631 context_ = context_builder.Build(); | 633 context_ = context_builder.Build(); |
| 632 if (network_quality_estimator_) | 634 if (network_quality_estimator_) |
| 633 context_->set_network_quality_estimator(network_quality_estimator_.get()); | 635 context_->set_network_quality_estimator(network_quality_estimator_.get()); |
| 634 | 636 |
| 635 if (config->load_disable_cache) | 637 if (config->load_disable_cache) |
| 636 default_load_flags_ |= net::LOAD_DISABLE_CACHE; | 638 default_load_flags_ |= net::LOAD_DISABLE_CACHE; |
| 637 | 639 |
| 638 if (config->enable_sdch) { | 640 if (config->enable_sdch) { |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 } | 866 } |
| 865 | 867 |
| 866 void CronetURLRequestContextAdapter::OnEffectiveConnectionTypeChanged( | 868 void CronetURLRequestContextAdapter::OnEffectiveConnectionTypeChanged( |
| 867 net::EffectiveConnectionType effective_connection_type) { | 869 net::EffectiveConnectionType effective_connection_type) { |
| 868 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); | 870 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); |
| 869 Java_CronetUrlRequestContext_onEffectiveConnectionTypeChanged( | 871 Java_CronetUrlRequestContext_onEffectiveConnectionTypeChanged( |
| 870 base::android::AttachCurrentThread(), jcronet_url_request_context_.obj(), | 872 base::android::AttachCurrentThread(), jcronet_url_request_context_.obj(), |
| 871 effective_connection_type); | 873 effective_connection_type); |
| 872 } | 874 } |
| 873 | 875 |
| 876 void CronetURLRequestContextAdapter::OnRTTOrThroughputEstimatesComputed( |
| 877 base::TimeDelta http_rtt, |
| 878 base::TimeDelta transport_rtt, |
| 879 int32_t downstream_throughput_kbps) { |
| 880 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); |
| 881 |
| 882 int32_t http_rtt_ms = http_rtt.InMilliseconds() <= INT32_MAX |
| 883 ? static_cast<int32_t>(http_rtt.InMilliseconds()) |
| 884 : INT32_MAX; |
| 885 int32_t transport_rtt_ms = |
| 886 transport_rtt.InMilliseconds() <= INT32_MAX |
| 887 ? static_cast<int32_t>(transport_rtt.InMilliseconds()) |
| 888 : INT32_MAX; |
| 889 |
| 890 Java_CronetUrlRequestContext_onRTTOrThroughputEstimatesComputed( |
| 891 base::android::AttachCurrentThread(), jcronet_url_request_context_.obj(), |
| 892 http_rtt_ms, transport_rtt_ms, downstream_throughput_kbps); |
| 893 } |
| 894 |
| 874 void CronetURLRequestContextAdapter::OnRTTObservation( | 895 void CronetURLRequestContextAdapter::OnRTTObservation( |
| 875 int32_t rtt_ms, | 896 int32_t rtt_ms, |
| 876 const base::TimeTicks& timestamp, | 897 const base::TimeTicks& timestamp, |
| 877 net::NetworkQualityObservationSource source) { | 898 net::NetworkQualityObservationSource source) { |
| 878 Java_CronetUrlRequestContext_onRttObservation( | 899 Java_CronetUrlRequestContext_onRttObservation( |
| 879 base::android::AttachCurrentThread(), jcronet_url_request_context_, | 900 base::android::AttachCurrentThread(), jcronet_url_request_context_, |
| 880 rtt_ms, (timestamp - base::TimeTicks::UnixEpoch()).InMilliseconds(), | 901 rtt_ms, (timestamp - base::TimeTicks::UnixEpoch()).InMilliseconds(), |
| 881 source); | 902 source); |
| 882 } | 903 } |
| 883 | 904 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1073 JNIEnv* env, | 1094 JNIEnv* env, |
| 1074 const JavaParamRef<jclass>& jcaller) { | 1095 const JavaParamRef<jclass>& jcaller) { |
| 1075 base::StatisticsRecorder::Initialize(); | 1096 base::StatisticsRecorder::Initialize(); |
| 1076 std::vector<uint8_t> data; | 1097 std::vector<uint8_t> data; |
| 1077 if (!HistogramManager::GetInstance()->GetDeltas(&data)) | 1098 if (!HistogramManager::GetInstance()->GetDeltas(&data)) |
| 1078 return ScopedJavaLocalRef<jbyteArray>(); | 1099 return ScopedJavaLocalRef<jbyteArray>(); |
| 1079 return base::android::ToJavaByteArray(env, &data[0], data.size()); | 1100 return base::android::ToJavaByteArray(env, &data[0], data.size()); |
| 1080 } | 1101 } |
| 1081 | 1102 |
| 1082 } // namespace cronet | 1103 } // namespace cronet |
| OLD | NEW |