summaryrefslogtreecommitdiffstats
path: root/android_webview
diff options
context:
space:
mode:
authorbengr <bengr@chromium.org>2015-01-06 16:20:52 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-07 00:22:29 +0000
commit70101ea5186d12e67ed99e67fdafd33813f8da67 (patch)
treea5da53a8a109b083d21874418b0a4610e4bfd39d /android_webview
parentdf648d28c1db235526abaeda0ee649fce7fdbae0 (diff)
downloadchromium_src-70101ea5186d12e67ed99e67fdafd33813f8da67.zip
chromium_src-70101ea5186d12e67ed99e67fdafd33813f8da67.tar.gz
chromium_src-70101ea5186d12e67ed99e67fdafd33813f8da67.tar.bz2
Make Data Reduction Proxy a best effort proxy
The data reduction proxy is used only if the effective proxy configuration resolves to DIRECT for the requested URL. This works by allowing the ProxyService to choose an effective proxy configuration and to decide on the prioritized list of proxies to use for a URL given that configuration. Just before the list is used, the DataReductionProxyNetworkDelegate's OnResolveProxy() method provides an opportunity to change that list, which it does, only if that list begins with DIRECT. BUG=429826,444169 Review URL: https://codereview.chromium.org/792803007 Cr-Commit-Position: refs/heads/master@{#310182}
Diffstat (limited to 'android_webview')
-rw-r--r--android_webview/browser/aw_browser_context.cc53
-rw-r--r--android_webview/browser/aw_browser_context.h3
-rw-r--r--android_webview/browser/net/aw_url_request_context_getter.cc22
-rw-r--r--android_webview/browser/net/aw_url_request_context_getter.h7
4 files changed, 44 insertions, 41 deletions
diff --git a/android_webview/browser/aw_browser_context.cc b/android_webview/browser/aw_browser_context.cc
index 016f35e..1fea722 100644
--- a/android_webview/browser/aw_browser_context.cc
+++ b/android_webview/browser/aw_browser_context.cc
@@ -18,7 +18,7 @@
#include "base/prefs/pref_service.h"
#include "base/prefs/pref_service_factory.h"
#include "components/autofill/core/common/autofill_pref_names.h"
-#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service.h"
+#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_configurator.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_prefs.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h"
@@ -36,7 +36,7 @@
using base::FilePath;
using content::BrowserThread;
-using data_reduction_proxy::DataReductionProxyConfigService;
+using data_reduction_proxy::DataReductionProxyConfigurator;
using data_reduction_proxy::DataReductionProxyEventStore;
using data_reduction_proxy::DataReductionProxySettings;
@@ -135,29 +135,6 @@ void AwBrowserContext::SetLegacyCacheRemovalDelayForTest(int delay_ms) {
void AwBrowserContext::PreMainMessageLoopRun() {
cookie_store_ = CreateCookieStore(this);
- data_reduction_proxy_settings_.reset(
- new DataReductionProxySettings(
- new data_reduction_proxy::DataReductionProxyParams(
- data_reduction_proxy::DataReductionProxyParams::kAllowed)));
- data_reduction_proxy_event_store_.reset(
- new DataReductionProxyEventStore(
- BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)));
- scoped_ptr<DataReductionProxyConfigService>
- data_reduction_proxy_config_service(
- new DataReductionProxyConfigService(
- scoped_ptr<net::ProxyConfigService>(
- CreateProxyConfigService()).Pass()));
- if (data_reduction_proxy_settings_.get()) {
- data_reduction_proxy_configurator_.reset(
- new data_reduction_proxy::DataReductionProxyConfigTracker(
- base::Bind(&DataReductionProxyConfigService::UpdateProxyConfig,
- base::Unretained(
- data_reduction_proxy_config_service.get())),
- BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)));
- data_reduction_proxy_settings_->SetProxyConfigurator(
- data_reduction_proxy_configurator_.get());
- }
-
FilePath cache_path;
const FilePath fallback_cache_dir =
GetPath().Append(FILE_PATH_LITERAL("Cache"));
@@ -175,9 +152,24 @@ void AwBrowserContext::PreMainMessageLoopRun() {
<< "Using app data directory as a fallback.";
}
url_request_context_getter_ =
- new AwURLRequestContextGetter(cache_path,
- cookie_store_.get(),
- data_reduction_proxy_config_service.Pass());
+ new AwURLRequestContextGetter(
+ cache_path, cookie_store_.get(),
+ make_scoped_ptr(CreateProxyConfigService()).Pass());
+
+ data_reduction_proxy_settings_.reset(
+ new DataReductionProxySettings(
+ new data_reduction_proxy::DataReductionProxyParams(
+ data_reduction_proxy::DataReductionProxyParams::kAllowed)));
+ data_reduction_proxy_event_store_.reset(
+ new DataReductionProxyEventStore(
+ BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)));
+ data_reduction_proxy_configurator_.reset(
+ new data_reduction_proxy::DataReductionProxyConfigurator(
+ BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
+ url_request_context_getter_->GetNetLog(),
+ data_reduction_proxy_event_store_.get()));
+ data_reduction_proxy_settings_->SetProxyConfigurator(
+ data_reduction_proxy_configurator_.get());
visitedlink_master_.reset(
new visitedlink::VisitedLinkMaster(this, this, false));
@@ -236,6 +228,11 @@ DataReductionProxyEventStore*
return data_reduction_proxy_event_store_.get();
}
+data_reduction_proxy::DataReductionProxyConfigurator*
+AwBrowserContext::GetDataReductionProxyConfigurator() {
+ return data_reduction_proxy_configurator_.get();
+}
+
AwURLRequestContextGetter* AwBrowserContext::GetAwURLRequestContext() {
return url_request_context_getter_.get();
}
diff --git a/android_webview/browser/aw_browser_context.h b/android_webview/browser/aw_browser_context.h
index bc2b11c..a821acf 100644
--- a/android_webview/browser/aw_browser_context.h
+++ b/android_webview/browser/aw_browser_context.h
@@ -94,6 +94,9 @@ class AwBrowserContext : public content::BrowserContext,
data_reduction_proxy::DataReductionProxyEventStore*
GetDataReductionProxyEventStore();
+ data_reduction_proxy::DataReductionProxyConfigurator*
+ GetDataReductionProxyConfigurator();
+
AwURLRequestContextGetter* GetAwURLRequestContext();
void CreateUserPrefServiceIfNecessary();
diff --git a/android_webview/browser/net/aw_url_request_context_getter.cc b/android_webview/browser/net/aw_url_request_context_getter.cc
index f00ef59..0bef536 100644
--- a/android_webview/browser/net/aw_url_request_context_getter.cc
+++ b/android_webview/browser/net/aw_url_request_context_getter.cc
@@ -13,14 +13,16 @@
#include "android_webview/browser/net/aw_url_request_job_factory.h"
#include "android_webview/browser/net/init_native_callback.h"
#include "android_webview/common/aw_content_client.h"
+#include "base/bind.h"
#include "base/command_line.h"
#include "base/strings/string_number_conversions.h"
#include "base/threading/sequenced_worker_pool.h"
#include "base/threading/worker_pool.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_auth_request_handler.h"
-#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service.h"
+#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_configurator.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_interceptor.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.h"
+#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_protocol.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
@@ -177,12 +179,11 @@ scoped_ptr<net::URLRequestJobFactory> CreateJobFactory(
AwURLRequestContextGetter::AwURLRequestContextGetter(
const base::FilePath& cache_path, net::CookieStore* cookie_store,
- scoped_ptr<data_reduction_proxy::DataReductionProxyConfigService>
- config_service)
+ scoped_ptr<net::ProxyConfigService> config_service)
: cache_path_(cache_path),
cookie_store_(cookie_store),
net_log_(new net::NetLog()) {
- data_reduction_proxy_config_service_ = config_service.Pass();
+ proxy_config_service_ = config_service.Pass();
// CreateSystemProxyConfigService for Android must be called on main thread.
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
}
@@ -219,20 +220,25 @@ void AwURLRequestContextGetter::InitializeURLRequestContext() {
aw_network_delegate.Pass(),
data_reduction_proxy_settings->params(),
data_reduction_proxy_auth_request_handler_.get(),
- data_reduction_proxy::DataReductionProxyNetworkDelegate::
- ProxyConfigGetter());
+ base::Bind(
+ &data_reduction_proxy::DataReductionProxyConfigurator::
+ GetProxyConfigOnIOThread,
+ base::Unretained(
+ browser_context->GetDataReductionProxyConfigurator())));
+ data_reduction_proxy_network_delegate->InitProxyConfigOverrider(
+ base::Bind(data_reduction_proxy::OnResolveProxyHandler));
builder.set_network_delegate(data_reduction_proxy_network_delegate);
#if !defined(DISABLE_FTP_SUPPORT)
builder.set_ftp_enabled(false); // Android WebView does not support ftp yet.
#endif
- DCHECK(data_reduction_proxy_config_service_.get());
+ DCHECK(proxy_config_service_.get());
// Android provides a local HTTP proxy that handles all the proxying.
// Create the proxy without a resolver since we rely on this local HTTP proxy.
// TODO(sgurun) is this behavior guaranteed through SDK?
builder.set_proxy_service(
net::ProxyService::CreateWithoutProxyResolver(
- data_reduction_proxy_config_service_.release(),
+ proxy_config_service_.release(),
net_log_.get()));
builder.set_accept_language(net::HttpUtil::GenerateAcceptLanguageHeader(
AwContentBrowserClient::GetAcceptLangsImpl()));
diff --git a/android_webview/browser/net/aw_url_request_context_getter.h b/android_webview/browser/net/aw_url_request_context_getter.h
index b8afdf8..50736ba 100644
--- a/android_webview/browser/net/aw_url_request_context_getter.h
+++ b/android_webview/browser/net/aw_url_request_context_getter.h
@@ -25,7 +25,6 @@ class URLRequestJobFactory;
namespace data_reduction_proxy {
class DataReductionProxyAuthRequestHandler;
-class DataReductionProxyConfigService;
}
namespace android_webview {
@@ -37,8 +36,7 @@ class AwURLRequestContextGetter : public net::URLRequestContextGetter {
AwURLRequestContextGetter(
const base::FilePath& cache_path,
net::CookieStore* cookie_store,
- scoped_ptr<data_reduction_proxy::DataReductionProxyConfigService>
- config_service);
+ scoped_ptr<net::ProxyConfigService> config_service);
// net::URLRequestContextGetter implementation.
virtual net::URLRequestContext* GetURLRequestContext() override;
@@ -76,8 +74,7 @@ class AwURLRequestContextGetter : public net::URLRequestContextGetter {
scoped_refptr<net::CookieStore> cookie_store_;
scoped_ptr<net::NetLog> net_log_;
scoped_ptr<net::URLRequestContext> url_request_context_;
- scoped_ptr<data_reduction_proxy::DataReductionProxyConfigService>
- data_reduction_proxy_config_service_;
+ scoped_ptr<net::ProxyConfigService> proxy_config_service_;
scoped_ptr<data_reduction_proxy::DataReductionProxyAuthRequestHandler>
data_reduction_proxy_auth_request_handler_;
scoped_ptr<net::URLRequestJobFactory> job_factory_;