summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbengr@chromium.org <bengr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-14 11:45:54 +0000
committerbengr@chromium.org <bengr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-14 11:47:01 +0000
commit1273179537d43549898dd974aa4b956ac8c407ff (patch)
tree0942f4e368132bb30b89cd45ca0eb90adac9b277
parent6cad429985fe8e0889f16c71e6c7a19a6b3bf3b2 (diff)
downloadchromium_src-1273179537d43549898dd974aa4b956ac8c407ff.zip
chromium_src-1273179537d43549898dd974aa4b956ac8c407ff.tar.gz
chromium_src-1273179537d43549898dd974aa4b956ac8c407ff.tar.bz2
Use data reduction proxy when managed proxy config returns direct
Adds the configured data reduction proxies if any to the proxy info for a request, if the data reduction proxy is enabled, the data reduction proxies are not bypassed, and the proxy server returned by the proxy info if the request is direct. This change makes it possible for the data reduction proxy to coexist with managed proxy configurations, instead of being overwritten by them. The data reduction proxy may be disabled via managed prefs if this behavior is not desired. BUG=339237,339258 Review URL: https://codereview.chromium.org/449973002 Cr-Commit-Position: refs/heads/master@{#289528} git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289528 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--android_webview/browser/aw_browser_context.cc15
-rw-r--r--android_webview/browser/aw_browser_context.h3
-rw-r--r--chrome/browser/net/chrome_network_delegate.cc12
-rw-r--r--chrome/browser/net/chrome_network_delegate.h19
-rw-r--r--chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.cc43
-rw-r--r--chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.h25
-rw-r--r--chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator_unittest.cc5
-rw-r--r--chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc5
-rw-r--r--chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h3
-rw-r--r--chrome/browser/profiles/profile_impl.cc20
-rw-r--r--chrome/browser/profiles/profile_impl_io_data.cc9
-rw-r--r--chrome/browser/profiles/profile_impl_io_data.h7
-rw-r--r--components/data_reduction_proxy/browser/data_reduction_proxy_protocol.cc13
-rw-r--r--components/data_reduction_proxy/browser/data_reduction_proxy_protocol.h4
-rw-r--r--components/data_reduction_proxy/browser/data_reduction_proxy_protocol_unittest.cc118
-rw-r--r--components/data_reduction_proxy/browser/data_reduction_proxy_settings.cc11
-rw-r--r--components/data_reduction_proxy/browser/data_reduction_proxy_settings.h8
-rw-r--r--components/data_reduction_proxy/browser/data_reduction_proxy_settings_test_utils.cc8
-rw-r--r--components/data_reduction_proxy/browser/data_reduction_proxy_settings_test_utils.h1
-rw-r--r--components/data_reduction_proxy/browser/data_reduction_proxy_settings_unittest.cc2
-rw-r--r--net/base/network_delegate.cc16
-rw-r--r--net/base/network_delegate.h6
-rw-r--r--net/proxy/proxy_service.cc4
-rw-r--r--net/proxy/proxy_service_unittest.cc16
24 files changed, 301 insertions, 72 deletions
diff --git a/android_webview/browser/aw_browser_context.cc b/android_webview/browser/aw_browser_context.cc
index 9b510e5..2626624 100644
--- a/android_webview/browser/aw_browser_context.cc
+++ b/android_webview/browser/aw_browser_context.cc
@@ -113,14 +113,15 @@ void AwBrowserContext::PreMainMessageLoopRun() {
BrowserThread::GetMessageLoopProxyForThread(
BrowserThread::IO),
NULL /* Ignored on Android */)).Pass()));
- if (data_reduction_proxy_settings_.get()) {
- scoped_ptr<data_reduction_proxy::DataReductionProxyConfigurator>
- configurator(new data_reduction_proxy::DataReductionProxyConfigTracker(
- base::Bind(&DataReductionProxyConfigService::UpdateProxyConfig,
- base::Unretained(
- data_reduction_proxy_config_service.get())),
+ 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(configurator.Pass());
+ data_reduction_proxy_settings_->SetProxyConfigurator(
+ data_reduction_proxy_configurator_.get());
}
url_request_context_getter_ =
diff --git a/android_webview/browser/aw_browser_context.h b/android_webview/browser/aw_browser_context.h
index ab0ebef..5664da4 100644
--- a/android_webview/browser/aw_browser_context.h
+++ b/android_webview/browser/aw_browser_context.h
@@ -28,6 +28,7 @@ class WebContents;
}
namespace data_reduction_proxy {
+class DataReductionProxyConfigurator;
class DataReductionProxySettings;
}
@@ -131,6 +132,8 @@ class AwBrowserContext : public content::BrowserContext,
scoped_ptr<PrefService> user_pref_service_;
+ scoped_ptr<data_reduction_proxy::DataReductionProxyConfigurator>
+ data_reduction_proxy_configurator_;
scoped_ptr<data_reduction_proxy::DataReductionProxySettings>
data_reduction_proxy_settings_;
diff --git a/chrome/browser/net/chrome_network_delegate.cc b/chrome/browser/net/chrome_network_delegate.cc
index 3d0f1b6..37683b0 100644
--- a/chrome/browser/net/chrome_network_delegate.cc
+++ b/chrome/browser/net/chrome_network_delegate.cc
@@ -47,7 +47,9 @@
#include "net/cookies/cookie_options.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_response_headers.h"
+#include "net/proxy/proxy_config.h"
#include "net/proxy/proxy_info.h"
+#include "net/proxy/proxy_retry_info.h"
#include "net/proxy/proxy_server.h"
#include "net/socket_stream/socket_stream.h"
#include "net/url_request/url_request.h"
@@ -427,9 +429,15 @@ int ChromeNetworkDelegate::OnBeforeURLRequest(
}
void ChromeNetworkDelegate::OnResolveProxy(
- const GURL& url, int load_flags, net::ProxyInfo* result) {
- if (!on_resolve_proxy_handler_.is_null()) {
+ const GURL& url,
+ int load_flags,
+ const net::ProxyService& proxy_service,
+ net::ProxyInfo* result) {
+ if (!on_resolve_proxy_handler_.is_null() &&
+ !proxy_config_getter_.is_null()) {
on_resolve_proxy_handler_.Run(url, load_flags,
+ proxy_config_getter_.Run(),
+ proxy_service.proxy_retry_info(),
data_reduction_proxy_params_, result);
}
}
diff --git a/chrome/browser/net/chrome_network_delegate.h b/chrome/browser/net/chrome_network_delegate.h
index f7c03dc..07e9af7 100644
--- a/chrome/browser/net/chrome_network_delegate.h
+++ b/chrome/browser/net/chrome_network_delegate.h
@@ -15,6 +15,7 @@
#include "base/values.h"
#include "components/data_reduction_proxy/browser/data_reduction_proxy_metrics.h"
#include "net/base/network_delegate.h"
+#include "net/proxy/proxy_retry_info.h"
class ChromeExtensionsNetworkDelegate;
class ClientHints;
@@ -50,8 +51,10 @@ class InfoMap;
}
namespace net {
+class ProxyConfig;
class ProxyInfo;
class ProxyServer;
+class ProxyService;
class URLRequest;
}
@@ -73,9 +76,15 @@ class ChromeNetworkDelegate : public net::NetworkDelegate {
typedef base::Callback<void(
const GURL& url,
int load_flags,
+ const net::ProxyConfig& data_reduction_proxy_config,
+ const net::ProxyRetryInfoMap& proxy_retry_info_map,
const data_reduction_proxy::DataReductionProxyParams* params,
net::ProxyInfo* result)> OnResolveProxyHandler;
+ // Provides an additional proxy configuration that can be consulted after
+ // proxy resolution.
+ typedef base::Callback<const net::ProxyConfig&()> ProxyConfigGetter;
+
// |enable_referrers| (and all of the other optional PrefMembers) should be
// initialized on the UI thread (see below) beforehand. This object's owner is
// responsible for cleaning them up at shutdown.
@@ -161,6 +170,10 @@ class ChromeNetworkDelegate : public net::NetworkDelegate {
on_resolve_proxy_handler_ = handler;
}
+ void set_proxy_config_getter(const ProxyConfigGetter& getter) {
+ proxy_config_getter_ = getter;
+ }
+
// Adds the Client Hints header to HTTP requests.
void SetEnableClientHints();
@@ -198,7 +211,10 @@ class ChromeNetworkDelegate : public net::NetworkDelegate {
const net::CompletionCallback& callback,
GURL* new_url) OVERRIDE;
virtual void OnResolveProxy(
- const GURL& url, int load_flags, net::ProxyInfo* result) OVERRIDE;
+ const GURL& url,
+ int load_flags,
+ const net::ProxyService& proxy_service,
+ net::ProxyInfo* result) OVERRIDE;
virtual void OnProxyFallback(const net::ProxyServer& bad_proxy,
int net_error,
bool did_fallback) OVERRIDE;
@@ -306,6 +322,7 @@ class ChromeNetworkDelegate : public net::NetworkDelegate {
data_reduction_proxy_auth_request_handler_;
OnResolveProxyHandler on_resolve_proxy_handler_;
+ ProxyConfigGetter proxy_config_getter_;
DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegate);
};
diff --git a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.cc b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.cc
index 1201cf0..cb9e788 100644
--- a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.cc
+++ b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.cc
@@ -6,13 +6,18 @@
#include "base/prefs/pref_service.h"
#include "base/prefs/scoped_user_pref_update.h"
+#include "base/sequenced_task_runner.h"
#include "base/strings/string_util.h"
#include "chrome/browser/prefs/proxy_prefs.h"
#include "chrome/common/pref_names.h"
+#include "net/proxy/proxy_config.h"
+#include "net/proxy/proxy_info.h"
+#include "net/proxy/proxy_service.h"
DataReductionProxyChromeConfigurator::DataReductionProxyChromeConfigurator(
- PrefService* prefs) : prefs_(prefs) {
- DCHECK(prefs);
+ PrefService* prefs,
+ scoped_refptr<base::SequencedTaskRunner> network_task_runner)
+ : prefs_(prefs), network_task_runner_(network_task_runner) {
}
DataReductionProxyChromeConfigurator::~DataReductionProxyChromeConfigurator() {
@@ -26,6 +31,8 @@ void DataReductionProxyChromeConfigurator::Enable(
const std::string& ssl_origin) {
DCHECK(prefs_);
DictionaryPrefUpdate update(prefs_, prefs::kProxy);
+ // TODO(bengr): Consider relying on the proxy config for all data reduction
+ // proxy configuration.
base::DictionaryValue* dict = update.Get();
std::vector<std::string> proxies;
@@ -60,6 +67,21 @@ void DataReductionProxyChromeConfigurator::Enable(
dict->SetString("server", server);
dict->SetString("mode", ProxyModeToString(ProxyPrefs::MODE_FIXED_SERVERS));
dict->SetString("bypass_list", JoinString(bypass_rules_, ", "));
+
+ net::ProxyConfig config;
+ config.proxy_rules().ParseFromString(server);
+ config.proxy_rules().bypass_rules.ParseFromString(
+ JoinString(bypass_rules_, ", "));
+ // The ID is set to a bogus value. It cannot be left uninitialized, else the
+ // config will return invalid.
+ net::ProxyConfig::ID unused_id = 1;
+ config.set_id(unused_id);
+ network_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(
+ &DataReductionProxyChromeConfigurator::UpdateProxyConfigOnIO,
+ base::Unretained(this),
+ config));
}
void DataReductionProxyChromeConfigurator::Disable() {
@@ -69,6 +91,13 @@ void DataReductionProxyChromeConfigurator::Disable() {
dict->SetString("mode", ProxyModeToString(ProxyPrefs::MODE_SYSTEM));
dict->SetString("server", "");
dict->SetString("bypass_list", "");
+ net::ProxyConfig config = net::ProxyConfig::CreateDirect();
+ network_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(
+ &DataReductionProxyChromeConfigurator::UpdateProxyConfigOnIO,
+ base::Unretained(this),
+ config));
}
void DataReductionProxyChromeConfigurator::AddHostPatternToBypass(
@@ -90,3 +119,13 @@ void DataReductionProxyChromeConfigurator::AddURLPatternToBypass(
AddHostPatternToBypass(host_pattern);
}
+
+void DataReductionProxyChromeConfigurator::UpdateProxyConfigOnIO(
+ const net::ProxyConfig& config) {
+ config_ = config;
+}
+
+const net::ProxyConfig&
+DataReductionProxyChromeConfigurator::GetProxyConfigOnIO() const {
+ return config_;
+}
diff --git a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.h b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.h
index 8efc3ed..72c7d49 100644
--- a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.h
+++ b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.h
@@ -9,14 +9,27 @@
#include <vector>
#include "base/gtest_prod_util.h"
+#include "base/task_runner.h"
#include "components/data_reduction_proxy/browser/data_reduction_proxy_configurator.h"
+#include "net/proxy/proxy_config.h"
+
+namespace base {
+class SequencedTaskRunner;
+}
+
+namespace net {
+class ProxyInfo;
+class ProxyService;
+}
class PrefService;
class DataReductionProxyChromeConfigurator
: public data_reduction_proxy::DataReductionProxyConfigurator {
public:
- explicit DataReductionProxyChromeConfigurator(PrefService* prefs);
+ explicit DataReductionProxyChromeConfigurator(
+ PrefService* prefs,
+ scoped_refptr<base::SequencedTaskRunner> network_task_runner);
virtual ~DataReductionProxyChromeConfigurator();
virtual void Enable(bool primary_restricted,
@@ -38,11 +51,21 @@ class DataReductionProxyChromeConfigurator
// as a hostname pattern. Subclasses may implement other semantics.
virtual void AddURLPatternToBypass(const std::string& pattern) OVERRIDE;
+ // Updates the config for use on the IO thread.
+ void UpdateProxyConfigOnIO(const net::ProxyConfig& config);
+
+ // Returns the current data reduction proxy config, even if it is not the
+ // effective configuration used by the proxy service.
+ const net::ProxyConfig& GetProxyConfigOnIO() const;
+
private:
FRIEND_TEST_ALL_PREFIXES(DataReductionProxyConfigTest, TestBypassList);
PrefService* prefs_;
+ scoped_refptr<base::SequencedTaskRunner> network_task_runner_;
+
std::vector<std::string> bypass_rules_;
+ net::ProxyConfig config_;
DISALLOW_COPY_AND_ASSIGN(DataReductionProxyChromeConfigurator);
};
diff --git a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator_unittest.cc b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator_unittest.cc
index eb56ef5..06848fa 100644
--- a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator_unittest.cc
+++ b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator_unittest.cc
@@ -9,6 +9,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/prefs/pref_registry_simple.h"
#include "base/prefs/testing_pref_service.h"
+#include "base/test/test_simple_task_runner.h"
#include "base/values.h"
#include "chrome/common/pref_names.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -19,7 +20,9 @@ class DataReductionProxyConfigTest : public testing::Test {
virtual void SetUp() {
PrefRegistrySimple* registry = pref_service_.registry();
registry->RegisterDictionaryPref(prefs::kProxy);
- config_.reset(new DataReductionProxyChromeConfigurator(&pref_service_));
+ config_.reset(new DataReductionProxyChromeConfigurator(
+ &pref_service_,
+ new base::TestSimpleTaskRunner()));
}
void CheckProxyConfig(
diff --git a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc
index 19ac6f1..26be2de 100644
--- a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc
+++ b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.cc
@@ -30,12 +30,11 @@ DataReductionProxyChromeSettings::~DataReductionProxyChromeSettings() {
}
void DataReductionProxyChromeSettings::InitDataReductionProxySettings(
- scoped_ptr<data_reduction_proxy::DataReductionProxyConfigurator>
- configurator,
+ data_reduction_proxy::DataReductionProxyConfigurator* configurator,
PrefService* profile_prefs,
PrefService* local_state_prefs,
net::URLRequestContextGetter* request_context) {
- SetProxyConfigurator(configurator.Pass());
+ SetProxyConfigurator(configurator);
DataReductionProxySettings::InitDataReductionProxySettings(
profile_prefs,
local_state_prefs,
diff --git a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h
index b095cb0..72f5026 100644
--- a/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h
+++ b/chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h
@@ -41,8 +41,7 @@ class DataReductionProxyChromeSettings
// Initialize the settings object with the given configurator, prefs services,
// and request context.
void InitDataReductionProxySettings(
- scoped_ptr<data_reduction_proxy::DataReductionProxyConfigurator>
- configurator,
+ data_reduction_proxy::DataReductionProxyConfigurator* configurator,
PrefService* profile_prefs,
PrefService* local_state_prefs,
net::URLRequestContextGetter* request_context);
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index 557912c..14248d6 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -45,6 +45,7 @@
#include "chrome/browser/net/predictor.h"
#include "chrome/browser/net/pref_proxy_config_tracker.h"
#include "chrome/browser/net/proxy_service_factory.h"
+#include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.h"
#include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
#include "chrome/browser/net/ssl_config_service_manager.h"
#include "chrome/browser/plugins/chrome_plugin_service_filter.h"
@@ -115,7 +116,6 @@
#endif
#if defined(SPDY_PROXY_AUTH_ORIGIN)
-#include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.h"
#include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_factory.h"
#include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h"
#include "components/data_reduction_proxy/browser/data_reduction_proxy_settings.h"
@@ -632,6 +632,7 @@ void ProfileImpl::DoFinalInit() {
base::Callback<void(bool)> data_reduction_proxy_unavailable;
scoped_ptr<data_reduction_proxy::DataReductionProxyParams>
data_reduction_proxy_params;
+ scoped_ptr<DataReductionProxyChromeConfigurator> chrome_configurator;
#if defined(SPDY_PROXY_AUTH_ORIGIN)
DataReductionProxyChromeSettings* data_reduction_proxy_chrome_settings =
DataReductionProxyChromeSettingsFactory::GetForBrowserContext(this);
@@ -641,6 +642,18 @@ void ProfileImpl::DoFinalInit() {
base::Bind(
&data_reduction_proxy::DataReductionProxySettings::SetUnreachable,
base::Unretained(data_reduction_proxy_chrome_settings));
+ // The configurator is used by DataReductionProxyChromeSettings and
+ // ProfileIOData. Ownership is passed to the latter via ProfileIOData::Handle,
+ // which is only destroyed after BrowserContextKeyedServices,
+ // including DataReductionProxyChromeSettings.
+ chrome_configurator.reset(
+ new DataReductionProxyChromeConfigurator(
+ prefs_.get(),
+ BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)));
+ // Retain a raw pointer to use for initialization of data reduction proxy
+ // settings after ownership is passed.
+ DataReductionProxyChromeConfigurator*
+ data_reduction_proxy_chrome_configurator = chrome_configurator.get();
#endif
// Make sure we initialize the ProfileIOData after everything else has been
@@ -652,13 +665,12 @@ void ProfileImpl::DoFinalInit() {
predictor_, session_cookie_mode, GetSpecialStoragePolicy(),
CreateDomainReliabilityMonitor(),
data_reduction_proxy_unavailable,
+ chrome_configurator.Pass(),
data_reduction_proxy_params.Pass());
#if defined(SPDY_PROXY_AUTH_ORIGIN)
- scoped_ptr<data_reduction_proxy::DataReductionProxyConfigurator>
- configurator(new DataReductionProxyChromeConfigurator(prefs_.get()));
data_reduction_proxy_chrome_settings->InitDataReductionProxySettings(
- configurator.Pass(),
+ data_reduction_proxy_chrome_configurator,
prefs_.get(),
g_browser_process->local_state(),
GetRequestContext());
diff --git a/chrome/browser/profiles/profile_impl_io_data.cc b/chrome/browser/profiles/profile_impl_io_data.cc
index 1c49b31..a53d195 100644
--- a/chrome/browser/profiles/profile_impl_io_data.cc
+++ b/chrome/browser/profiles/profile_impl_io_data.cc
@@ -26,6 +26,7 @@
#include "chrome/browser/net/cookie_store_util.h"
#include "chrome/browser/net/http_server_properties_manager_factory.h"
#include "chrome/browser/net/predictor.h"
+#include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.h"
#include "chrome/browser/net/sqlite_channel_id_store.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_constants.h"
@@ -153,6 +154,8 @@ void ProfileImplIOData::Handle::Init(
scoped_ptr<domain_reliability::DomainReliabilityMonitor>
domain_reliability_monitor,
const base::Callback<void(bool)>& data_reduction_proxy_unavailable,
+ scoped_ptr<DataReductionProxyChromeConfigurator>
+ data_reduction_proxy_chrome_configurator,
scoped_ptr<data_reduction_proxy::DataReductionProxyParams>
data_reduction_proxy_params) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -188,6 +191,8 @@ void ProfileImplIOData::Handle::Init(
#if defined(SPDY_PROXY_AUTH_ORIGIN)
io_data_->data_reduction_proxy_unavailable_callback_ =
data_reduction_proxy_unavailable;
+ io_data_->data_reduction_proxy_chrome_configurator_ =
+ data_reduction_proxy_chrome_configurator.Pass();
io_data_->data_reduction_proxy_params_ =
data_reduction_proxy_params.Pass();
#endif // defined(SPDY_PROXY_AUTH_ORIGIN)
@@ -435,6 +440,10 @@ void ProfileImplIOData::InitializeInternal(
data_reduction_proxy_auth_request_handler_.get());
network_delegate()->set_on_resolve_proxy_handler(
base::Bind(data_reduction_proxy::OnResolveProxyHandler));
+ network_delegate()->set_proxy_config_getter(
+ base::Bind(
+ &DataReductionProxyChromeConfigurator::GetProxyConfigOnIO,
+ base::Unretained(data_reduction_proxy_chrome_configurator_.get())));
#endif // defined(SPDY_PROXY_AUTH_ORIGIN)
network_delegate()->set_predictor(predictor_.get());
diff --git a/chrome/browser/profiles/profile_impl_io_data.h b/chrome/browser/profiles/profile_impl_io_data.h
index 3a6f529..9ca3263 100644
--- a/chrome/browser/profiles/profile_impl_io_data.h
+++ b/chrome/browser/profiles/profile_impl_io_data.h
@@ -39,6 +39,7 @@ class FtpTransactionFactory;
class HttpServerProperties;
class HttpServerPropertiesManager;
class HttpTransactionFactory;
+class ProxyConfig;
class SDCHManager;
} // namespace net
@@ -46,6 +47,8 @@ namespace quota {
class SpecialStoragePolicy;
} // namespace quota
+class DataReductionProxyChromeConfigurator;
+
class ProfileImplIOData : public ProfileIOData {
public:
class Handle {
@@ -72,6 +75,8 @@ class ProfileImplIOData : public ProfileIOData {
domain_reliability_monitor,
const base::Callback<void(bool)>&
data_reduction_proxy_unavailable,
+ scoped_ptr<DataReductionProxyChromeConfigurator>
+ data_reduction_proxy_chrome_configurator,
scoped_ptr<data_reduction_proxy::DataReductionProxyParams>
data_reduction_proxy_params);
@@ -249,6 +254,8 @@ class ProfileImplIOData : public ProfileIOData {
mutable scoped_ptr<data_reduction_proxy::DataReductionProxyUsageStats>
data_reduction_proxy_usage_stats_;
mutable base::Callback<void(bool)> data_reduction_proxy_unavailable_callback_;
+ mutable scoped_ptr<DataReductionProxyChromeConfigurator>
+ data_reduction_proxy_chrome_configurator_;
mutable scoped_ptr<data_reduction_proxy::DataReductionProxyAuthRequestHandler>
data_reduction_proxy_auth_request_handler_;
#endif // defined(SPDY_PROXY_AUTH_ORIGIN)
diff --git a/components/data_reduction_proxy/browser/data_reduction_proxy_protocol.cc b/components/data_reduction_proxy/browser/data_reduction_proxy_protocol.cc
index 6c4fc87..aae5ee3 100644
--- a/components/data_reduction_proxy/browser/data_reduction_proxy_protocol.cc
+++ b/components/data_reduction_proxy/browser/data_reduction_proxy_protocol.cc
@@ -12,8 +12,10 @@
#include "components/data_reduction_proxy/common/data_reduction_proxy_headers.h"
#include "net/base/load_flags.h"
#include "net/http/http_response_headers.h"
+#include "net/proxy/proxy_config.h"
#include "net/proxy/proxy_info.h"
#include "net/proxy/proxy_list.h"
+#include "net/proxy/proxy_retry_info.h"
#include "net/proxy/proxy_server.h"
#include "net/proxy/proxy_service.h"
#include "net/url_request/url_request.h"
@@ -109,8 +111,19 @@ bool MaybeBypassProxyAndPrepareToRetry(
void OnResolveProxyHandler(const GURL& url,
int load_flags,
+ const net::ProxyConfig& data_reduction_proxy_config,
+ const net::ProxyRetryInfoMap& proxy_retry_info,
const DataReductionProxyParams* params,
net::ProxyInfo* result) {
+ if (data_reduction_proxy_config.is_valid() &&
+ result->proxy_server().is_direct()) {
+ net::ProxyInfo data_reduction_proxy_info;
+ data_reduction_proxy_config.proxy_rules().Apply(
+ url, &data_reduction_proxy_info);
+ data_reduction_proxy_info.DeprioritizeBadProxies(proxy_retry_info);
+ result->Use(data_reduction_proxy_info);
+ }
+
if ((load_flags & net::LOAD_BYPASS_DATA_REDUCTION_PROXY) &&
DataReductionProxyParams::IsIncludedInCriticalPathBypassFieldTrial() &&
!result->is_empty() &&
diff --git a/components/data_reduction_proxy/browser/data_reduction_proxy_protocol.h b/components/data_reduction_proxy/browser/data_reduction_proxy_protocol.h
index b32ed6a..e592713 100644
--- a/components/data_reduction_proxy/browser/data_reduction_proxy_protocol.h
+++ b/components/data_reduction_proxy/browser/data_reduction_proxy_protocol.h
@@ -7,6 +7,7 @@
#include "base/memory/ref_counted.h"
#include "components/data_reduction_proxy/common/data_reduction_proxy_headers.h"
+#include "net/proxy/proxy_retry_info.h"
namespace base {
class TimeDelta;
@@ -14,6 +15,7 @@ class TimeDelta;
namespace net {
class HttpResponseHeaders;
+class ProxyConfig;
class ProxyInfo;
class ProxyServer;
class URLRequest;
@@ -44,6 +46,8 @@ bool MaybeBypassProxyAndPrepareToRetry(
// |ChromeNetworkDelegate.NotifyResolveProxy|.
void OnResolveProxyHandler(const GURL& url,
int load_flags,
+ const net::ProxyConfig& data_reduction_proxy_config,
+ const net::ProxyRetryInfoMap& proxy_retry_info,
const DataReductionProxyParams* params,
net::ProxyInfo* result);
diff --git a/components/data_reduction_proxy/browser/data_reduction_proxy_protocol_unittest.cc b/components/data_reduction_proxy/browser/data_reduction_proxy_protocol_unittest.cc
index 603bd71..60e663b 100644
--- a/components/data_reduction_proxy/browser/data_reduction_proxy_protocol_unittest.cc
+++ b/components/data_reduction_proxy/browser/data_reduction_proxy_protocol_unittest.cc
@@ -793,33 +793,95 @@ TEST_F(DataReductionProxyProtocolTest, OnResolveProxyHandler) {
TestDataReductionProxyParams::HAS_EVERYTHING &
~TestDataReductionProxyParams::HAS_DEV_ORIGIN);
- // Data reduction proxy
- net::ProxyInfo info1;
+ // Data reduction proxy info
+ net::ProxyInfo data_reduction_proxy_info;
std::string data_reduction_proxy;
base::TrimString(test_params.DefaultOrigin(), "/", &data_reduction_proxy);
- info1.UseNamedProxy(data_reduction_proxy);
- EXPECT_FALSE(info1.is_empty());
+ data_reduction_proxy_info.UseNamedProxy(data_reduction_proxy);
+ EXPECT_FALSE(data_reduction_proxy_info.is_empty());
+
+ // Data reduction proxy config
+ net::ProxyConfig data_reduction_proxy_config;
+ data_reduction_proxy_config.proxy_rules().ParseFromString(
+ "http=" + data_reduction_proxy + ",direct://;");
+ data_reduction_proxy_config.set_id(1);
+
+ // Other proxy info
+ net::ProxyInfo other_proxy_info;
+ other_proxy_info.UseNamedProxy("proxy.com");
+ EXPECT_FALSE(other_proxy_info.is_empty());
+
+ // Direct
+ net::ProxyInfo direct_proxy_info;
+ direct_proxy_info.UseDirect();
+ EXPECT_TRUE(direct_proxy_info.is_direct());
+
+ // Empty retry info map
+ net::ProxyRetryInfoMap empty_proxy_retry_info;
+
+ // Retry info map with the data reduction proxy;
+ net::ProxyRetryInfoMap data_reduction_proxy_retry_info;
+ net::ProxyRetryInfo retry_info;
+ retry_info.current_delay = base::TimeDelta::FromSeconds(1000);
+ retry_info.bad_until = base::TimeTicks().Now() + retry_info.current_delay;
+ retry_info.try_while_bad = false;
+ data_reduction_proxy_retry_info[
+ data_reduction_proxy_info.proxy_server().ToURI()] = retry_info;
+
+ net::ProxyInfo result;
+
+ // The data reduction proxy is used. It should be used afterwards.
+ result.Use(data_reduction_proxy_info);
+ OnResolveProxyHandler(url, load_flags, data_reduction_proxy_config,
+ empty_proxy_retry_info, &test_params, &result);
+ EXPECT_EQ(data_reduction_proxy_info.proxy_server(), result.proxy_server());
+
+ // Another proxy is used. It should be used afterwards.
+ result.Use(other_proxy_info);
+ OnResolveProxyHandler(url, load_flags, data_reduction_proxy_config,
+ empty_proxy_retry_info, &test_params, &result);
+ EXPECT_EQ(other_proxy_info.proxy_server(), result.proxy_server());
+
+ // A direct connection is used. The data reduction proxy should be used
+ // afterwards.
+ // Another proxy is used. It should be used afterwards.
+ result.Use(direct_proxy_info);
+ OnResolveProxyHandler(url, load_flags, data_reduction_proxy_config,
+ empty_proxy_retry_info, &test_params, &result);
+ EXPECT_EQ(data_reduction_proxy_info.proxy_server(), result.proxy_server());
+
+ // A direct connection is used, but the data reduction proxy is on the retry
+ // list. A direct connection should be used afterwards.
+ result.Use(direct_proxy_info);
+ OnResolveProxyHandler(url, load_flags, data_reduction_proxy_config,
+ data_reduction_proxy_retry_info, &test_params,
+ &result);
+ EXPECT_TRUE(result.proxy_server().is_direct());
- // Other proxy
- net::ProxyInfo info2;
- info2.UseNamedProxy("proxy.com");
- EXPECT_FALSE(info2.is_empty());
// Without DataCompressionProxyCriticalBypass Finch trial set, should never
// bypass.
- OnResolveProxyHandler(url, load_flags, &test_params, &info1);
- EXPECT_FALSE(info1.is_direct());
+ OnResolveProxyHandler(url, load_flags, data_reduction_proxy_config,
+ empty_proxy_retry_info, &test_params,
+ &data_reduction_proxy_info);
+ EXPECT_FALSE(data_reduction_proxy_info.is_direct());
- OnResolveProxyHandler(url, load_flags, &test_params,&info2);
- EXPECT_FALSE(info2.is_direct());
+ OnResolveProxyHandler(url, load_flags, data_reduction_proxy_config,
+ empty_proxy_retry_info, &test_params,
+ &other_proxy_info);
+ EXPECT_FALSE(other_proxy_info.is_direct());
load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY;
- OnResolveProxyHandler(url, load_flags, &test_params, &info1);
- EXPECT_FALSE(info1.is_direct());
+ OnResolveProxyHandler(url, load_flags, data_reduction_proxy_config,
+ empty_proxy_retry_info, &test_params,
+ &data_reduction_proxy_info);
+ EXPECT_FALSE(data_reduction_proxy_info.is_direct());
- OnResolveProxyHandler(url, load_flags, &test_params, &info2);
- EXPECT_FALSE(info2.is_direct());
+ OnResolveProxyHandler(url, load_flags, data_reduction_proxy_config,
+ empty_proxy_retry_info, &test_params,
+ &other_proxy_info);
+ EXPECT_FALSE(other_proxy_info.is_direct());
// With Finch trial set, should only bypass if LOAD flag is set and the
// effective proxy is the data compression proxy.
@@ -833,19 +895,27 @@ TEST_F(DataReductionProxyProtocolTest, OnResolveProxyHandler) {
load_flags = net::LOAD_NORMAL;
- OnResolveProxyHandler(url, load_flags, &test_params, &info1);
- EXPECT_FALSE(info1.is_direct());
+ OnResolveProxyHandler(url, load_flags, data_reduction_proxy_config,
+ empty_proxy_retry_info, &test_params,
+ &data_reduction_proxy_info);
+ EXPECT_FALSE(data_reduction_proxy_info.is_direct());
- OnResolveProxyHandler(url, load_flags, &test_params, &info2);
- EXPECT_FALSE(info2.is_direct());
+ OnResolveProxyHandler(url, load_flags, data_reduction_proxy_config,
+ empty_proxy_retry_info, &test_params,
+ &other_proxy_info);
+ EXPECT_FALSE(other_proxy_info.is_direct());
load_flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY;
- OnResolveProxyHandler(url, load_flags, &test_params, &info2);
- EXPECT_FALSE(info2.is_direct());
+ OnResolveProxyHandler(url, load_flags, data_reduction_proxy_config,
+ empty_proxy_retry_info, &test_params,
+ &other_proxy_info);
+ EXPECT_FALSE(other_proxy_info.is_direct());
- OnResolveProxyHandler(url, load_flags, &test_params, &info1);
- EXPECT_TRUE(info1.is_direct());
+ OnResolveProxyHandler(url, load_flags, data_reduction_proxy_config,
+ empty_proxy_retry_info, &test_params,
+ &data_reduction_proxy_info);
+ EXPECT_TRUE(data_reduction_proxy_info.is_direct());
}
} // namespace data_reduction_proxy
diff --git a/components/data_reduction_proxy/browser/data_reduction_proxy_settings.cc b/components/data_reduction_proxy/browser/data_reduction_proxy_settings.cc
index a853668..09f5d2c 100644
--- a/components/data_reduction_proxy/browser/data_reduction_proxy_settings.cc
+++ b/components/data_reduction_proxy/browser/data_reduction_proxy_settings.cc
@@ -94,7 +94,8 @@ DataReductionProxySettings::DataReductionProxySettings(
unreachable_(false),
prefs_(NULL),
local_state_prefs_(NULL),
- url_request_context_getter_(NULL) {
+ url_request_context_getter_(NULL),
+ configurator_(NULL) {
DCHECK(params);
params_.reset(params);
}
@@ -149,11 +150,11 @@ void DataReductionProxySettings::InitDataReductionProxySettings(
PrefService* prefs,
PrefService* local_state_prefs,
net::URLRequestContextGetter* url_request_context_getter,
- scoped_ptr<DataReductionProxyConfigurator> configurator) {
+ DataReductionProxyConfigurator* configurator) {
InitDataReductionProxySettings(prefs,
local_state_prefs,
url_request_context_getter);
- SetProxyConfigurator(configurator.Pass());
+ SetProxyConfigurator(configurator);
}
void DataReductionProxySettings::SetOnDataReductionEnabledCallback(
@@ -163,9 +164,9 @@ void DataReductionProxySettings::SetOnDataReductionEnabledCallback(
}
void DataReductionProxySettings::SetProxyConfigurator(
- scoped_ptr<DataReductionProxyConfigurator> configurator) {
+ DataReductionProxyConfigurator* configurator) {
DCHECK(configurator);
- configurator_ = configurator.Pass();
+ configurator_ = configurator;
}
bool DataReductionProxySettings::IsDataReductionProxyEnabled() {
diff --git a/components/data_reduction_proxy/browser/data_reduction_proxy_settings.h b/components/data_reduction_proxy/browser/data_reduction_proxy_settings.h
index f974b66..804023b 100644
--- a/components/data_reduction_proxy/browser/data_reduction_proxy_settings.h
+++ b/components/data_reduction_proxy/browser/data_reduction_proxy_settings.h
@@ -115,7 +115,7 @@ class DataReductionProxySettings
PrefService* prefs,
PrefService* local_state_prefs,
net::URLRequestContextGetter* url_request_context_getter,
- scoped_ptr<DataReductionProxyConfigurator> configurator);
+ DataReductionProxyConfigurator* configurator);
// Sets the |on_data_reduction_proxy_enabled_| callback and runs to register
// the DataReductionProxyEnabled synthetic field trial.
@@ -125,7 +125,7 @@ class DataReductionProxySettings
// Sets the logic the embedder uses to set the networking configuration that
// causes traffic to be proxied.
void SetProxyConfigurator(
- scoped_ptr<DataReductionProxyConfigurator> configurator);
+ DataReductionProxyConfigurator* configurator);
// Returns true if the proxy is enabled.
bool IsDataReductionProxyEnabled();
@@ -227,7 +227,7 @@ class DataReductionProxySettings
int policy);
DataReductionProxyConfigurator* configurator() {
- return configurator_.get();
+ return configurator_;
}
// Reset params for tests.
@@ -313,7 +313,7 @@ class DataReductionProxySettings
base::Callback<void(bool)> on_data_reduction_proxy_enabled_;
- scoped_ptr<DataReductionProxyConfigurator> configurator_;
+ DataReductionProxyConfigurator* configurator_;
base::ThreadChecker thread_checker_;
diff --git a/components/data_reduction_proxy/browser/data_reduction_proxy_settings_test_utils.cc b/components/data_reduction_proxy/browser/data_reduction_proxy_settings_test_utils.cc
index ccd3c2d..7cf609a 100644
--- a/components/data_reduction_proxy/browser/data_reduction_proxy_settings_test_utils.cc
+++ b/components/data_reduction_proxy/browser/data_reduction_proxy_settings_test_utils.cc
@@ -146,7 +146,8 @@ void DataReductionProxySettingsTestBase::ResetSettings(bool allowed,
EXPECT_CALL(*settings, GetURLFetcherForWarmup()).Times(0);
EXPECT_CALL(*settings, LogProxyState(_, _, _)).Times(0);
settings_.reset(settings);
- settings_->configurator_.reset(new TestDataReductionProxyConfig());
+ configurator_.reset(new TestDataReductionProxyConfig());
+ settings_->configurator_ = configurator_.get();
}
// Explicitly generate required instantiations.
@@ -210,8 +211,7 @@ void DataReductionProxySettingsTestBase::CheckProxyConfigs(
bool expected_restricted,
bool expected_fallback_restricted) {
TestDataReductionProxyConfig* config =
- static_cast<TestDataReductionProxyConfig*>(
- settings_->configurator_.get());
+ static_cast<TestDataReductionProxyConfig*>(settings_->configurator_);
ASSERT_EQ(expected_restricted, config->restricted_);
ASSERT_EQ(expected_fallback_restricted, config->fallback_restricted_);
ASSERT_EQ(expected_enabled, config->enabled_);
@@ -297,7 +297,7 @@ void DataReductionProxySettingsTestBase::CheckInitDataReductionProxy(
enabled_at_startup ? 1 : 0);
scoped_ptr<DataReductionProxyConfigurator> configurator(
new TestDataReductionProxyConfig());
- settings_->SetProxyConfigurator(configurator.Pass());
+ settings_->SetProxyConfigurator(configurator.get());
scoped_refptr<net::TestURLRequestContextGetter> request_context =
new net::TestURLRequestContextGetter(base::MessageLoopProxy::current());
diff --git a/components/data_reduction_proxy/browser/data_reduction_proxy_settings_test_utils.h b/components/data_reduction_proxy/browser/data_reduction_proxy_settings_test_utils.h
index 0ece527..eb8ef0e 100644
--- a/components/data_reduction_proxy/browser/data_reduction_proxy_settings_test_utils.h
+++ b/components/data_reduction_proxy/browser/data_reduction_proxy_settings_test_utils.h
@@ -162,6 +162,7 @@ class DataReductionProxySettingsTestBase : public testing::Test {
}
TestingPrefServiceSimple pref_service_;
+ scoped_ptr<DataReductionProxyConfigurator> configurator_;
scoped_ptr<DataReductionProxySettings> settings_;
scoped_ptr<TestDataReductionProxyParams> expected_params_;
base::Time last_update_time_;
diff --git a/components/data_reduction_proxy/browser/data_reduction_proxy_settings_unittest.cc b/components/data_reduction_proxy/browser/data_reduction_proxy_settings_unittest.cc
index f461925..9e77071 100644
--- a/components/data_reduction_proxy/browser/data_reduction_proxy_settings_unittest.cc
+++ b/components/data_reduction_proxy/browser/data_reduction_proxy_settings_unittest.cc
@@ -417,7 +417,7 @@ TEST_F(DataReductionProxySettingsTest, CheckInitMetricsWhenNotAllowed) {
scoped_ptr<DataReductionProxyConfigurator> configurator(
new TestDataReductionProxyConfig());
- settings_->SetProxyConfigurator(configurator.Pass());
+ settings_->SetProxyConfigurator(configurator.get());
scoped_refptr<net::TestURLRequestContextGetter> request_context =
new net::TestURLRequestContextGetter(base::MessageLoopProxy::current());
settings_->InitDataReductionProxySettings(
diff --git a/net/base/network_delegate.cc b/net/base/network_delegate.cc
index 7591752..dbaa431 100644
--- a/net/base/network_delegate.cc
+++ b/net/base/network_delegate.cc
@@ -21,11 +21,14 @@ int NetworkDelegate::NotifyBeforeURLRequest(
return OnBeforeURLRequest(request, callback, new_url);
}
-void NetworkDelegate::NotifyResolveProxy(const GURL& url, int load_flags,
- ProxyInfo* result) {
+void NetworkDelegate::NotifyResolveProxy(
+ const GURL& url,
+ int load_flags,
+ const ProxyService& proxy_service,
+ ProxyInfo* result) {
DCHECK(CalledOnValidThread());
DCHECK(result);
- OnResolveProxy(url, load_flags, result);
+ OnResolveProxy(url, load_flags, proxy_service, result);
}
void NetworkDelegate::NotifyProxyFallback(
@@ -170,8 +173,11 @@ int NetworkDelegate::OnBeforeURLRequest(URLRequest* request,
return OK;
}
-void NetworkDelegate::OnResolveProxy(const GURL& url, int load_flags,
- ProxyInfo* result) {
+void NetworkDelegate::OnResolveProxy(
+ const GURL& url,
+ int load_flags,
+ const ProxyService& proxy_service,
+ ProxyInfo* result) {
}
void NetworkDelegate::OnProxyFallback(const ProxyServer& bad_proxy,
diff --git a/net/base/network_delegate.h b/net/base/network_delegate.h
index eafaca6..2a0c9f0 100644
--- a/net/base/network_delegate.h
+++ b/net/base/network_delegate.h
@@ -37,6 +37,7 @@ class HttpRequestHeaders;
class HttpResponseHeaders;
class ProxyInfo;
class ProxyServer;
+class ProxyService;
class SocketStream;
class URLRequest;
@@ -62,7 +63,9 @@ class NET_EXPORT NetworkDelegate : public base::NonThreadSafe {
int NotifyBeforeURLRequest(URLRequest* request,
const CompletionCallback& callback,
GURL* new_url);
- void NotifyResolveProxy(const GURL& url, int load_flags,
+ void NotifyResolveProxy(const GURL& url,
+ int load_flags,
+ const ProxyService& proxy_service,
ProxyInfo* result);
void NotifyProxyFallback(const ProxyServer& bad_proxy,
int net_error,
@@ -132,6 +135,7 @@ class NET_EXPORT NetworkDelegate : public base::NonThreadSafe {
// may override the decision by modifying the ProxyInfo |result|.
virtual void OnResolveProxy(const GURL& url,
int load_flags,
+ const ProxyService& proxy_service,
ProxyInfo* result);
// Called when use of |bad_proxy| fails due to |net_error|. |did_fallback| is
diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc
index 4006110..6bd519c 100644
--- a/net/proxy/proxy_service.cc
+++ b/net/proxy/proxy_service.cc
@@ -1297,7 +1297,7 @@ int ProxyService::DidFinishResolvingProxy(const GURL& url,
// Allow the network delegate to interpose on the resolution decision,
// possibly modifying the ProxyInfo.
if (network_delegate)
- network_delegate->NotifyResolveProxy(url, load_flags, result);
+ network_delegate->NotifyResolveProxy(url, load_flags, *this, result);
// When logging all events is enabled, dump the proxy list.
if (net_log.IsLogging()) {
@@ -1324,7 +1324,7 @@ int ProxyService::DidFinishResolvingProxy(const GURL& url,
// Allow the network delegate to interpose on the resolution decision,
// possibly modifying the ProxyInfo.
if (network_delegate)
- network_delegate->NotifyResolveProxy(url, load_flags, result);
+ network_delegate->NotifyResolveProxy(url, load_flags, *this, result);
} else {
result_code = ERR_MANDATORY_PROXY_CONFIGURATION_FAILED;
}
diff --git a/net/proxy/proxy_service_unittest.cc b/net/proxy/proxy_service_unittest.cc
index a2dcf3f..1d5b1c7 100644
--- a/net/proxy/proxy_service_unittest.cc
+++ b/net/proxy/proxy_service_unittest.cc
@@ -161,12 +161,16 @@ class TestResolveProxyNetworkDelegate : public NetworkDelegate {
TestResolveProxyNetworkDelegate()
: on_resolve_proxy_called_(false),
add_proxy_(false),
- remove_proxy_(false) {
+ remove_proxy_(false),
+ proxy_service_(NULL) {
}
- virtual void OnResolveProxy(
- const GURL& url, int load_flags, ProxyInfo* result) OVERRIDE {
+ virtual void OnResolveProxy(const GURL& url,
+ int load_flags,
+ const ProxyService& proxy_service,
+ ProxyInfo* result) OVERRIDE {
on_resolve_proxy_called_ = true;
+ proxy_service_ = &proxy_service;
DCHECK(!add_proxy_ || !remove_proxy_);
if (add_proxy_) {
result->UseNamedProxy("delegate_proxy.com");
@@ -187,10 +191,15 @@ class TestResolveProxyNetworkDelegate : public NetworkDelegate {
remove_proxy_ = remove_proxy;
}
+ const ProxyService* proxy_service() const {
+ return proxy_service_;
+ }
+
private:
bool on_resolve_proxy_called_;
bool add_proxy_;
bool remove_proxy_;
+ const ProxyService* proxy_service_;
};
// A test network delegate that exercises the OnProxyFallback callback.
@@ -299,6 +308,7 @@ TEST_F(ProxyServiceTest, OnResolveProxyCallbackAddProxy) {
url, net::LOAD_NORMAL, &info, callback.callback(), NULL, &delegate,
log.bound());
EXPECT_TRUE(delegate.on_resolve_proxy_called());
+ EXPECT_EQ(&service, delegate.proxy_service());
// Verify that the NetworkDelegate's behavior is stateless across
// invocations of ResolveProxy. Start by having the callback add a proxy