| 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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); | 406 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); |
| 407 | 407 |
| 408 if (http_server_properties_manager_) | 408 if (http_server_properties_manager_) |
| 409 http_server_properties_manager_->ShutdownOnPrefThread(); | 409 http_server_properties_manager_->ShutdownOnPrefThread(); |
| 410 if (pref_service_) | 410 if (pref_service_) |
| 411 pref_service_->CommitPendingWrite(); | 411 pref_service_->CommitPendingWrite(); |
| 412 if (network_quality_estimator_) { | 412 if (network_quality_estimator_) { |
| 413 network_quality_estimator_->RemoveRTTObserver(this); | 413 network_quality_estimator_->RemoveRTTObserver(this); |
| 414 network_quality_estimator_->RemoveThroughputObserver(this); | 414 network_quality_estimator_->RemoveThroughputObserver(this); |
| 415 } | 415 } |
| 416 // Stop |write_to_file_observer_| if there is one. |
| 417 StopNetLogHelper(); |
| 416 } | 418 } |
| 417 | 419 |
| 418 void CronetURLRequestContextAdapter::InitRequestContextOnMainThread( | 420 void CronetURLRequestContextAdapter::InitRequestContextOnMainThread( |
| 419 JNIEnv* env, | 421 JNIEnv* env, |
| 420 const JavaParamRef<jobject>& jcaller) { | 422 const JavaParamRef<jobject>& jcaller) { |
| 421 base::android::ScopedJavaGlobalRef<jobject> jcaller_ref; | 423 base::android::ScopedJavaGlobalRef<jobject> jcaller_ref; |
| 422 jcaller_ref.Reset(env, jcaller); | 424 jcaller_ref.Reset(env, jcaller); |
| 423 proxy_config_service_ = net::ProxyService::CreateSystemProxyConfigService( | 425 proxy_config_service_ = net::ProxyService::CreateSystemProxyConfigService( |
| 424 GetNetworkTaskRunner(), nullptr /* Ignored on Android */); | 426 GetNetworkTaskRunner(), nullptr /* Ignored on Android */); |
| 425 net::ProxyConfigServiceAndroid* android_proxy_config_service = | 427 net::ProxyConfigServiceAndroid* android_proxy_config_service = |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 net::NetLogCaptureMode::IncludeSocketBytes()); | 774 net::NetLogCaptureMode::IncludeSocketBytes()); |
| 773 } | 775 } |
| 774 write_to_file_observer_->StartObserving( | 776 write_to_file_observer_->StartObserving( |
| 775 g_net_log.Get().net_log(), std::move(file), | 777 g_net_log.Get().net_log(), std::move(file), |
| 776 /*constants=*/nullptr, /*url_request_context=*/nullptr); | 778 /*constants=*/nullptr, /*url_request_context=*/nullptr); |
| 777 } | 779 } |
| 778 | 780 |
| 779 void CronetURLRequestContextAdapter::StopNetLog( | 781 void CronetURLRequestContextAdapter::StopNetLog( |
| 780 JNIEnv* env, | 782 JNIEnv* env, |
| 781 const JavaParamRef<jobject>& jcaller) { | 783 const JavaParamRef<jobject>& jcaller) { |
| 782 base::AutoLock lock(write_to_file_observer_lock_); | 784 StopNetLogHelper(); |
| 783 if (write_to_file_observer_) { | |
| 784 write_to_file_observer_->StopObserving(/*url_request_context=*/nullptr); | |
| 785 write_to_file_observer_.reset(); | |
| 786 } | |
| 787 } | 785 } |
| 788 | 786 |
| 789 base::Thread* CronetURLRequestContextAdapter::GetFileThread() { | 787 base::Thread* CronetURLRequestContextAdapter::GetFileThread() { |
| 790 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); | 788 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); |
| 791 if (!file_thread_) { | 789 if (!file_thread_) { |
| 792 file_thread_.reset(new base::Thread("Network File Thread")); | 790 file_thread_.reset(new base::Thread("Network File Thread")); |
| 793 file_thread_->Start(); | 791 file_thread_->Start(); |
| 794 } | 792 } |
| 795 return file_thread_.get(); | 793 return file_thread_.get(); |
| 796 } | 794 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 808 void CronetURLRequestContextAdapter::OnThroughputObservation( | 806 void CronetURLRequestContextAdapter::OnThroughputObservation( |
| 809 int32_t throughput_kbps, | 807 int32_t throughput_kbps, |
| 810 const base::TimeTicks& timestamp, | 808 const base::TimeTicks& timestamp, |
| 811 net::NetworkQualityObservationSource source) { | 809 net::NetworkQualityObservationSource source) { |
| 812 Java_CronetUrlRequestContext_onThroughputObservation( | 810 Java_CronetUrlRequestContext_onThroughputObservation( |
| 813 base::android::AttachCurrentThread(), jcronet_url_request_context_.obj(), | 811 base::android::AttachCurrentThread(), jcronet_url_request_context_.obj(), |
| 814 throughput_kbps, | 812 throughput_kbps, |
| 815 (timestamp - base::TimeTicks::UnixEpoch()).InMilliseconds(), source); | 813 (timestamp - base::TimeTicks::UnixEpoch()).InMilliseconds(), source); |
| 816 } | 814 } |
| 817 | 815 |
| 816 void CronetURLRequestContextAdapter::StopNetLogHelper() { |
| 817 base::AutoLock lock(write_to_file_observer_lock_); |
| 818 if (write_to_file_observer_) { |
| 819 write_to_file_observer_->StopObserving(/*url_request_context=*/nullptr); |
| 820 write_to_file_observer_.reset(); |
| 821 } |
| 822 } |
| 823 |
| 818 // Create a URLRequestContextConfig from the given parameters. | 824 // Create a URLRequestContextConfig from the given parameters. |
| 819 static jlong CreateRequestContextConfig( | 825 static jlong CreateRequestContextConfig( |
| 820 JNIEnv* env, | 826 JNIEnv* env, |
| 821 const JavaParamRef<jclass>& jcaller, | 827 const JavaParamRef<jclass>& jcaller, |
| 822 const JavaParamRef<jstring>& juser_agent, | 828 const JavaParamRef<jstring>& juser_agent, |
| 823 const JavaParamRef<jstring>& jstorage_path, | 829 const JavaParamRef<jstring>& jstorage_path, |
| 824 jboolean jquic_enabled, | 830 jboolean jquic_enabled, |
| 825 const JavaParamRef<jstring>& jquic_default_user_agent_id, | 831 const JavaParamRef<jstring>& jquic_default_user_agent_id, |
| 826 jboolean jhttp2_enabled, | 832 jboolean jhttp2_enabled, |
| 827 jboolean jsdch_enabled, | 833 jboolean jsdch_enabled, |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 JNIEnv* env, | 945 JNIEnv* env, |
| 940 const JavaParamRef<jclass>& jcaller) { | 946 const JavaParamRef<jclass>& jcaller) { |
| 941 base::StatisticsRecorder::Initialize(); | 947 base::StatisticsRecorder::Initialize(); |
| 942 std::vector<uint8_t> data; | 948 std::vector<uint8_t> data; |
| 943 if (!HistogramManager::GetInstance()->GetDeltas(&data)) | 949 if (!HistogramManager::GetInstance()->GetDeltas(&data)) |
| 944 return ScopedJavaLocalRef<jbyteArray>(); | 950 return ScopedJavaLocalRef<jbyteArray>(); |
| 945 return base::android::ToJavaByteArray(env, &data[0], data.size()); | 951 return base::android::ToJavaByteArray(env, &data[0], data.size()); |
| 946 } | 952 } |
| 947 | 953 |
| 948 } // namespace cronet | 954 } // namespace cronet |
| OLD | NEW |