| 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 <map> | 9 #include <map> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 } | 256 } |
| 257 | 257 |
| 258 bool OnCanAccessFile(const net::URLRequest& request, | 258 bool OnCanAccessFile(const net::URLRequest& request, |
| 259 const base::FilePath& path) const override { | 259 const base::FilePath& path) const override { |
| 260 return false; | 260 return false; |
| 261 } | 261 } |
| 262 | 262 |
| 263 DISALLOW_COPY_AND_ASSIGN(BasicNetworkDelegate); | 263 DISALLOW_COPY_AND_ASSIGN(BasicNetworkDelegate); |
| 264 }; | 264 }; |
| 265 | 265 |
| 266 // Helper method that takes a Java string that can be null, in which case it |
| 267 // will get converted to an empty string. |
| 268 std::string ConvertNullableJavaStringToUTF8(JNIEnv* env, |
| 269 const JavaParamRef<jstring>& jstr) { |
| 270 std::string str; |
| 271 if (!jstr.is_null()) |
| 272 base::android::ConvertJavaStringToUTF8(env, jstr, &str); |
| 273 return str; |
| 274 } |
| 275 |
| 266 } // namespace | 276 } // namespace |
| 267 | 277 |
| 268 namespace cronet { | 278 namespace cronet { |
| 269 | 279 |
| 270 // Explicitly register static JNI functions. | 280 // Explicitly register static JNI functions. |
| 271 bool CronetUrlRequestContextAdapterRegisterJni(JNIEnv* env) { | 281 bool CronetUrlRequestContextAdapterRegisterJni(JNIEnv* env) { |
| 272 return RegisterNativesImpl(env); | 282 return RegisterNativesImpl(env); |
| 273 } | 283 } |
| 274 | 284 |
| 275 CronetURLRequestContextAdapter::CronetURLRequestContextAdapter( | 285 CronetURLRequestContextAdapter::CronetURLRequestContextAdapter( |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 const JavaParamRef<jstring>& jdata_reduction_proxy_primary_proxy, | 703 const JavaParamRef<jstring>& jdata_reduction_proxy_primary_proxy, |
| 694 const JavaParamRef<jstring>& jdata_reduction_proxy_fallback_proxy, | 704 const JavaParamRef<jstring>& jdata_reduction_proxy_fallback_proxy, |
| 695 const JavaParamRef<jstring>& jdata_reduction_proxy_secure_proxy_check_url, | 705 const JavaParamRef<jstring>& jdata_reduction_proxy_secure_proxy_check_url, |
| 696 jboolean jdisable_cache, | 706 jboolean jdisable_cache, |
| 697 jint jhttp_cache_mode, | 707 jint jhttp_cache_mode, |
| 698 jlong jhttp_cache_max_size, | 708 jlong jhttp_cache_max_size, |
| 699 const JavaParamRef<jstring>& jexperimental_quic_connection_options, | 709 const JavaParamRef<jstring>& jexperimental_quic_connection_options, |
| 700 jlong jmock_cert_verifier) { | 710 jlong jmock_cert_verifier) { |
| 701 return reinterpret_cast<jlong>(new URLRequestContextConfig( | 711 return reinterpret_cast<jlong>(new URLRequestContextConfig( |
| 702 jquic_enabled, | 712 jquic_enabled, |
| 703 base::android::ConvertJavaStringToUTF8(env, jquic_default_user_agent_id), | 713 ConvertNullableJavaStringToUTF8(env, jquic_default_user_agent_id), |
| 704 jhttp2_enabled, jsdch_enabled, | 714 jhttp2_enabled, jsdch_enabled, |
| 705 static_cast<URLRequestContextConfig::HttpCacheType>(jhttp_cache_mode), | 715 static_cast<URLRequestContextConfig::HttpCacheType>(jhttp_cache_mode), |
| 706 jhttp_cache_max_size, jdisable_cache, | 716 jhttp_cache_max_size, jdisable_cache, |
| 707 base::android::ConvertJavaStringToUTF8(env, jstorage_path), | 717 ConvertNullableJavaStringToUTF8(env, jstorage_path), |
| 708 base::android::ConvertJavaStringToUTF8(env, juser_agent), | 718 ConvertNullableJavaStringToUTF8(env, juser_agent), |
| 709 base::android::ConvertJavaStringToUTF8( | 719 ConvertNullableJavaStringToUTF8(env, |
| 710 env, jexperimental_quic_connection_options), | 720 jexperimental_quic_connection_options), |
| 711 base::android::ConvertJavaStringToUTF8(env, jdata_reduction_proxy_key), | 721 ConvertNullableJavaStringToUTF8(env, jdata_reduction_proxy_key), |
| 712 base::android::ConvertJavaStringToUTF8( | 722 ConvertNullableJavaStringToUTF8(env, jdata_reduction_proxy_primary_proxy), |
| 713 env, jdata_reduction_proxy_primary_proxy), | 723 ConvertNullableJavaStringToUTF8(env, |
| 714 base::android::ConvertJavaStringToUTF8( | 724 jdata_reduction_proxy_fallback_proxy), |
| 715 env, jdata_reduction_proxy_fallback_proxy), | 725 ConvertNullableJavaStringToUTF8( |
| 716 base::android::ConvertJavaStringToUTF8( | |
| 717 env, jdata_reduction_proxy_secure_proxy_check_url), | 726 env, jdata_reduction_proxy_secure_proxy_check_url), |
| 718 make_scoped_ptr( | 727 make_scoped_ptr( |
| 719 reinterpret_cast<net::CertVerifier*>(jmock_cert_verifier)))); | 728 reinterpret_cast<net::CertVerifier*>(jmock_cert_verifier)))); |
| 720 } | 729 } |
| 721 | 730 |
| 722 // Add a QUIC hint to a URLRequestContextConfig. | 731 // Add a QUIC hint to a URLRequestContextConfig. |
| 723 static void AddQuicHint(JNIEnv* env, | 732 static void AddQuicHint(JNIEnv* env, |
| 724 const JavaParamRef<jclass>& jcaller, | 733 const JavaParamRef<jclass>& jcaller, |
| 725 jlong jurl_request_context_config, | 734 jlong jurl_request_context_config, |
| 726 const JavaParamRef<jstring>& jhost, | 735 const JavaParamRef<jstring>& jhost, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 JNIEnv* env, | 809 JNIEnv* env, |
| 801 const JavaParamRef<jclass>& jcaller) { | 810 const JavaParamRef<jclass>& jcaller) { |
| 802 base::StatisticsRecorder::Initialize(); | 811 base::StatisticsRecorder::Initialize(); |
| 803 std::vector<uint8_t> data; | 812 std::vector<uint8_t> data; |
| 804 if (!HistogramManager::GetInstance()->GetDeltas(&data)) | 813 if (!HistogramManager::GetInstance()->GetDeltas(&data)) |
| 805 return ScopedJavaLocalRef<jbyteArray>(); | 814 return ScopedJavaLocalRef<jbyteArray>(); |
| 806 return base::android::ToJavaByteArray(env, &data[0], data.size()); | 815 return base::android::ToJavaByteArray(env, &data[0], data.size()); |
| 807 } | 816 } |
| 808 | 817 |
| 809 } // namespace cronet | 818 } // namespace cronet |
| OLD | NEW |