| 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 } // namespace | 174 } // namespace |
| 175 | 175 |
| 176 AwURLRequestContextGetter::AwURLRequestContextGetter( | 176 AwURLRequestContextGetter::AwURLRequestContextGetter( |
| 177 const base::FilePath& cache_path, net::CookieStore* cookie_store, | 177 const base::FilePath& cache_path, net::CookieStore* cookie_store, |
| 178 scoped_ptr<net::ProxyConfigService> config_service) | 178 scoped_ptr<net::ProxyConfigService> config_service) |
| 179 : cache_path_(cache_path), | 179 : cache_path_(cache_path), |
| 180 cookie_store_(cookie_store), | 180 cookie_store_(cookie_store), |
| 181 net_log_(new net::NetLog()) { | 181 net_log_(new net::NetLog()) { |
| 182 proxy_config_service_ = config_service.Pass(); | 182 proxy_config_service_ = config_service.Pass(); |
| 183 // CreateSystemProxyConfigService for Android must be called on main thread. | 183 // CreateSystemProxyConfigService for Android must be called on main thread. |
| 184 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 184 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 185 } | 185 } |
| 186 | 186 |
| 187 AwURLRequestContextGetter::~AwURLRequestContextGetter() { | 187 AwURLRequestContextGetter::~AwURLRequestContextGetter() { |
| 188 } | 188 } |
| 189 | 189 |
| 190 void AwURLRequestContextGetter::InitializeURLRequestContext() { | 190 void AwURLRequestContextGetter::InitializeURLRequestContext() { |
| 191 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 191 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 192 DCHECK(!url_request_context_); | 192 DCHECK(!url_request_context_); |
| 193 | 193 |
| 194 net::URLRequestContextBuilder builder; | 194 net::URLRequestContextBuilder builder; |
| 195 builder.set_user_agent(GetUserAgent()); | 195 builder.set_user_agent(GetUserAgent()); |
| 196 scoped_ptr<AwNetworkDelegate> aw_network_delegate(new AwNetworkDelegate()); | 196 scoped_ptr<AwNetworkDelegate> aw_network_delegate(new AwNetworkDelegate()); |
| 197 | 197 |
| 198 AwBrowserContext* browser_context = AwBrowserContext::GetDefault(); | 198 AwBrowserContext* browser_context = AwBrowserContext::GetDefault(); |
| 199 DCHECK(browser_context); | 199 DCHECK(browser_context); |
| 200 | 200 |
| 201 builder.set_network_delegate( | 201 builder.set_network_delegate( |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 job_factory_ = CreateJobFactory(&protocol_handlers_, | 241 job_factory_ = CreateJobFactory(&protocol_handlers_, |
| 242 request_interceptors_.Pass()); | 242 request_interceptors_.Pass()); |
| 243 | 243 |
| 244 job_factory_.reset(new net::URLRequestInterceptingJobFactory( | 244 job_factory_.reset(new net::URLRequestInterceptingJobFactory( |
| 245 job_factory_.Pass(), | 245 job_factory_.Pass(), |
| 246 browser_context->GetDataReductionProxyIOData()->CreateInterceptor())); | 246 browser_context->GetDataReductionProxyIOData()->CreateInterceptor())); |
| 247 url_request_context_->set_job_factory(job_factory_.get()); | 247 url_request_context_->set_job_factory(job_factory_.get()); |
| 248 } | 248 } |
| 249 | 249 |
| 250 net::URLRequestContext* AwURLRequestContextGetter::GetURLRequestContext() { | 250 net::URLRequestContext* AwURLRequestContextGetter::GetURLRequestContext() { |
| 251 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 251 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 252 if (!url_request_context_) | 252 if (!url_request_context_) |
| 253 InitializeURLRequestContext(); | 253 InitializeURLRequestContext(); |
| 254 | 254 |
| 255 return url_request_context_.get(); | 255 return url_request_context_.get(); |
| 256 } | 256 } |
| 257 | 257 |
| 258 scoped_refptr<base::SingleThreadTaskRunner> | 258 scoped_refptr<base::SingleThreadTaskRunner> |
| 259 AwURLRequestContextGetter::GetNetworkTaskRunner() const { | 259 AwURLRequestContextGetter::GetNetworkTaskRunner() const { |
| 260 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 260 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
| 261 } | 261 } |
| 262 | 262 |
| 263 void AwURLRequestContextGetter::SetHandlersAndInterceptors( | 263 void AwURLRequestContextGetter::SetHandlersAndInterceptors( |
| 264 content::ProtocolHandlerMap* protocol_handlers, | 264 content::ProtocolHandlerMap* protocol_handlers, |
| 265 content::URLRequestInterceptorScopedVector request_interceptors) { | 265 content::URLRequestInterceptorScopedVector request_interceptors) { |
| 266 std::swap(protocol_handlers_, *protocol_handlers); | 266 std::swap(protocol_handlers_, *protocol_handlers); |
| 267 request_interceptors_.swap(request_interceptors); | 267 request_interceptors_.swap(request_interceptors); |
| 268 } | 268 } |
| 269 | 269 |
| 270 net::NetLog* AwURLRequestContextGetter::GetNetLog() { | 270 net::NetLog* AwURLRequestContextGetter::GetNetLog() { |
| 271 return net_log_.get(); | 271 return net_log_.get(); |
| 272 } | 272 } |
| 273 | 273 |
| 274 void AwURLRequestContextGetter::SetKeyOnIO(const std::string& key) { | 274 void AwURLRequestContextGetter::SetKeyOnIO(const std::string& key) { |
| 275 DCHECK(AwBrowserContext::GetDefault()->GetDataReductionProxyIOData()); | 275 DCHECK(AwBrowserContext::GetDefault()->GetDataReductionProxyIOData()); |
| 276 AwBrowserContext::GetDefault()->GetDataReductionProxyIOData()-> | 276 AwBrowserContext::GetDefault()->GetDataReductionProxyIOData()-> |
| 277 request_options()->SetKeyOnIO(key); | 277 request_options()->SetKeyOnIO(key); |
| 278 } | 278 } |
| 279 | 279 |
| 280 } // namespace android_webview | 280 } // namespace android_webview |
| OLD | NEW |