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

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

Issue 792803007: Make Data Reduction Proxy a best effort proxy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated tests Created 5 years, 11 months 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/bind.h"
16 #include "base/command_line.h" 17 #include "base/command_line.h"
17 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
18 #include "base/threading/sequenced_worker_pool.h" 19 #include "base/threading/sequenced_worker_pool.h"
19 #include "base/threading/worker_pool.h" 20 #include "base/threading/worker_pool.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_auth _request_handler.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_conf igurator.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_inte rceptor.h"
23 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_netw ork_delegate.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_prot ocol.h"
24 #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"
25 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
26 #include "content/public/browser/content_browser_client.h" 28 #include "content/public/browser/content_browser_client.h"
27 #include "content/public/browser/cookie_store_factory.h" 29 #include "content/public/browser/cookie_store_factory.h"
28 #include "content/public/common/content_client.h" 30 #include "content/public/common/content_client.h"
29 #include "content/public/common/content_switches.h" 31 #include "content/public/common/content_switches.h"
30 #include "content/public/common/url_constants.h" 32 #include "content/public/common/url_constants.h"
31 #include "net/base/cache_type.h" 33 #include "net/base/cache_type.h"
32 #include "net/base/net_log.h" 34 #include "net/base/net_log.h"
33 #include "net/cookies/cookie_store.h" 35 #include "net/cookies/cookie_store.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 } 172 }
171 request_interceptors.weak_clear(); 173 request_interceptors.weak_clear();
172 174
173 return job_factory.Pass(); 175 return job_factory.Pass();
174 } 176 }
175 177
176 } // namespace 178 } // namespace
177 179
178 AwURLRequestContextGetter::AwURLRequestContextGetter( 180 AwURLRequestContextGetter::AwURLRequestContextGetter(
179 const base::FilePath& cache_path, net::CookieStore* cookie_store, 181 const base::FilePath& cache_path, net::CookieStore* cookie_store,
180 scoped_ptr<data_reduction_proxy::DataReductionProxyConfigService> 182 scoped_ptr<net::ProxyConfigService> config_service)
181 config_service)
182 : cache_path_(cache_path), 183 : cache_path_(cache_path),
183 cookie_store_(cookie_store), 184 cookie_store_(cookie_store),
184 net_log_(new net::NetLog()) { 185 net_log_(new net::NetLog()) {
185 data_reduction_proxy_config_service_ = config_service.Pass(); 186 proxy_config_service_ = config_service.Pass();
186 // CreateSystemProxyConfigService for Android must be called on main thread. 187 // CreateSystemProxyConfigService for Android must be called on main thread.
187 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 188 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
188 } 189 }
189 190
190 AwURLRequestContextGetter::~AwURLRequestContextGetter() { 191 AwURLRequestContextGetter::~AwURLRequestContextGetter() {
191 } 192 }
192 193
193 void AwURLRequestContextGetter::InitializeURLRequestContext() { 194 void AwURLRequestContextGetter::InitializeURLRequestContext() {
194 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 195 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
195 DCHECK(!url_request_context_); 196 DCHECK(!url_request_context_);
(...skipping 16 matching lines...) Expand all
212 data_reduction_proxy::Client::WEBVIEW_ANDROID, 213 data_reduction_proxy::Client::WEBVIEW_ANDROID,
213 data_reduction_proxy_settings->params(), 214 data_reduction_proxy_settings->params(),
214 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); 215 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)));
215 216
216 data_reduction_proxy::DataReductionProxyNetworkDelegate* 217 data_reduction_proxy::DataReductionProxyNetworkDelegate*
217 data_reduction_proxy_network_delegate = 218 data_reduction_proxy_network_delegate =
218 new data_reduction_proxy::DataReductionProxyNetworkDelegate( 219 new data_reduction_proxy::DataReductionProxyNetworkDelegate(
219 aw_network_delegate.Pass(), 220 aw_network_delegate.Pass(),
220 data_reduction_proxy_settings->params(), 221 data_reduction_proxy_settings->params(),
221 data_reduction_proxy_auth_request_handler_.get(), 222 data_reduction_proxy_auth_request_handler_.get(),
222 data_reduction_proxy::DataReductionProxyNetworkDelegate:: 223 base::Bind(
223 ProxyConfigGetter()); 224 &data_reduction_proxy::DataReductionProxyConfigurator::
225 GetProxyConfigOnIOThread,
226 base::Unretained(
227 browser_context->GetDataReductionProxyConfigurator())));
228 data_reduction_proxy_network_delegate->InitProxyConfigOverrider(
229 base::Bind(data_reduction_proxy::OnResolveProxyHandler));
224 230
225 builder.set_network_delegate(data_reduction_proxy_network_delegate); 231 builder.set_network_delegate(data_reduction_proxy_network_delegate);
226 #if !defined(DISABLE_FTP_SUPPORT) 232 #if !defined(DISABLE_FTP_SUPPORT)
227 builder.set_ftp_enabled(false); // Android WebView does not support ftp yet. 233 builder.set_ftp_enabled(false); // Android WebView does not support ftp yet.
228 #endif 234 #endif
229 DCHECK(data_reduction_proxy_config_service_.get()); 235 DCHECK(proxy_config_service_.get());
230 // Android provides a local HTTP proxy that handles all the proxying. 236 // Android provides a local HTTP proxy that handles all the proxying.
231 // Create the proxy without a resolver since we rely on this local HTTP proxy. 237 // Create the proxy without a resolver since we rely on this local HTTP proxy.
232 // TODO(sgurun) is this behavior guaranteed through SDK? 238 // TODO(sgurun) is this behavior guaranteed through SDK?
233 builder.set_proxy_service( 239 builder.set_proxy_service(
234 net::ProxyService::CreateWithoutProxyResolver( 240 net::ProxyService::CreateWithoutProxyResolver(
235 data_reduction_proxy_config_service_.release(), 241 proxy_config_service_.release(),
236 net_log_.get())); 242 net_log_.get()));
237 builder.set_accept_language(net::HttpUtil::GenerateAcceptLanguageHeader( 243 builder.set_accept_language(net::HttpUtil::GenerateAcceptLanguageHeader(
238 AwContentBrowserClient::GetAcceptLangsImpl())); 244 AwContentBrowserClient::GetAcceptLangsImpl()));
239 builder.set_net_log(net_log_.get()); 245 builder.set_net_log(net_log_.get());
240 builder.set_channel_id_enabled(false); 246 builder.set_channel_id_enabled(false);
241 ApplyCmdlineOverridesToURLRequestContextBuilder(&builder); 247 ApplyCmdlineOverridesToURLRequestContextBuilder(&builder);
242 248
243 url_request_context_.reset(builder.Build()); 249 url_request_context_.reset(builder.Build());
244 // TODO(mnaganov): Fix URLRequestContextBuilder to use proper threads. 250 // TODO(mnaganov): Fix URLRequestContextBuilder to use proper threads.
245 net::HttpNetworkSession::Params network_session_params; 251 net::HttpNetworkSession::Params network_session_params;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 net::NetLog* AwURLRequestContextGetter::GetNetLog() { 305 net::NetLog* AwURLRequestContextGetter::GetNetLog() {
300 return net_log_.get(); 306 return net_log_.get();
301 } 307 }
302 308
303 void AwURLRequestContextGetter::SetKeyOnIO(const std::string& key) { 309 void AwURLRequestContextGetter::SetKeyOnIO(const std::string& key) {
304 DCHECK(data_reduction_proxy_auth_request_handler_); 310 DCHECK(data_reduction_proxy_auth_request_handler_);
305 data_reduction_proxy_auth_request_handler_->InitAuthentication(key); 311 data_reduction_proxy_auth_request_handler_->InitAuthentication(key);
306 } 312 }
307 313
308 } // namespace android_webview 314 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698