Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Side by Side Diff: android_webview/browser/net/aw_url_request_context_getter.cc

Issue 734263003: Move data reduction proxy logic out of chrome and android webview network delegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 data_reduction_proxy::DataReductionProxyNetworkDelegate*
201 data_reduction_proxy_network_delegate =
202 new data_reduction_proxy::DataReductionProxyNetworkDelegate(
203 aw_network_delegate.Pass());
204 builder.set_network_delegate(data_reduction_proxy_network_delegate);
200 #if !defined(DISABLE_FTP_SUPPORT) 205 #if !defined(DISABLE_FTP_SUPPORT)
201 builder.set_ftp_enabled(false); // Android WebView does not support ftp yet. 206 builder.set_ftp_enabled(false); // Android WebView does not support ftp yet.
202 #endif 207 #endif
203 if (data_reduction_proxy_config_service_.get()) { 208 if (data_reduction_proxy_config_service_.get()) {
204 builder.set_proxy_config_service( 209 builder.set_proxy_config_service(
205 data_reduction_proxy_config_service_.release()); 210 data_reduction_proxy_config_service_.release());
206 } else { 211 } else {
207 builder.set_proxy_config_service( 212 builder.set_proxy_config_service(
208 net::ProxyService::CreateSystemProxyConfigService( 213 net::ProxyService::CreateSystemProxyConfigService(
209 GetNetworkTaskRunner(), NULL /* Ignored on Android */ )); 214 GetNetworkTaskRunner(), NULL /* Ignored on Android */ ));
(...skipping 18 matching lines...) Expand all
228 net::CACHE_BACKEND_SIMPLE, 233 net::CACHE_BACKEND_SIMPLE,
229 partition_path_.Append(FILE_PATH_LITERAL("Cache")), 234 partition_path_.Append(FILE_PATH_LITERAL("Cache")),
230 20 * 1024 * 1024, // 20M 235 20 * 1024 * 1024, // 20M
231 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE))); 236 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)));
232 237
233 AwBrowserContext* browser_context = AwBrowserContext::GetDefault(); 238 AwBrowserContext* browser_context = AwBrowserContext::GetDefault();
234 DCHECK(browser_context); 239 DCHECK(browser_context);
235 DataReductionProxySettings* data_reduction_proxy_settings = 240 DataReductionProxySettings* data_reduction_proxy_settings =
236 browser_context->GetDataReductionProxySettings(); 241 browser_context->GetDataReductionProxySettings();
237 DCHECK(data_reduction_proxy_settings); 242 DCHECK(data_reduction_proxy_settings);
238 data_reduction_proxy_auth_request_handler_.reset( 243 data_reduction_proxy_auth_request_handler_.reset(
bengr 2014/11/18 19:30:55 Can this be moved above the delegate construction
megjablon 2014/11/19 19:23:40 Done.
239 new data_reduction_proxy::DataReductionProxyAuthRequestHandler( 244 new data_reduction_proxy::DataReductionProxyAuthRequestHandler(
240 data_reduction_proxy::Client::WEBVIEW_ANDROID, 245 data_reduction_proxy::Client::WEBVIEW_ANDROID,
241 data_reduction_proxy_settings->params(), 246 data_reduction_proxy_settings->params(),
242 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); 247 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)));
243 248
244 // Compression statistics are not gathered for WebView, so 249 // Compression statistics are not gathered for WebView, so
245 // DataReductionProxyStatisticsPrefs is not instantiated and passed to the 250 // DataReductionProxyStatisticsPrefs is not instantiated and passed to the
246 // network delegate. 251 // network delegate.
247 aw_network_delegate->set_data_reduction_proxy_params( 252 data_reduction_proxy_network_delegate->set_data_reduction_proxy_params(
248 data_reduction_proxy_settings->params()); 253 data_reduction_proxy_settings->params());
bengr 2014/11/18 19:30:55 Make this part of the DRPNetworkDelegate construc
megjablon 2014/11/19 19:23:40 Done.
249 aw_network_delegate->set_data_reduction_proxy_auth_request_handler( 254 data_reduction_proxy_network_delegate->
250 data_reduction_proxy_auth_request_handler_.get()); 255 set_data_reduction_proxy_auth_request_handler(
256 data_reduction_proxy_auth_request_handler_.get());
251 257
252 main_http_factory_.reset(main_cache); 258 main_http_factory_.reset(main_cache);
253 url_request_context_->set_http_transaction_factory(main_cache); 259 url_request_context_->set_http_transaction_factory(main_cache);
254 url_request_context_->set_cookie_store(cookie_store_.get()); 260 url_request_context_->set_cookie_store(cookie_store_.get());
255 261
256 job_factory_ = CreateJobFactory(&protocol_handlers_, 262 job_factory_ = CreateJobFactory(&protocol_handlers_,
257 request_interceptors_.Pass()); 263 request_interceptors_.Pass());
258 264
259 job_factory_.reset(new net::URLRequestInterceptingJobFactory( 265 job_factory_.reset(new net::URLRequestInterceptingJobFactory(
260 job_factory_.Pass(), make_scoped_ptr( 266 job_factory_.Pass(), make_scoped_ptr(
(...skipping 30 matching lines...) Expand all
291 net::NetLog* AwURLRequestContextGetter::GetNetLog() { 297 net::NetLog* AwURLRequestContextGetter::GetNetLog() {
292 return net_log_.get(); 298 return net_log_.get();
293 } 299 }
294 300
295 void AwURLRequestContextGetter::SetKeyOnIO(const std::string& key) { 301 void AwURLRequestContextGetter::SetKeyOnIO(const std::string& key) {
296 DCHECK(data_reduction_proxy_auth_request_handler_); 302 DCHECK(data_reduction_proxy_auth_request_handler_);
297 data_reduction_proxy_auth_request_handler_->InitAuthentication(key); 303 data_reduction_proxy_auth_request_handler_->InitAuthentication(key);
298 } 304 }
299 305
300 } // namespace android_webview 306 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698