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