| 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" |
| 11 #include "android_webview/browser/aw_request_interceptor.h" | 11 #include "android_webview/browser/aw_request_interceptor.h" |
| 12 #include "android_webview/browser/net/aw_network_delegate.h" | 12 #include "android_webview/browser/net/aw_network_delegate.h" |
| 13 #include "android_webview/browser/net/aw_url_request_job_factory.h" | 13 #include "android_webview/browser/net/aw_url_request_job_factory.h" |
| 14 #include "android_webview/browser/net/init_native_callback.h" | 14 #include "android_webview/browser/net/init_native_callback.h" |
| 15 #include "android_webview/common/aw_content_client.h" | 15 #include "android_webview/common/aw_content_client.h" |
| 16 #include "base/bind.h" | 16 #include "base/bind.h" |
| 17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/threading/sequenced_worker_pool.h" | 19 #include "base/threading/sequenced_worker_pool.h" |
| 20 #include "base/threading/worker_pool.h" | 20 #include "base/threading/worker_pool.h" |
| 21 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_auth
_request_handler.h" | 21 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_auth
_request_handler.h" |
| 22 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
igurator.h" | 22 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
igurator.h" |
| 23 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_inte
rceptor.h" | 23 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_inte
rceptor.h" |
| 24 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d
ata.h" |
| 24 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_netw
ork_delegate.h" | 25 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_netw
ork_delegate.h" |
| 25 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" | 26 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" |
| 26 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| 27 #include "content/public/browser/content_browser_client.h" | 28 #include "content/public/browser/content_browser_client.h" |
| 28 #include "content/public/browser/cookie_store_factory.h" | 29 #include "content/public/browser/cookie_store_factory.h" |
| 29 #include "content/public/common/content_client.h" | 30 #include "content/public/common/content_client.h" |
| 30 #include "content/public/common/content_switches.h" | 31 #include "content/public/common/content_switches.h" |
| 31 #include "content/public/common/url_constants.h" | 32 #include "content/public/common/url_constants.h" |
| 32 #include "net/base/cache_type.h" | 33 #include "net/base/cache_type.h" |
| 33 #include "net/base/net_log.h" | 34 #include "net/base/net_log.h" |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 195 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 195 DCHECK(!url_request_context_); | 196 DCHECK(!url_request_context_); |
| 196 | 197 |
| 197 net::URLRequestContextBuilder builder; | 198 net::URLRequestContextBuilder builder; |
| 198 builder.set_user_agent(GetUserAgent()); | 199 builder.set_user_agent(GetUserAgent()); |
| 199 scoped_ptr<AwNetworkDelegate> aw_network_delegate(new AwNetworkDelegate()); | 200 scoped_ptr<AwNetworkDelegate> aw_network_delegate(new AwNetworkDelegate()); |
| 200 | 201 |
| 201 AwBrowserContext* browser_context = AwBrowserContext::GetDefault(); | 202 AwBrowserContext* browser_context = AwBrowserContext::GetDefault(); |
| 202 DCHECK(browser_context); | 203 DCHECK(browser_context); |
| 203 | 204 |
| 204 // Compression statistics are not gathered for WebView, so | 205 builder.set_network_delegate( |
| 205 // DataReductionProxyStatisticsPrefs is not instantiated and passed to the | 206 browser_context->GetDataReductionProxyIOData()->CreateNetworkDelegate( |
| 206 // network delegate. | 207 aw_network_delegate.Pass(), |
| 207 DataReductionProxySettings* data_reduction_proxy_settings = | 208 false /* No UMA is produced to track bypasses. */ ).release()); |
| 208 browser_context->GetDataReductionProxySettings(); | |
| 209 DCHECK(data_reduction_proxy_settings); | |
| 210 data_reduction_proxy_auth_request_handler_.reset( | |
| 211 new data_reduction_proxy::DataReductionProxyAuthRequestHandler( | |
| 212 data_reduction_proxy::Client::WEBVIEW_ANDROID, | |
| 213 data_reduction_proxy_settings->params(), | |
| 214 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); | |
| 215 | |
| 216 data_reduction_proxy::DataReductionProxyNetworkDelegate* | |
| 217 data_reduction_proxy_network_delegate = | |
| 218 new data_reduction_proxy::DataReductionProxyNetworkDelegate( | |
| 219 aw_network_delegate.Pass(), | |
| 220 data_reduction_proxy_settings->params(), | |
| 221 data_reduction_proxy_auth_request_handler_.get(), | |
| 222 base::Bind( | |
| 223 &data_reduction_proxy::DataReductionProxyConfigurator:: | |
| 224 GetProxyConfigOnIOThread, | |
| 225 base::Unretained( | |
| 226 browser_context->GetDataReductionProxyConfigurator()))); | |
| 227 data_reduction_proxy_network_delegate->InitProxyConfigOverrider( | |
| 228 base::Bind(data_reduction_proxy::OnResolveProxyHandler)); | |
| 229 | |
| 230 builder.set_network_delegate(data_reduction_proxy_network_delegate); | |
| 231 #if !defined(DISABLE_FTP_SUPPORT) | 209 #if !defined(DISABLE_FTP_SUPPORT) |
| 232 builder.set_ftp_enabled(false); // Android WebView does not support ftp yet. | 210 builder.set_ftp_enabled(false); // Android WebView does not support ftp yet. |
| 233 #endif | 211 #endif |
| 234 DCHECK(proxy_config_service_.get()); | 212 DCHECK(proxy_config_service_.get()); |
| 235 // Android provides a local HTTP proxy that handles all the proxying. | 213 // Android provides a local HTTP proxy that handles all the proxying. |
| 236 // Create the proxy without a resolver since we rely on this local HTTP proxy. | 214 // Create the proxy without a resolver since we rely on this local HTTP proxy. |
| 237 // TODO(sgurun) is this behavior guaranteed through SDK? | 215 // TODO(sgurun) is this behavior guaranteed through SDK? |
| 238 builder.set_proxy_service( | 216 builder.set_proxy_service( |
| 239 net::ProxyService::CreateWithoutProxyResolver( | 217 net::ProxyService::CreateWithoutProxyResolver( |
| 240 proxy_config_service_.release(), | 218 proxy_config_service_.release(), |
| (...skipping 20 matching lines...) Expand all Loading... |
| 261 20 * 1024 * 1024, // 20M | 239 20 * 1024 * 1024, // 20M |
| 262 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE))); | 240 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE))); |
| 263 | 241 |
| 264 main_http_factory_.reset(main_cache); | 242 main_http_factory_.reset(main_cache); |
| 265 url_request_context_->set_http_transaction_factory(main_cache); | 243 url_request_context_->set_http_transaction_factory(main_cache); |
| 266 | 244 |
| 267 job_factory_ = CreateJobFactory(&protocol_handlers_, | 245 job_factory_ = CreateJobFactory(&protocol_handlers_, |
| 268 request_interceptors_.Pass()); | 246 request_interceptors_.Pass()); |
| 269 | 247 |
| 270 job_factory_.reset(new net::URLRequestInterceptingJobFactory( | 248 job_factory_.reset(new net::URLRequestInterceptingJobFactory( |
| 271 job_factory_.Pass(), make_scoped_ptr( | 249 job_factory_.Pass(), |
| 272 new data_reduction_proxy::DataReductionProxyInterceptor( | 250 browser_context->GetDataReductionProxyIOData()->CreateInterceptor())); |
| 273 data_reduction_proxy_settings->params(), NULL, | |
| 274 browser_context->GetDataReductionProxyEventStore())))); | |
| 275 url_request_context_->set_job_factory(job_factory_.get()); | 251 url_request_context_->set_job_factory(job_factory_.get()); |
| 276 } | 252 } |
| 277 | 253 |
| 278 net::URLRequestContext* AwURLRequestContextGetter::GetURLRequestContext() { | 254 net::URLRequestContext* AwURLRequestContextGetter::GetURLRequestContext() { |
| 279 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 255 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 280 if (!url_request_context_) | 256 if (!url_request_context_) |
| 281 InitializeURLRequestContext(); | 257 InitializeURLRequestContext(); |
| 282 | 258 |
| 283 return url_request_context_.get(); | 259 return url_request_context_.get(); |
| 284 } | 260 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 303 net::NetLog* AwURLRequestContextGetter::GetNetLog() { | 279 net::NetLog* AwURLRequestContextGetter::GetNetLog() { |
| 304 return net_log_.get(); | 280 return net_log_.get(); |
| 305 } | 281 } |
| 306 | 282 |
| 307 void AwURLRequestContextGetter::SetKeyOnIO(const std::string& key) { | 283 void AwURLRequestContextGetter::SetKeyOnIO(const std::string& key) { |
| 308 DCHECK(data_reduction_proxy_auth_request_handler_); | 284 DCHECK(data_reduction_proxy_auth_request_handler_); |
| 309 data_reduction_proxy_auth_request_handler_->InitAuthentication(key); | 285 data_reduction_proxy_auth_request_handler_->InitAuthentication(key); |
| 310 } | 286 } |
| 311 | 287 |
| 312 } // namespace android_webview | 288 } // namespace android_webview |
| OLD | NEW |