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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 | 175 |
176 return job_factory.Pass(); | 176 return job_factory.Pass(); |
177 } | 177 } |
178 | 178 |
179 } // namespace | 179 } // namespace |
180 | 180 |
181 AwURLRequestContextGetter::AwURLRequestContextGetter( | 181 AwURLRequestContextGetter::AwURLRequestContextGetter( |
182 const base::FilePath& cache_path, net::CookieStore* cookie_store, | 182 const base::FilePath& cache_path, net::CookieStore* cookie_store, |
183 scoped_ptr<net::ProxyConfigService> config_service) | 183 scoped_ptr<net::ProxyConfigService> config_service) |
184 : cache_path_(cache_path), | 184 : cache_path_(cache_path), |
| 185 net_log_(new net::NetLog()), |
| 186 proxy_config_service_(config_service.Pass()), |
185 cookie_store_(cookie_store), | 187 cookie_store_(cookie_store), |
186 net_log_(new net::NetLog()) { | 188 http_user_agent_settings_(new AwHttpUserAgentSettings()) { |
187 proxy_config_service_ = config_service.Pass(); | |
188 http_user_agent_settings_.reset( | |
189 new AwHttpUserAgentSettings()); | |
190 // CreateSystemProxyConfigService for Android must be called on main thread. | 189 // CreateSystemProxyConfigService for Android must be called on main thread. |
191 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 190 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
192 } | 191 } |
193 | 192 |
194 AwURLRequestContextGetter::~AwURLRequestContextGetter() { | 193 AwURLRequestContextGetter::~AwURLRequestContextGetter() { |
195 } | 194 } |
196 | 195 |
197 void AwURLRequestContextGetter::InitializeURLRequestContext() { | 196 void AwURLRequestContextGetter::InitializeURLRequestContext() { |
198 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 197 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
199 DCHECK(!url_request_context_); | 198 DCHECK(!url_request_context_); |
(...skipping 23 matching lines...) Expand all Loading... |
223 builder.SetCookieAndChannelIdStores(cookie_store_, NULL); | 222 builder.SetCookieAndChannelIdStores(cookie_store_, NULL); |
224 ApplyCmdlineOverridesToURLRequestContextBuilder(&builder); | 223 ApplyCmdlineOverridesToURLRequestContextBuilder(&builder); |
225 | 224 |
226 url_request_context_ = builder.Build().Pass(); | 225 url_request_context_ = builder.Build().Pass(); |
227 // TODO(mnaganov): Fix URLRequestContextBuilder to use proper threads. | 226 // TODO(mnaganov): Fix URLRequestContextBuilder to use proper threads. |
228 net::HttpNetworkSession::Params network_session_params; | 227 net::HttpNetworkSession::Params network_session_params; |
229 | 228 |
230 PopulateNetworkSessionParams(url_request_context_.get(), | 229 PopulateNetworkSessionParams(url_request_context_.get(), |
231 &network_session_params); | 230 &network_session_params); |
232 | 231 |
233 net::HttpCache* main_cache = new net::HttpCache( | 232 http_network_session_.reset( |
234 network_session_params, | 233 new net::HttpNetworkSession(network_session_params)); |
| 234 main_http_factory_.reset(new net::HttpCache( |
| 235 http_network_session_.get(), |
235 new net::HttpCache::DefaultBackend( | 236 new net::HttpCache::DefaultBackend( |
236 net::DISK_CACHE, | 237 net::DISK_CACHE, |
237 net::CACHE_BACKEND_SIMPLE, | 238 net::CACHE_BACKEND_SIMPLE, |
238 cache_path_, | 239 cache_path_, |
239 20 * 1024 * 1024, // 20M | 240 20 * 1024 * 1024, // 20M |
240 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE))); | 241 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)), |
| 242 true /* set_up_quic_server_info */)); |
241 | 243 |
242 main_http_factory_.reset(main_cache); | 244 url_request_context_->set_http_transaction_factory(main_http_factory_.get()); |
243 url_request_context_->set_http_transaction_factory(main_cache); | |
244 | 245 |
245 job_factory_ = CreateJobFactory(&protocol_handlers_, | 246 job_factory_ = CreateJobFactory(&protocol_handlers_, |
246 request_interceptors_.Pass()); | 247 request_interceptors_.Pass()); |
247 | 248 |
248 job_factory_.reset(new net::URLRequestInterceptingJobFactory( | 249 job_factory_.reset(new net::URLRequestInterceptingJobFactory( |
249 job_factory_.Pass(), | 250 job_factory_.Pass(), |
250 browser_context->GetDataReductionProxyIOData()->CreateInterceptor())); | 251 browser_context->GetDataReductionProxyIOData()->CreateInterceptor())); |
251 url_request_context_->set_job_factory(job_factory_.get()); | 252 url_request_context_->set_job_factory(job_factory_.get()); |
252 url_request_context_->set_http_user_agent_settings( | 253 url_request_context_->set_http_user_agent_settings( |
253 http_user_agent_settings_.get()); | 254 http_user_agent_settings_.get()); |
(...skipping 23 matching lines...) Expand all Loading... |
277 return net_log_.get(); | 278 return net_log_.get(); |
278 } | 279 } |
279 | 280 |
280 void AwURLRequestContextGetter::SetKeyOnIO(const std::string& key) { | 281 void AwURLRequestContextGetter::SetKeyOnIO(const std::string& key) { |
281 DCHECK(AwBrowserContext::GetDefault()->GetDataReductionProxyIOData()); | 282 DCHECK(AwBrowserContext::GetDefault()->GetDataReductionProxyIOData()); |
282 AwBrowserContext::GetDefault()->GetDataReductionProxyIOData()-> | 283 AwBrowserContext::GetDefault()->GetDataReductionProxyIOData()-> |
283 request_options()->SetKeyOnIO(key); | 284 request_options()->SetKeyOnIO(key); |
284 } | 285 } |
285 | 286 |
286 } // namespace android_webview | 287 } // namespace android_webview |
OLD | NEW |