summaryrefslogtreecommitdiffstats
path: root/net/proxy/proxy_service.cc
diff options
context:
space:
mode:
authorrobertshield@google.com <robertshield@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-12 15:07:50 +0000
committerrobertshield@google.com <robertshield@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-12 15:07:50 +0000
commitab501a6a67596eb43d233f91f7500779dcbe8740 (patch)
tree90bfc9f94bf80c4ed7081d8d54454f02075c3c26 /net/proxy/proxy_service.cc
parent481fe3bfb2359849d1d3fc9d0ceba4161fbb5a3e (diff)
downloadchromium_src-ab501a6a67596eb43d233f91f7500779dcbe8740.zip
chromium_src-ab501a6a67596eb43d233f91f7500779dcbe8740.tar.gz
chromium_src-ab501a6a67596eb43d233f91f7500779dcbe8740.tar.bz2
Making command-line specified proxy settings more flexible - allowing for setting of auto-detect, pac url, per-schema proxy settings, proxy bypass urls.
BUG=http://crbug.com/266 Review URL: http://codereview.chromium.org/115029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15855 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy/proxy_service.cc')
-rw-r--r--net/proxy/proxy_service.cc60
1 files changed, 36 insertions, 24 deletions
diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc
index 0919f45..c2ae532 100644
--- a/net/proxy/proxy_service.cc
+++ b/net/proxy/proxy_service.cc
@@ -71,8 +71,8 @@ class NotifyFetchCompletionTask : public Task {
// We rely on the fact that the origin thread (and its message loop) will not
// be destroyed until after the PAC thread is destroyed.
-class ProxyService::PacRequest :
- public base::RefCountedThreadSafe<ProxyService::PacRequest> {
+class ProxyService::PacRequest
+ : public base::RefCountedThreadSafe<ProxyService::PacRequest> {
public:
// |service| -- the ProxyService that owns this request.
// |url| -- the url of the query.
@@ -193,46 +193,58 @@ ProxyService::ProxyService(ProxyConfigService* config_service,
}
// static
-ProxyService* ProxyService::Create(const ProxyInfo* pi) {
- if (pi) {
- // The ProxyResolver is set to NULL, since it should never be called
- // (because the configuration will never require PAC).
- return new ProxyService(new ProxyConfigServiceFixed(*pi), NULL);
+ProxyService* ProxyService::Create(const ProxyConfig* pc) {
+ scoped_ptr<ProxyConfigService> proxy_config_service;
+ scoped_ptr<ProxyResolver> proxy_resolver;
+ if (pc) {
+ proxy_config_service.reset(new ProxyConfigServiceFixed(*pc));
}
+
#if defined(OS_WIN)
- return new ProxyService(new ProxyConfigServiceWin(),
- new ProxyResolverWinHttp());
+ if (proxy_config_service == NULL)
+ proxy_config_service.reset(new ProxyConfigServiceWin());
+ proxy_resolver.reset(new ProxyResolverWinHttp());
#elif defined(OS_MACOSX)
- return new ProxyService(new ProxyConfigServiceMac(),
- new ProxyResolverMac());
+ if (proxy_config_service == NULL)
+ proxy_config_service.reset(new ProxyConfigServiceMac());
+ proxy_resolver.reset(new ProxyResolverMac());
#elif defined(OS_LINUX)
// On Linux we use the V8Resolver, no fallback implementation.
- return CreateNull();
+ // This means that if we got called with a ProxyConfig that could require a
+ // resolver, or if the caller is trying to create a regular ProxyService via
+ // this method instead of CreateUsingV8Resolver() we have to return a
+ // nulled-out ProxyService.
+ if (!pc || pc->MayRequirePACResolver()) {
+ LOG(WARNING) << "Attempting to create a ProxyService with a non-v8 "
+ << "resolver using an invalid ProxyConfig.";
+ return CreateNull();
+ }
#else
return CreateNull();
#endif
+
+ return new ProxyService(proxy_config_service.release(),
+ proxy_resolver.release());
}
// static
ProxyService* ProxyService::CreateUsingV8Resolver(
- const ProxyInfo* pi, URLRequestContext* url_request_context) {
- if (pi) {
- // The ProxyResolver is set to NULL, since it should never be called
- // (because the configuration will never require PAC).
- return new ProxyService(new ProxyConfigServiceFixed(*pi), NULL);
- }
-
+ const ProxyConfig* pc, URLRequestContext* url_request_context) {
// Choose the system configuration service appropriate for each platform.
- ProxyConfigService* config_service;
+ ProxyConfigService* config_service = NULL;
+ if (pc) {
+ config_service = new ProxyConfigServiceFixed(*pc);
+ } else {
#if defined(OS_WIN)
- config_service = new ProxyConfigServiceWin();
+ config_service = new ProxyConfigServiceWin();
#elif defined(OS_MACOSX)
- config_service = new ProxyConfigServiceMac();
+ config_service = new ProxyConfigServiceMac();
#elif defined(OS_LINUX)
- config_service = new ProxyConfigServiceLinux();
+ config_service = new ProxyConfigServiceLinux();
#else
- return CreateNull();
+ return CreateNull();
#endif
+ }
// Create a ProxyService that uses V8 to evaluate PAC scripts.
ProxyService* proxy_service = new ProxyService(