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

Unified Diff: net/proxy/proxy_service.cc

Issue 3192011: Make sure the key into the spdy session pool identifies the actual proxy used... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rework some comments Created 10 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: net/proxy/proxy_service.cc
===================================================================
--- net/proxy/proxy_service.cc (revision 57108)
+++ net/proxy/proxy_service.cc (working copy)
@@ -83,6 +83,37 @@
}
};
+// 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 @@
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,

Powered by Google App Engine
This is Rietveld 408576698