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 cookie_store_(cookie_store), | 185 net_log_(new net::NetLog()), |
186 net_log_(new net::NetLog()) { | 186 cookie_store_(cookie_store) { |
pauljensen
2015/09/02 14:32:29
while we're reordering initialization here, can we
mmenke
2015/09/02 16:29:33
Done.
| |
187 proxy_config_service_ = config_service.Pass(); | 187 proxy_config_service_ = config_service.Pass(); |
188 http_user_agent_settings_.reset( | 188 http_user_agent_settings_.reset( |
189 new AwHttpUserAgentSettings()); | 189 new AwHttpUserAgentSettings()); |
pauljensen
2015/09/02 14:32:29
nit: It's odd that some of these fields are initia
mmenke
2015/09/02 16:29:33
Done.
| |
190 // CreateSystemProxyConfigService for Android must be called on main thread. | 190 // CreateSystemProxyConfigService for Android must be called on main thread. |
191 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 191 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
192 } | 192 } |
193 | 193 |
194 AwURLRequestContextGetter::~AwURLRequestContextGetter() { | 194 AwURLRequestContextGetter::~AwURLRequestContextGetter() { |
195 } | 195 } |
196 | 196 |
197 void AwURLRequestContextGetter::InitializeURLRequestContext() { | 197 void AwURLRequestContextGetter::InitializeURLRequestContext() { |
198 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 198 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
199 DCHECK(!url_request_context_); | 199 DCHECK(!url_request_context_); |
(...skipping 24 matching lines...) Expand all Loading... | |
224 builder.SetCookieAndChannelIdStores(cookie_store_, NULL); | 224 builder.SetCookieAndChannelIdStores(cookie_store_, NULL); |
225 ApplyCmdlineOverridesToURLRequestContextBuilder(&builder); | 225 ApplyCmdlineOverridesToURLRequestContextBuilder(&builder); |
226 | 226 |
227 url_request_context_ = builder.Build().Pass(); | 227 url_request_context_ = builder.Build().Pass(); |
228 // TODO(mnaganov): Fix URLRequestContextBuilder to use proper threads. | 228 // TODO(mnaganov): Fix URLRequestContextBuilder to use proper threads. |
229 net::HttpNetworkSession::Params network_session_params; | 229 net::HttpNetworkSession::Params network_session_params; |
230 | 230 |
231 PopulateNetworkSessionParams(url_request_context_.get(), | 231 PopulateNetworkSessionParams(url_request_context_.get(), |
232 &network_session_params); | 232 &network_session_params); |
233 | 233 |
234 net::HttpCache* main_cache = new net::HttpCache( | 234 http_network_session_.reset( |
235 network_session_params, | 235 new net::HttpNetworkSession(network_session_params)); |
236 main_http_factory_.reset(new net::HttpCache( | |
237 http_network_session_.get(), | |
236 new net::HttpCache::DefaultBackend( | 238 new net::HttpCache::DefaultBackend( |
237 net::DISK_CACHE, | 239 net::DISK_CACHE, |
238 net::CACHE_BACKEND_SIMPLE, | 240 net::CACHE_BACKEND_SIMPLE, |
239 cache_path_, | 241 cache_path_, |
240 20 * 1024 * 1024, // 20M | 242 20 * 1024 * 1024, // 20M |
241 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE))); | 243 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)), |
244 true)); | |
pauljensen
2015/09/02 14:32:29
/* set_up_quic_server_info */
mmenke
2015/09/02 16:29:33
Done.
| |
242 | 245 |
243 main_http_factory_.reset(main_cache); | 246 url_request_context_->set_http_transaction_factory(main_http_factory_.get()); |
244 url_request_context_->set_http_transaction_factory(main_cache); | |
245 | 247 |
246 job_factory_ = CreateJobFactory(&protocol_handlers_, | 248 job_factory_ = CreateJobFactory(&protocol_handlers_, |
247 request_interceptors_.Pass()); | 249 request_interceptors_.Pass()); |
248 | 250 |
249 job_factory_.reset(new net::URLRequestInterceptingJobFactory( | 251 job_factory_.reset(new net::URLRequestInterceptingJobFactory( |
250 job_factory_.Pass(), | 252 job_factory_.Pass(), |
251 browser_context->GetDataReductionProxyIOData()->CreateInterceptor())); | 253 browser_context->GetDataReductionProxyIOData()->CreateInterceptor())); |
252 url_request_context_->set_job_factory(job_factory_.get()); | 254 url_request_context_->set_job_factory(job_factory_.get()); |
253 url_request_context_->set_http_user_agent_settings( | 255 url_request_context_->set_http_user_agent_settings( |
254 http_user_agent_settings_.get()); | 256 http_user_agent_settings_.get()); |
pauljensen
2015/09/02 14:32:29
one idea to simplify all this code a lot more woul
mmenke
2015/09/02 16:29:33
I'd really like to just switch to using URLRequest
| |
255 } | 257 } |
256 | 258 |
257 net::URLRequestContext* AwURLRequestContextGetter::GetURLRequestContext() { | 259 net::URLRequestContext* AwURLRequestContextGetter::GetURLRequestContext() { |
258 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 260 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
259 if (!url_request_context_) | 261 if (!url_request_context_) |
260 InitializeURLRequestContext(); | 262 InitializeURLRequestContext(); |
261 | 263 |
262 return url_request_context_.get(); | 264 return url_request_context_.get(); |
263 } | 265 } |
264 | 266 |
(...skipping 13 matching lines...) Expand all Loading... | |
278 return net_log_.get(); | 280 return net_log_.get(); |
279 } | 281 } |
280 | 282 |
281 void AwURLRequestContextGetter::SetKeyOnIO(const std::string& key) { | 283 void AwURLRequestContextGetter::SetKeyOnIO(const std::string& key) { |
282 DCHECK(AwBrowserContext::GetDefault()->GetDataReductionProxyIOData()); | 284 DCHECK(AwBrowserContext::GetDefault()->GetDataReductionProxyIOData()); |
283 AwBrowserContext::GetDefault()->GetDataReductionProxyIOData()-> | 285 AwBrowserContext::GetDefault()->GetDataReductionProxyIOData()-> |
284 request_options()->SetKeyOnIO(key); | 286 request_options()->SetKeyOnIO(key); |
285 } | 287 } |
286 | 288 |
287 } // namespace android_webview | 289 } // namespace android_webview |
OLD | NEW |