| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/shell/browser/shell_url_request_context_getter.h" | 5 #include "content/shell/browser/shell_url_request_context_getter.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 #if defined(OS_ANDROID) | 184 #if defined(OS_ANDROID) |
| 185 // TODO(rdsmith): Remove when default backend for Android is | 185 // TODO(rdsmith): Remove when default backend for Android is |
| 186 // changed to simple cache. | 186 // changed to simple cache. |
| 187 net::CACHE_BACKEND_SIMPLE, | 187 net::CACHE_BACKEND_SIMPLE, |
| 188 #else | 188 #else |
| 189 net::CACHE_BACKEND_DEFAULT, | 189 net::CACHE_BACKEND_DEFAULT, |
| 190 #endif | 190 #endif |
| 191 cache_path, 0, | 191 cache_path, 0, |
| 192 BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE))); | 192 BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE))); |
| 193 | 193 |
| 194 net::HttpNetworkSession::Context network_session_context; |
| 195 network_session_context.cert_verifier = |
| 196 url_request_context_->cert_verifier(); |
| 197 network_session_context.transport_security_state = |
| 198 url_request_context_->transport_security_state(); |
| 199 network_session_context.cert_transparency_verifier = |
| 200 url_request_context_->cert_transparency_verifier(); |
| 201 network_session_context.ct_policy_enforcer = |
| 202 url_request_context_->ct_policy_enforcer(); |
| 203 network_session_context.channel_id_service = |
| 204 url_request_context_->channel_id_service(); |
| 205 network_session_context.proxy_service = |
| 206 url_request_context_->proxy_service(); |
| 207 network_session_context.ssl_config_service = |
| 208 url_request_context_->ssl_config_service(); |
| 209 network_session_context.http_auth_handler_factory = |
| 210 url_request_context_->http_auth_handler_factory(); |
| 211 network_session_context.http_server_properties = |
| 212 url_request_context_->http_server_properties(); |
| 213 network_session_context.net_log = url_request_context_->net_log(); |
| 214 |
| 194 net::HttpNetworkSession::Params network_session_params; | 215 net::HttpNetworkSession::Params network_session_params; |
| 195 network_session_params.cert_verifier = | |
| 196 url_request_context_->cert_verifier(); | |
| 197 network_session_params.transport_security_state = | |
| 198 url_request_context_->transport_security_state(); | |
| 199 network_session_params.cert_transparency_verifier = | |
| 200 url_request_context_->cert_transparency_verifier(); | |
| 201 network_session_params.ct_policy_enforcer = | |
| 202 url_request_context_->ct_policy_enforcer(); | |
| 203 network_session_params.channel_id_service = | |
| 204 url_request_context_->channel_id_service(); | |
| 205 network_session_params.proxy_service = | |
| 206 url_request_context_->proxy_service(); | |
| 207 network_session_params.ssl_config_service = | |
| 208 url_request_context_->ssl_config_service(); | |
| 209 network_session_params.http_auth_handler_factory = | |
| 210 url_request_context_->http_auth_handler_factory(); | |
| 211 network_session_params.http_server_properties = | |
| 212 url_request_context_->http_server_properties(); | |
| 213 network_session_params.net_log = | |
| 214 url_request_context_->net_log(); | |
| 215 network_session_params.ignore_certificate_errors = | 216 network_session_params.ignore_certificate_errors = |
| 216 ignore_certificate_errors_; | 217 ignore_certificate_errors_; |
| 217 if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) { | 218 if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) { |
| 218 int value; | 219 int value; |
| 219 base::StringToInt(command_line.GetSwitchValueASCII( | 220 base::StringToInt(command_line.GetSwitchValueASCII( |
| 220 switches::kTestingFixedHttpPort), &value); | 221 switches::kTestingFixedHttpPort), &value); |
| 221 network_session_params.testing_fixed_http_port = value; | 222 network_session_params.testing_fixed_http_port = value; |
| 222 } | 223 } |
| 223 if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) { | 224 if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) { |
| 224 int value; | 225 int value; |
| 225 base::StringToInt(command_line.GetSwitchValueASCII( | 226 base::StringToInt(command_line.GetSwitchValueASCII( |
| 226 switches::kTestingFixedHttpsPort), &value); | 227 switches::kTestingFixedHttpsPort), &value); |
| 227 network_session_params.testing_fixed_https_port = value; | 228 network_session_params.testing_fixed_https_port = value; |
| 228 } | 229 } |
| 229 if (command_line.HasSwitch(switches::kHostResolverRules)) { | 230 if (command_line.HasSwitch(switches::kHostResolverRules)) { |
| 230 std::unique_ptr<net::MappedHostResolver> mapped_host_resolver( | 231 std::unique_ptr<net::MappedHostResolver> mapped_host_resolver( |
| 231 new net::MappedHostResolver(std::move(host_resolver))); | 232 new net::MappedHostResolver(std::move(host_resolver))); |
| 232 mapped_host_resolver->SetRulesFromString( | 233 mapped_host_resolver->SetRulesFromString( |
| 233 command_line.GetSwitchValueASCII(switches::kHostResolverRules)); | 234 command_line.GetSwitchValueASCII(switches::kHostResolverRules)); |
| 234 host_resolver = std::move(mapped_host_resolver); | 235 host_resolver = std::move(mapped_host_resolver); |
| 235 } | 236 } |
| 236 | 237 |
| 237 // Give |storage_| ownership at the end in case it's |mapped_host_resolver|. | 238 // Give |storage_| ownership at the end in case it's |mapped_host_resolver|. |
| 238 storage_->set_host_resolver(std::move(host_resolver)); | 239 storage_->set_host_resolver(std::move(host_resolver)); |
| 239 network_session_params.host_resolver = | 240 network_session_context.host_resolver = |
| 240 url_request_context_->host_resolver(); | 241 url_request_context_->host_resolver(); |
| 241 | 242 |
| 242 storage_->set_http_network_session( | 243 storage_->set_http_network_session( |
| 243 base::MakeUnique<net::HttpNetworkSession>(network_session_params)); | 244 base::MakeUnique<net::HttpNetworkSession>(network_session_params, |
| 245 network_session_context)); |
| 244 storage_->set_http_transaction_factory(base::MakeUnique<net::HttpCache>( | 246 storage_->set_http_transaction_factory(base::MakeUnique<net::HttpCache>( |
| 245 storage_->http_network_session(), std::move(main_backend), | 247 storage_->http_network_session(), std::move(main_backend), |
| 246 true /* is_main_cache */)); | 248 true /* is_main_cache */)); |
| 247 | 249 |
| 248 std::unique_ptr<net::URLRequestJobFactoryImpl> job_factory( | 250 std::unique_ptr<net::URLRequestJobFactoryImpl> job_factory( |
| 249 new net::URLRequestJobFactoryImpl()); | 251 new net::URLRequestJobFactoryImpl()); |
| 250 // Keep ProtocolHandlers added in sync with | 252 // Keep ProtocolHandlers added in sync with |
| 251 // ShellContentBrowserClient::IsHandledURL(). | 253 // ShellContentBrowserClient::IsHandledURL(). |
| 252 InstallProtocolHandlers(job_factory.get(), &protocol_handlers_); | 254 InstallProtocolHandlers(job_factory.get(), &protocol_handlers_); |
| 253 bool set_protocol = job_factory->SetProtocolHandler( | 255 bool set_protocol = job_factory->SetProtocolHandler( |
| (...skipping 28 matching lines...) Expand all Loading... |
| 282 scoped_refptr<base::SingleThreadTaskRunner> | 284 scoped_refptr<base::SingleThreadTaskRunner> |
| 283 ShellURLRequestContextGetter::GetNetworkTaskRunner() const { | 285 ShellURLRequestContextGetter::GetNetworkTaskRunner() const { |
| 284 return BrowserThread::GetTaskRunnerForThread(BrowserThread::IO); | 286 return BrowserThread::GetTaskRunnerForThread(BrowserThread::IO); |
| 285 } | 287 } |
| 286 | 288 |
| 287 net::HostResolver* ShellURLRequestContextGetter::host_resolver() { | 289 net::HostResolver* ShellURLRequestContextGetter::host_resolver() { |
| 288 return url_request_context_->host_resolver(); | 290 return url_request_context_->host_resolver(); |
| 289 } | 291 } |
| 290 | 292 |
| 291 } // namespace content | 293 } // namespace content |
| OLD | NEW |