diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-25 01:38:43 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-25 01:38:43 +0000 |
commit | 733b7a6d83ad1c1394408f1c089cee2068135d44 (patch) | |
tree | b1ef08e4d72977d440a63045dfff94047b063ee4 /net/proxy | |
parent | 7a7a13b4d8ff1e790da262addcdeb84232539ebe (diff) | |
download | chromium_src-733b7a6d83ad1c1394408f1c089cee2068135d44.zip chromium_src-733b7a6d83ad1c1394408f1c089cee2068135d44.tar.gz chromium_src-733b7a6d83ad1c1394408f1c089cee2068135d44.tar.bz2 |
Make sure the key into the spdy session pool identifies the actual proxy used, and not the full list of possible proxies for the URL.
BUG=52668
TEST=SpdyNetworkTransactionTest.DirectConnectProxyReconnect
Review URL: http://codereview.chromium.org/3192011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57274 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy')
-rw-r--r-- | net/proxy/proxy_info.h | 2 | ||||
-rw-r--r-- | net/proxy/proxy_service.cc | 48 | ||||
-rw-r--r-- | net/proxy/proxy_service.h | 8 |
3 files changed, 57 insertions, 1 deletions
diff --git a/net/proxy/proxy_info.h b/net/proxy/proxy_info.h index 69c87c8..d6a891f 100644 --- a/net/proxy/proxy_info.h +++ b/net/proxy/proxy_info.h @@ -77,7 +77,7 @@ class ProxyInfo { // Returns the first valid proxy server. is_empty() must be false to be able // to call this function. - ProxyServer proxy_server() const { return proxy_list_.Get(); } + const ProxyServer& proxy_server() const { return proxy_list_.Get(); } // See description in ProxyList::ToPacString(). std::string ToPacString() const; diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc index 48e1fca..54fe171 100644 --- a/net/proxy/proxy_service.cc +++ b/net/proxy/proxy_service.cc @@ -83,6 +83,37 @@ class ProxyResolverNull : public ProxyResolver { } }; +// ProxyResolver that simulates a PAC script which returns +// |pac_string| for every single URL. +class ProxyResolverFromPacString : public ProxyResolver { + public: + ProxyResolverFromPacString(const std::string& pac_string) + : ProxyResolver(false /*expects_pac_bytes*/), + pac_string_(pac_string) {} + + virtual int GetProxyForURL(const GURL& url, + ProxyInfo* results, + CompletionCallback* callback, + RequestHandle* request, + const BoundNetLog& net_log) { + results->UsePacString(pac_string_); + return OK; + } + + virtual void CancelRequest(RequestHandle request) { + NOTREACHED(); + } + + virtual int SetPacScript( + const scoped_refptr<ProxyResolverScriptData>& pac_script, + CompletionCallback* callback) { + return OK; + } + + private: + const std::string pac_string_; +}; + // This factory creates V8ProxyResolvers with appropriate javascript bindings. class ProxyResolverFactoryForV8 : public ProxyResolverFactory { public: @@ -360,6 +391,23 @@ ProxyService* ProxyService::CreateNull() { NULL); } +// static +ProxyService* ProxyService::CreateFixedFromPacResult( + const std::string& pac_string) { + + // We need the settings to contain an "automatic" setting, otherwise the + // ProxyResolver dependency we give it will never be used. + scoped_ptr<ProxyConfigService> proxy_config_service( + new ProxyConfigServiceFixed(ProxyConfig::CreateAutoDetect())); + + scoped_ptr<ProxyResolver> proxy_resolver( + new ProxyResolverFromPacString(pac_string)); + + return new ProxyService(proxy_config_service.release(), + proxy_resolver.release(), + NULL); +} + int ProxyService::ResolveProxy(const GURL& raw_url, ProxyInfo* result, CompletionCallback* callback, diff --git a/net/proxy/proxy_service.h b/net/proxy/proxy_service.h index 3a3f7da..8f30327 100644 --- a/net/proxy/proxy_service.h +++ b/net/proxy/proxy_service.h @@ -178,8 +178,16 @@ class ProxyService : public base::RefCountedThreadSafe<ProxyService>, // Creates a proxy service that always fails to fetch the proxy configuration, // so it falls back to direct connect. + // TODO(eroman): Rename to CreateDirect(). static ProxyService* CreateNull(); + // This method is used by tests to create a ProxyService that returns a + // hardcoded proxy fallback list (|pac_string|) for every URL. + // + // |pac_string| is a list of proxy servers, in the format that a PAC script + // would return it. For example, "PROXY foobar:99; SOCKS fml:2; DIRECT" + static ProxyService* CreateFixedFromPacResult(const std::string& pac_string); + // Creates a config service appropriate for this platform that fetches the // system proxy settings. static ProxyConfigService* CreateSystemProxyConfigService( |