| 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 "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| 11 #include "base/files/scoped_file.h" | 11 #include "base/files/scoped_file.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "components/cronet/url_request_context_config.h" | 15 #include "components/cronet/url_request_context_config.h" |
| 16 #include "jni/CronetUrlRequestContext_jni.h" | 16 #include "jni/CronetUrlRequestContext_jni.h" |
| 17 #include "net/base/load_flags.h" | 17 #include "net/base/load_flags.h" |
| 18 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
| 19 #include "net/base/network_delegate_impl.h" | 19 #include "net/base/network_delegate_impl.h" |
| 20 #include "net/http/http_auth_handler_factory.h" | 20 #include "net/http/http_auth_handler_factory.h" |
| 21 #include "net/log/net_log_logger.h" | 21 #include "net/log/net_log_logger.h" |
| 22 #include "net/proxy/proxy_service.h" | 22 #include "net/proxy/proxy_service.h" |
| 23 #include "net/sdch/sdch_owner.h" |
| 23 #include "net/url_request/url_request_context.h" | 24 #include "net/url_request/url_request_context.h" |
| 24 #include "net/url_request/url_request_context_builder.h" | 25 #include "net/url_request/url_request_context_builder.h" |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 class BasicNetworkDelegate : public net::NetworkDelegateImpl { | 29 class BasicNetworkDelegate : public net::NetworkDelegateImpl { |
| 29 public: | 30 public: |
| 30 BasicNetworkDelegate() {} | 31 BasicNetworkDelegate() {} |
| 31 ~BasicNetworkDelegate() override {} | 32 ~BasicNetworkDelegate() override {} |
| 32 | 33 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 context_builder.set_proxy_config_service(proxy_config_service_.release()); | 155 context_builder.set_proxy_config_service(proxy_config_service_.release()); |
| 155 config->ConfigureURLRequestContextBuilder(&context_builder); | 156 config->ConfigureURLRequestContextBuilder(&context_builder); |
| 156 | 157 |
| 157 context_.reset(context_builder.Build()); | 158 context_.reset(context_builder.Build()); |
| 158 | 159 |
| 159 default_load_flags_ = net::LOAD_DO_NOT_SAVE_COOKIES | | 160 default_load_flags_ = net::LOAD_DO_NOT_SAVE_COOKIES | |
| 160 net::LOAD_DO_NOT_SEND_COOKIES; | 161 net::LOAD_DO_NOT_SEND_COOKIES; |
| 161 if (config->load_disable_cache) | 162 if (config->load_disable_cache) |
| 162 default_load_flags_ |= net::LOAD_DISABLE_CACHE; | 163 default_load_flags_ |= net::LOAD_DISABLE_CACHE; |
| 163 | 164 |
| 165 if (config->enable_sdch) { |
| 166 DCHECK(context_->sdch_manager()); |
| 167 sdch_owner_.reset( |
| 168 new net::SdchOwner(context_->sdch_manager(), context_.get())); |
| 169 } |
| 170 |
| 164 // Currently (circa M39) enabling QUIC requires setting probability threshold. | 171 // Currently (circa M39) enabling QUIC requires setting probability threshold. |
| 165 if (config->enable_quic) { | 172 if (config->enable_quic) { |
| 166 context_->http_server_properties() | 173 context_->http_server_properties() |
| 167 ->SetAlternateProtocolProbabilityThreshold(0.0f); | 174 ->SetAlternateProtocolProbabilityThreshold(0.0f); |
| 168 for (auto hint = config->quic_hints.begin(); | 175 for (auto hint = config->quic_hints.begin(); |
| 169 hint != config->quic_hints.end(); ++hint) { | 176 hint != config->quic_hints.end(); ++hint) { |
| 170 const URLRequestContextConfig::QuicHint& quic_hint = **hint; | 177 const URLRequestContextConfig::QuicHint& quic_hint = **hint; |
| 171 if (quic_hint.host.empty()) { | 178 if (quic_hint.host.empty()) { |
| 172 LOG(ERROR) << "Empty QUIC hint host: " << quic_hint.host; | 179 LOG(ERROR) << "Empty QUIC hint host: " << quic_hint.host; |
| 173 continue; | 180 continue; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 } | 331 } |
| 325 | 332 |
| 326 static jint SetMinLogLevel(JNIEnv* env, jclass jcaller, jint jlog_level) { | 333 static jint SetMinLogLevel(JNIEnv* env, jclass jcaller, jint jlog_level) { |
| 327 jint old_log_level = static_cast<jint>(logging::GetMinLogLevel()); | 334 jint old_log_level = static_cast<jint>(logging::GetMinLogLevel()); |
| 328 // MinLogLevel is global, shared by all URLRequestContexts. | 335 // MinLogLevel is global, shared by all URLRequestContexts. |
| 329 logging::SetMinLogLevel(static_cast<int>(jlog_level)); | 336 logging::SetMinLogLevel(static_cast<int>(jlog_level)); |
| 330 return old_log_level; | 337 return old_log_level; |
| 331 } | 338 } |
| 332 | 339 |
| 333 } // namespace cronet | 340 } // namespace cronet |
| OLD | NEW |