OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "android_webview/browser/net/aw_url_request_context_getter.h" | 5 #include "android_webview/browser/net/aw_url_request_context_getter.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "android_webview/browser/aw_browser_context.h" | 9 #include "android_webview/browser/aw_browser_context.h" |
10 #include "android_webview/browser/aw_content_browser_client.h" | 10 #include "android_webview/browser/aw_content_browser_client.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) { | 81 if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) { |
82 base::StringToInt(command_line.GetSwitchValueASCII( | 82 base::StringToInt(command_line.GetSwitchValueASCII( |
83 switches::kTestingFixedHttpsPort), &value); | 83 switches::kTestingFixedHttpsPort), &value); |
84 params->testing_fixed_https_port = value; | 84 params->testing_fixed_https_port = value; |
85 } | 85 } |
86 if (command_line.HasSwitch(switches::kIgnoreCertificateErrors)) { | 86 if (command_line.HasSwitch(switches::kIgnoreCertificateErrors)) { |
87 params->ignore_certificate_errors = true; | 87 params->ignore_certificate_errors = true; |
88 } | 88 } |
89 } | 89 } |
90 | 90 |
91 void PopulateNetworkSessionParams( | |
92 net::URLRequestContext* context, | |
93 net::HttpNetworkSession::Params* params) { | |
94 params->host_resolver = context->host_resolver(); | |
95 params->cert_verifier = context->cert_verifier(); | |
96 params->channel_id_service = context->channel_id_service(); | |
97 params->transport_security_state = context->transport_security_state(); | |
98 params->proxy_service = context->proxy_service(); | |
99 params->ssl_config_service = context->ssl_config_service(); | |
100 params->http_auth_handler_factory = context->http_auth_handler_factory(); | |
101 params->network_delegate = context->network_delegate(); | |
102 params->http_server_properties = context->http_server_properties(); | |
103 params->net_log = context->net_log(); | |
104 // TODO(sgurun) remove once crbug.com/329681 is fixed. | |
105 params->next_protos = net::NextProtosSpdy31(); | |
106 params->use_alternative_services = true; | |
107 | |
108 ApplyCmdlineOverridesToNetworkSessionParams(params); | |
109 } | |
110 | |
111 scoped_ptr<net::URLRequestJobFactory> CreateJobFactory( | 91 scoped_ptr<net::URLRequestJobFactory> CreateJobFactory( |
112 content::ProtocolHandlerMap* protocol_handlers, | 92 content::ProtocolHandlerMap* protocol_handlers, |
113 content::URLRequestInterceptorScopedVector request_interceptors) { | 93 content::URLRequestInterceptorScopedVector request_interceptors) { |
114 scoped_ptr<AwURLRequestJobFactory> aw_job_factory(new AwURLRequestJobFactory); | 94 scoped_ptr<AwURLRequestJobFactory> aw_job_factory(new AwURLRequestJobFactory); |
115 // Note that the registered schemes must also be specified in | 95 // Note that the registered schemes must also be specified in |
116 // AwContentBrowserClient::IsHandledURL. | 96 // AwContentBrowserClient::IsHandledURL. |
117 bool set_protocol = aw_job_factory->SetProtocolHandler( | 97 bool set_protocol = aw_job_factory->SetProtocolHandler( |
118 url::kFileScheme, | 98 url::kFileScheme, |
119 make_scoped_ptr(new net::FileProtocolHandler( | 99 make_scoped_ptr(new net::FileProtocolHandler( |
120 content::BrowserThread::GetBlockingPool() | 100 content::BrowserThread::GetBlockingPool() |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
213 builder.set_ftp_enabled(false); // Android WebView does not support ftp yet. | 193 builder.set_ftp_enabled(false); // Android WebView does not support ftp yet. |
214 #endif | 194 #endif |
215 DCHECK(proxy_config_service_.get()); | 195 DCHECK(proxy_config_service_.get()); |
216 // Android provides a local HTTP proxy that handles all the proxying. | 196 // Android provides a local HTTP proxy that handles all the proxying. |
217 // Create the proxy without a resolver since we rely on this local HTTP proxy. | 197 // Create the proxy without a resolver since we rely on this local HTTP proxy. |
218 // TODO(sgurun) is this behavior guaranteed through SDK? | 198 // TODO(sgurun) is this behavior guaranteed through SDK? |
219 builder.set_proxy_service(net::ProxyService::CreateWithoutProxyResolver( | 199 builder.set_proxy_service(net::ProxyService::CreateWithoutProxyResolver( |
220 proxy_config_service_.Pass(), net_log_.get())); | 200 proxy_config_service_.Pass(), net_log_.get())); |
221 builder.set_net_log(net_log_.get()); | 201 builder.set_net_log(net_log_.get()); |
222 builder.SetCookieAndChannelIdStores(cookie_store_, NULL); | 202 builder.SetCookieAndChannelIdStores(cookie_store_, NULL); |
203 | |
204 net::URLRequestContextBuilder::HttpCacheParams cache_params; | |
205 cache_params.type = | |
206 net::URLRequestContextBuilder::HttpCacheParams::DISK_SIMPLE; | |
207 cache_params.max_size = 20 * 1024 * 1024; // 20M | |
208 cache_params.path = cache_path_; | |
209 builder.EnableHttpCache(cache_params); | |
210 builder.SetFileTaskRunner( | |
211 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)); | |
212 | |
213 net::HttpNetworkSession::Params network_session_params; | |
214 ApplyCmdlineOverridesToNetworkSessionParams(&network_session_params); | |
mmenke
2015/11/17 17:22:45
Bug: This isn't doing anything.
You can set thes
mnaganov (inactive)
2015/11/17 19:01:38
*facepalm* Right, I knew I must call it, but someh
| |
215 builder.SetSpdyAndQuicEnabled(true, true); | |
sgurun-gerrit only
2015/11/17 08:19:12
This makes me realize that... Quic is probably alr
sgurun-gerrit only
2015/11/17 18:06:31
also as mmenke pointed out this enables http2, whi
mnaganov (inactive)
2015/11/17 19:01:39
I confused use_alternative_services with Quic. The
| |
223 ApplyCmdlineOverridesToURLRequestContextBuilder(&builder); | 216 ApplyCmdlineOverridesToURLRequestContextBuilder(&builder); |
224 | |
225 url_request_context_ = builder.Build().Pass(); | 217 url_request_context_ = builder.Build().Pass(); |
226 // TODO(mnaganov): Fix URLRequestContextBuilder to use proper threads. | |
227 net::HttpNetworkSession::Params network_session_params; | |
228 | |
229 PopulateNetworkSessionParams(url_request_context_.get(), | |
230 &network_session_params); | |
231 | |
232 http_network_session_.reset( | |
233 new net::HttpNetworkSession(network_session_params)); | |
234 main_http_factory_.reset(new net::HttpCache( | |
235 http_network_session_.get(), | |
236 make_scoped_ptr(new net::HttpCache::DefaultBackend( | |
237 net::DISK_CACHE, | |
238 net::CACHE_BACKEND_SIMPLE, | |
239 cache_path_, | |
240 20 * 1024 * 1024, // 20M | |
241 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE))), | |
242 true /* set_up_quic_server_info */)); | |
243 | |
244 url_request_context_->set_http_transaction_factory(main_http_factory_.get()); | |
245 | 218 |
246 job_factory_ = CreateJobFactory(&protocol_handlers_, | 219 job_factory_ = CreateJobFactory(&protocol_handlers_, |
247 request_interceptors_.Pass()); | 220 request_interceptors_.Pass()); |
248 | |
249 job_factory_.reset(new net::URLRequestInterceptingJobFactory( | 221 job_factory_.reset(new net::URLRequestInterceptingJobFactory( |
250 job_factory_.Pass(), | 222 job_factory_.Pass(), |
251 browser_context->GetDataReductionProxyIOData()->CreateInterceptor())); | 223 browser_context->GetDataReductionProxyIOData()->CreateInterceptor())); |
252 url_request_context_->set_job_factory(job_factory_.get()); | 224 url_request_context_->set_job_factory(job_factory_.get()); |
253 url_request_context_->set_http_user_agent_settings( | 225 url_request_context_->set_http_user_agent_settings( |
254 http_user_agent_settings_.get()); | 226 http_user_agent_settings_.get()); |
255 } | 227 } |
256 | 228 |
257 net::URLRequestContext* AwURLRequestContextGetter::GetURLRequestContext() { | 229 net::URLRequestContext* AwURLRequestContextGetter::GetURLRequestContext() { |
258 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 230 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
(...skipping 19 matching lines...) Expand all Loading... | |
278 return net_log_.get(); | 250 return net_log_.get(); |
279 } | 251 } |
280 | 252 |
281 void AwURLRequestContextGetter::SetKeyOnIO(const std::string& key) { | 253 void AwURLRequestContextGetter::SetKeyOnIO(const std::string& key) { |
282 DCHECK(AwBrowserContext::GetDefault()->GetDataReductionProxyIOData()); | 254 DCHECK(AwBrowserContext::GetDefault()->GetDataReductionProxyIOData()); |
283 AwBrowserContext::GetDefault()->GetDataReductionProxyIOData()-> | 255 AwBrowserContext::GetDefault()->GetDataReductionProxyIOData()-> |
284 request_options()->SetKeyOnIO(key); | 256 request_options()->SetKeyOnIO(key); |
285 } | 257 } |
286 | 258 |
287 } // namespace android_webview | 259 } // namespace android_webview |
OLD | NEW |