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/command_line.h" | 16 #include "base/command_line.h" |
17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
18 #include "base/threading/sequenced_worker_pool.h" | 18 #include "base/threading/sequenced_worker_pool.h" |
19 #include "base/threading/worker_pool.h" | 19 #include "base/threading/worker_pool.h" |
20 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_auth _request_handler.h" | 20 #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_conf ig_service.h" | 21 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf ig_service.h" |
22 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_inte rceptor.h" | 22 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_inte rceptor.h" |
23 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_netw ork_delegate.h" | |
23 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett ings.h" | 24 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett ings.h" |
24 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
25 #include "content/public/browser/content_browser_client.h" | 26 #include "content/public/browser/content_browser_client.h" |
26 #include "content/public/browser/cookie_store_factory.h" | 27 #include "content/public/browser/cookie_store_factory.h" |
27 #include "content/public/common/content_client.h" | 28 #include "content/public/common/content_client.h" |
28 #include "content/public/common/content_switches.h" | 29 #include "content/public/common/content_switches.h" |
29 #include "content/public/common/url_constants.h" | 30 #include "content/public/common/url_constants.h" |
30 #include "net/base/cache_type.h" | 31 #include "net/base/cache_type.h" |
31 #include "net/base/net_log.h" | 32 #include "net/base/net_log.h" |
32 #include "net/cookies/cookie_store.h" | 33 #include "net/cookies/cookie_store.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 | 189 |
189 AwURLRequestContextGetter::~AwURLRequestContextGetter() { | 190 AwURLRequestContextGetter::~AwURLRequestContextGetter() { |
190 } | 191 } |
191 | 192 |
192 void AwURLRequestContextGetter::InitializeURLRequestContext() { | 193 void AwURLRequestContextGetter::InitializeURLRequestContext() { |
193 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 194 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
194 DCHECK(!url_request_context_); | 195 DCHECK(!url_request_context_); |
195 | 196 |
196 net::URLRequestContextBuilder builder; | 197 net::URLRequestContextBuilder builder; |
197 builder.set_user_agent(GetUserAgent()); | 198 builder.set_user_agent(GetUserAgent()); |
198 AwNetworkDelegate* aw_network_delegate = new AwNetworkDelegate(); | 199 scoped_ptr<AwNetworkDelegate> aw_network_delegate(new AwNetworkDelegate()); |
199 builder.set_network_delegate(aw_network_delegate); | 200 |
201 AwBrowserContext* browser_context = AwBrowserContext::GetDefault(); | |
202 DCHECK(browser_context); | |
203 | |
204 // Compression statistics are not gathered for WebView, so | |
205 // DataReductionProxyStatisticsPrefs is not instantiated and passed to the | |
206 // network delegate. | |
207 DataReductionProxySettings* data_reduction_proxy_settings = | |
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_network_delegate->Init( | |
221 NULL, NULL, NULL, | |
bengr
2014/12/02 17:20:00
I don't understand this Init call. If you need to
megjablon
2014/12/02 22:33:21
Moved all to constructor.
| |
222 data_reduction_proxy_settings->params(), NULL, | |
223 data_reduction_proxy_auth_request_handler_.get(), NULL, | |
bengr
2014/12/02 17:20:00
Who needs this besides the data_reduction_proxy_ne
megjablon
2014/12/02 22:33:21
It is used by SetKeyOnIO
| |
224 data_reduction_proxy::DataReductionProxyNetworkDelegate:: | |
225 OnResolveProxyHandler(), | |
226 data_reduction_proxy::DataReductionProxyNetworkDelegate:: | |
227 ProxyConfigGetter()); | |
228 | |
229 builder.set_network_delegate(data_reduction_proxy_network_delegate); | |
200 #if !defined(DISABLE_FTP_SUPPORT) | 230 #if !defined(DISABLE_FTP_SUPPORT) |
201 builder.set_ftp_enabled(false); // Android WebView does not support ftp yet. | 231 builder.set_ftp_enabled(false); // Android WebView does not support ftp yet. |
202 #endif | 232 #endif |
203 DCHECK(data_reduction_proxy_config_service_.get()); | 233 DCHECK(data_reduction_proxy_config_service_.get()); |
204 // Android provides a local HTTP proxy that handles all the proxying. | 234 // Android provides a local HTTP proxy that handles all the proxying. |
205 // Create the proxy without a resolver since we rely on this local HTTP proxy. | 235 // Create the proxy without a resolver since we rely on this local HTTP proxy. |
206 // TODO(sgurun) is this behavior guaranteed through SDK? | 236 // TODO(sgurun) is this behavior guaranteed through SDK? |
207 builder.set_proxy_service( | 237 builder.set_proxy_service( |
208 net::ProxyService::CreateWithoutProxyResolver( | 238 net::ProxyService::CreateWithoutProxyResolver( |
209 data_reduction_proxy_config_service_.release(), | 239 data_reduction_proxy_config_service_.release(), |
(...skipping 13 matching lines...) Expand all Loading... | |
223 | 253 |
224 net::HttpCache* main_cache = new net::HttpCache( | 254 net::HttpCache* main_cache = new net::HttpCache( |
225 network_session_params, | 255 network_session_params, |
226 new net::HttpCache::DefaultBackend( | 256 new net::HttpCache::DefaultBackend( |
227 net::DISK_CACHE, | 257 net::DISK_CACHE, |
228 net::CACHE_BACKEND_SIMPLE, | 258 net::CACHE_BACKEND_SIMPLE, |
229 cache_path_, | 259 cache_path_, |
230 20 * 1024 * 1024, // 20M | 260 20 * 1024 * 1024, // 20M |
231 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE))); | 261 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE))); |
232 | 262 |
233 AwBrowserContext* browser_context = AwBrowserContext::GetDefault(); | |
234 DCHECK(browser_context); | |
235 DataReductionProxySettings* data_reduction_proxy_settings = | |
236 browser_context->GetDataReductionProxySettings(); | |
237 DCHECK(data_reduction_proxy_settings); | |
238 data_reduction_proxy_auth_request_handler_.reset( | |
239 new data_reduction_proxy::DataReductionProxyAuthRequestHandler( | |
240 data_reduction_proxy::Client::WEBVIEW_ANDROID, | |
241 data_reduction_proxy_settings->params(), | |
242 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); | |
243 | |
244 // Compression statistics are not gathered for WebView, so | |
245 // DataReductionProxyStatisticsPrefs is not instantiated and passed to the | |
246 // network delegate. | |
247 aw_network_delegate->set_data_reduction_proxy_params( | |
248 data_reduction_proxy_settings->params()); | |
249 aw_network_delegate->set_data_reduction_proxy_auth_request_handler( | |
250 data_reduction_proxy_auth_request_handler_.get()); | |
251 | |
252 main_http_factory_.reset(main_cache); | 263 main_http_factory_.reset(main_cache); |
253 url_request_context_->set_http_transaction_factory(main_cache); | 264 url_request_context_->set_http_transaction_factory(main_cache); |
254 url_request_context_->set_cookie_store(cookie_store_.get()); | 265 url_request_context_->set_cookie_store(cookie_store_.get()); |
255 | 266 |
256 job_factory_ = CreateJobFactory(&protocol_handlers_, | 267 job_factory_ = CreateJobFactory(&protocol_handlers_, |
257 request_interceptors_.Pass()); | 268 request_interceptors_.Pass()); |
258 | 269 |
259 job_factory_.reset(new net::URLRequestInterceptingJobFactory( | 270 job_factory_.reset(new net::URLRequestInterceptingJobFactory( |
260 job_factory_.Pass(), make_scoped_ptr( | 271 job_factory_.Pass(), make_scoped_ptr( |
261 new data_reduction_proxy::DataReductionProxyInterceptor( | 272 new data_reduction_proxy::DataReductionProxyInterceptor( |
(...skipping 30 matching lines...) Expand all Loading... | |
292 net::NetLog* AwURLRequestContextGetter::GetNetLog() { | 303 net::NetLog* AwURLRequestContextGetter::GetNetLog() { |
293 return net_log_.get(); | 304 return net_log_.get(); |
294 } | 305 } |
295 | 306 |
296 void AwURLRequestContextGetter::SetKeyOnIO(const std::string& key) { | 307 void AwURLRequestContextGetter::SetKeyOnIO(const std::string& key) { |
297 DCHECK(data_reduction_proxy_auth_request_handler_); | 308 DCHECK(data_reduction_proxy_auth_request_handler_); |
298 data_reduction_proxy_auth_request_handler_->InitAuthentication(key); | 309 data_reduction_proxy_auth_request_handler_->InitAuthentication(key); |
299 } | 310 } |
300 | 311 |
301 } // namespace android_webview | 312 } // namespace android_webview |
OLD | NEW |