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 24 matching lines...) Expand all Loading... |
224 builder.SetCookieAndChannelIdStores(cookie_store_, NULL); | 223 builder.SetCookieAndChannelIdStores(cookie_store_, NULL); |
225 ApplyCmdlineOverridesToURLRequestContextBuilder(&builder); | 224 ApplyCmdlineOverridesToURLRequestContextBuilder(&builder); |
226 | 225 |
227 url_request_context_ = builder.Build().Pass(); | 226 url_request_context_ = builder.Build().Pass(); |
228 // TODO(mnaganov): Fix URLRequestContextBuilder to use proper threads. | 227 // TODO(mnaganov): Fix URLRequestContextBuilder to use proper threads. |
229 net::HttpNetworkSession::Params network_session_params; | 228 net::HttpNetworkSession::Params network_session_params; |
230 | 229 |
231 PopulateNetworkSessionParams(url_request_context_.get(), | 230 PopulateNetworkSessionParams(url_request_context_.get(), |
232 &network_session_params); | 231 &network_session_params); |
233 | 232 |
234 net::HttpCache* main_cache = new net::HttpCache( | 233 http_network_session_.reset( |
235 network_session_params, | 234 new net::HttpNetworkSession(network_session_params)); |
| 235 main_http_factory_.reset(new net::HttpCache( |
| 236 http_network_session_.get(), |
236 new net::HttpCache::DefaultBackend( | 237 new net::HttpCache::DefaultBackend( |
237 net::DISK_CACHE, | 238 net::DISK_CACHE, |
238 net::CACHE_BACKEND_SIMPLE, | 239 net::CACHE_BACKEND_SIMPLE, |
239 cache_path_, | 240 cache_path_, |
240 20 * 1024 * 1024, // 20M | 241 20 * 1024 * 1024, // 20M |
241 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE))); | 242 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)), |
| 243 true /* set_up_quic_server_info */)); |
242 | 244 |
243 main_http_factory_.reset(main_cache); | 245 url_request_context_->set_http_transaction_factory(main_http_factory_.get()); |
244 url_request_context_->set_http_transaction_factory(main_cache); | |
245 | 246 |
246 job_factory_ = CreateJobFactory(&protocol_handlers_, | 247 job_factory_ = CreateJobFactory(&protocol_handlers_, |
247 request_interceptors_.Pass()); | 248 request_interceptors_.Pass()); |
248 | 249 |
249 job_factory_.reset(new net::URLRequestInterceptingJobFactory( | 250 job_factory_.reset(new net::URLRequestInterceptingJobFactory( |
250 job_factory_.Pass(), | 251 job_factory_.Pass(), |
251 browser_context->GetDataReductionProxyIOData()->CreateInterceptor())); | 252 browser_context->GetDataReductionProxyIOData()->CreateInterceptor())); |
252 url_request_context_->set_job_factory(job_factory_.get()); | 253 url_request_context_->set_job_factory(job_factory_.get()); |
253 url_request_context_->set_http_user_agent_settings( | 254 url_request_context_->set_http_user_agent_settings( |
254 http_user_agent_settings_.get()); | 255 http_user_agent_settings_.get()); |
(...skipping 23 matching lines...) Expand all Loading... |
278 return net_log_.get(); | 279 return net_log_.get(); |
279 } | 280 } |
280 | 281 |
281 void AwURLRequestContextGetter::SetKeyOnIO(const std::string& key) { | 282 void AwURLRequestContextGetter::SetKeyOnIO(const std::string& key) { |
282 DCHECK(AwBrowserContext::GetDefault()->GetDataReductionProxyIOData()); | 283 DCHECK(AwBrowserContext::GetDefault()->GetDataReductionProxyIOData()); |
283 AwBrowserContext::GetDefault()->GetDataReductionProxyIOData()-> | 284 AwBrowserContext::GetDefault()->GetDataReductionProxyIOData()-> |
284 request_options()->SetKeyOnIO(key); | 285 request_options()->SetKeyOnIO(key); |
285 } | 286 } |
286 | 287 |
287 } // namespace android_webview | 288 } // namespace android_webview |
OLD | NEW |