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

Side by Side Diff: components/cronet/android/cronet_url_request_context_adapter.cc

Issue 2839413003: Delete Cronet Data Reduction Proxy integration (Closed)
Patch Set: Created 3 years, 7 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 #include "net/nqe/external_estimate_provider.h" 61 #include "net/nqe/external_estimate_provider.h"
62 #include "net/nqe/network_qualities_prefs_manager.h" 62 #include "net/nqe/network_qualities_prefs_manager.h"
63 #include "net/proxy/proxy_config_service_android.h" 63 #include "net/proxy/proxy_config_service_android.h"
64 #include "net/proxy/proxy_service.h" 64 #include "net/proxy/proxy_service.h"
65 #include "net/sdch/sdch_owner.h" 65 #include "net/sdch/sdch_owner.h"
66 #include "net/ssl/channel_id_service.h" 66 #include "net/ssl/channel_id_service.h"
67 #include "net/url_request/url_request_context.h" 67 #include "net/url_request/url_request_context.h"
68 #include "net/url_request/url_request_context_builder.h" 68 #include "net/url_request/url_request_context_builder.h"
69 #include "net/url_request/url_request_interceptor.h" 69 #include "net/url_request/url_request_interceptor.h"
70 70
71 #if defined(DATA_REDUCTION_PROXY_SUPPORT)
72 #include "components/cronet/android/cronet_data_reduction_proxy.h"
73 #endif
74
75 using base::android::JavaParamRef; 71 using base::android::JavaParamRef;
76 using base::android::ScopedJavaLocalRef; 72 using base::android::ScopedJavaLocalRef;
77 73
78 namespace { 74 namespace {
79 75
80 // Always split NetLog events into 10 files. 76 // Always split NetLog events into 10 files.
81 const int kNumNetLogEventFiles = 10; 77 const int kNumNetLogEventFiles = 10;
82 78
83 // This class wraps a NetLog that also contains network change events. 79 // This class wraps a NetLog that also contains network change events.
84 class NetLogWithNetworkChangeEvents { 80 class NetLogWithNetworkChangeEvents {
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 jcronet_url_request_context) { 604 jcronet_url_request_context) {
609 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); 605 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread());
610 DCHECK(!is_context_initialized_); 606 DCHECK(!is_context_initialized_);
611 DCHECK(proxy_config_service_); 607 DCHECK(proxy_config_service_);
612 608
613 // TODO(mmenke): Add method to have the builder enable SPDY. 609 // TODO(mmenke): Add method to have the builder enable SPDY.
614 net::URLRequestContextBuilder context_builder; 610 net::URLRequestContextBuilder context_builder;
615 611
616 std::unique_ptr<net::NetworkDelegate> network_delegate( 612 std::unique_ptr<net::NetworkDelegate> network_delegate(
617 new BasicNetworkDelegate()); 613 new BasicNetworkDelegate());
618 #if defined(DATA_REDUCTION_PROXY_SUPPORT)
619 DCHECK(!data_reduction_proxy_);
620 // For now, the choice to enable the data reduction proxy happens once,
621 // at initialization. It cannot be disabled thereafter.
622 if (!config->data_reduction_proxy_key.empty()) {
623 data_reduction_proxy_.reset(new CronetDataReductionProxy(
624 config->data_reduction_proxy_key, config->data_reduction_primary_proxy,
625 config->data_reduction_fallback_proxy,
626 config->data_reduction_secure_proxy_check_url, config->user_agent,
627 GetNetworkTaskRunner(), g_net_log.Get().net_log()));
628 network_delegate = data_reduction_proxy_->CreateNetworkDelegate(
629 std::move(network_delegate));
630 context_builder.set_proxy_delegate(
631 data_reduction_proxy_->CreateProxyDelegate());
632 std::vector<std::unique_ptr<net::URLRequestInterceptor>> interceptors;
633 interceptors.push_back(data_reduction_proxy_->CreateInterceptor());
634 context_builder.SetInterceptors(std::move(interceptors));
635 }
636 #endif // defined(DATA_REDUCTION_PROXY_SUPPORT)
637 context_builder.set_network_delegate(std::move(network_delegate)); 614 context_builder.set_network_delegate(std::move(network_delegate));
638 context_builder.set_net_log(g_net_log.Get().net_log()); 615 context_builder.set_net_log(g_net_log.Get().net_log());
639 616
640 // Android provides a local HTTP proxy server that handles proxying when a PAC 617 // Android provides a local HTTP proxy server that handles proxying when a PAC
641 // URL is present. Create a proxy service without a resolver and rely on this 618 // URL is present. Create a proxy service without a resolver and rely on this
642 // local HTTP proxy. See: crbug.com/432539. 619 // local HTTP proxy. See: crbug.com/432539.
643 context_builder.set_proxy_service( 620 context_builder.set_proxy_service(
644 net::ProxyService::CreateWithoutProxyResolver( 621 net::ProxyService::CreateWithoutProxyResolver(
645 std::move(proxy_config_service_), g_net_log.Get().net_log())); 622 std::move(proxy_config_service_), g_net_log.Get().net_log()));
646 623
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 789
813 context_->transport_security_state() 790 context_->transport_security_state()
814 ->SetEnablePublicKeyPinningBypassForLocalTrustAnchors( 791 ->SetEnablePublicKeyPinningBypassForLocalTrustAnchors(
815 config->bypass_public_key_pinning_for_local_trust_anchors); 792 config->bypass_public_key_pinning_for_local_trust_anchors);
816 793
817 JNIEnv* env = base::android::AttachCurrentThread(); 794 JNIEnv* env = base::android::AttachCurrentThread();
818 jcronet_url_request_context_.Reset(env, jcronet_url_request_context.obj()); 795 jcronet_url_request_context_.Reset(env, jcronet_url_request_context.obj());
819 Java_CronetUrlRequestContext_initNetworkThread(env, 796 Java_CronetUrlRequestContext_initNetworkThread(env,
820 jcronet_url_request_context); 797 jcronet_url_request_context);
821 798
822 #if defined(DATA_REDUCTION_PROXY_SUPPORT)
823 if (data_reduction_proxy_)
824 data_reduction_proxy_->Init(true, GetURLRequestContext());
825 #endif
826 is_context_initialized_ = true; 799 is_context_initialized_ = true;
827 while (!tasks_waiting_for_context_.empty()) { 800 while (!tasks_waiting_for_context_.empty()) {
828 tasks_waiting_for_context_.front().Run(); 801 tasks_waiting_for_context_.front().Run();
829 tasks_waiting_for_context_.pop(); 802 tasks_waiting_for_context_.pop();
830 } 803 }
831 } 804 }
832 805
833 void CronetURLRequestContextAdapter::Destroy( 806 void CronetURLRequestContextAdapter::Destroy(
834 JNIEnv* env, 807 JNIEnv* env,
835 const JavaParamRef<jobject>& jcaller) { 808 const JavaParamRef<jobject>& jcaller) {
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 static jlong CreateRequestContextConfig( 1058 static jlong CreateRequestContextConfig(
1086 JNIEnv* env, 1059 JNIEnv* env,
1087 const JavaParamRef<jclass>& jcaller, 1060 const JavaParamRef<jclass>& jcaller,
1088 const JavaParamRef<jstring>& juser_agent, 1061 const JavaParamRef<jstring>& juser_agent,
1089 const JavaParamRef<jstring>& jstorage_path, 1062 const JavaParamRef<jstring>& jstorage_path,
1090 jboolean jquic_enabled, 1063 jboolean jquic_enabled,
1091 const JavaParamRef<jstring>& jquic_default_user_agent_id, 1064 const JavaParamRef<jstring>& jquic_default_user_agent_id,
1092 jboolean jhttp2_enabled, 1065 jboolean jhttp2_enabled,
1093 jboolean jsdch_enabled, 1066 jboolean jsdch_enabled,
1094 jboolean jbrotli_enabled, 1067 jboolean jbrotli_enabled,
1095 const JavaParamRef<jstring>& jdata_reduction_proxy_key,
1096 const JavaParamRef<jstring>& jdata_reduction_proxy_primary_proxy,
1097 const JavaParamRef<jstring>& jdata_reduction_proxy_fallback_proxy,
1098 const JavaParamRef<jstring>& jdata_reduction_proxy_secure_proxy_check_url,
1099 jboolean jdisable_cache, 1068 jboolean jdisable_cache,
1100 jint jhttp_cache_mode, 1069 jint jhttp_cache_mode,
1101 jlong jhttp_cache_max_size, 1070 jlong jhttp_cache_max_size,
1102 const JavaParamRef<jstring>& jexperimental_quic_connection_options, 1071 const JavaParamRef<jstring>& jexperimental_quic_connection_options,
1103 jlong jmock_cert_verifier, 1072 jlong jmock_cert_verifier,
1104 jboolean jenable_network_quality_estimator, 1073 jboolean jenable_network_quality_estimator,
1105 jboolean jbypass_public_key_pinning_for_local_trust_anchors, 1074 jboolean jbypass_public_key_pinning_for_local_trust_anchors,
1106 const JavaParamRef<jstring>& jcert_verifier_data) { 1075 const JavaParamRef<jstring>& jcert_verifier_data) {
1107 return reinterpret_cast<jlong>(new URLRequestContextConfig( 1076 return reinterpret_cast<jlong>(new URLRequestContextConfig(
1108 jquic_enabled, 1077 jquic_enabled,
1109 ConvertNullableJavaStringToUTF8(env, jquic_default_user_agent_id), 1078 ConvertNullableJavaStringToUTF8(env, jquic_default_user_agent_id),
1110 jhttp2_enabled, jsdch_enabled, jbrotli_enabled, 1079 jhttp2_enabled, jsdch_enabled, jbrotli_enabled,
1111 static_cast<URLRequestContextConfig::HttpCacheType>(jhttp_cache_mode), 1080 static_cast<URLRequestContextConfig::HttpCacheType>(jhttp_cache_mode),
1112 jhttp_cache_max_size, jdisable_cache, 1081 jhttp_cache_max_size, jdisable_cache,
1113 ConvertNullableJavaStringToUTF8(env, jstorage_path), 1082 ConvertNullableJavaStringToUTF8(env, jstorage_path),
1114 ConvertNullableJavaStringToUTF8(env, juser_agent), 1083 ConvertNullableJavaStringToUTF8(env, juser_agent),
1115 ConvertNullableJavaStringToUTF8(env, 1084 ConvertNullableJavaStringToUTF8(env,
1116 jexperimental_quic_connection_options), 1085 jexperimental_quic_connection_options),
1117 ConvertNullableJavaStringToUTF8(env, jdata_reduction_proxy_key),
1118 ConvertNullableJavaStringToUTF8(env, jdata_reduction_proxy_primary_proxy),
1119 ConvertNullableJavaStringToUTF8(env,
1120 jdata_reduction_proxy_fallback_proxy),
1121 ConvertNullableJavaStringToUTF8(
1122 env, jdata_reduction_proxy_secure_proxy_check_url),
1123 base::WrapUnique( 1086 base::WrapUnique(
1124 reinterpret_cast<net::CertVerifier*>(jmock_cert_verifier)), 1087 reinterpret_cast<net::CertVerifier*>(jmock_cert_verifier)),
1125 jenable_network_quality_estimator, 1088 jenable_network_quality_estimator,
1126 jbypass_public_key_pinning_for_local_trust_anchors, 1089 jbypass_public_key_pinning_for_local_trust_anchors,
1127 ConvertNullableJavaStringToUTF8(env, jcert_verifier_data))); 1090 ConvertNullableJavaStringToUTF8(env, jcert_verifier_data)));
1128 } 1091 }
1129 1092
1130 // Add a QUIC hint to a URLRequestContextConfig. 1093 // Add a QUIC hint to a URLRequestContextConfig.
1131 static void AddQuicHint(JNIEnv* env, 1094 static void AddQuicHint(JNIEnv* env,
1132 const JavaParamRef<jclass>& jcaller, 1095 const JavaParamRef<jclass>& jcaller,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 JNIEnv* env, 1173 JNIEnv* env,
1211 const JavaParamRef<jclass>& jcaller) { 1174 const JavaParamRef<jclass>& jcaller) {
1212 DCHECK(base::StatisticsRecorder::IsActive()); 1175 DCHECK(base::StatisticsRecorder::IsActive());
1213 std::vector<uint8_t> data; 1176 std::vector<uint8_t> data;
1214 if (!HistogramManager::GetInstance()->GetDeltas(&data)) 1177 if (!HistogramManager::GetInstance()->GetDeltas(&data))
1215 return ScopedJavaLocalRef<jbyteArray>(); 1178 return ScopedJavaLocalRef<jbyteArray>();
1216 return base::android::ToJavaByteArray(env, &data[0], data.size()); 1179 return base::android::ToJavaByteArray(env, &data[0], data.size());
1217 } 1180 }
1218 1181
1219 } // namespace cronet 1182 } // namespace cronet
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698