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

Unified Diff: net/proxy/proxy_service.cc

Issue 3646004: Add an option ProxyService::Create() to disable use of proxy auto-config.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix a typo Created 10 years, 2 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
« no previous file with comments | « net/proxy/proxy_service.h ('k') | webkit/tools/test_shell/test_shell_request_context.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/proxy_service.cc
===================================================================
--- net/proxy/proxy_service.cc (revision 62170)
+++ net/proxy/proxy_service.cc (working copy)
@@ -193,23 +193,31 @@
scoped_ptr<ForwardingNetLog> forwarding_net_log_;
};
-// Creates ProxyResolvers using a non-V8 implementation.
-class ProxyResolverFactoryForNonV8 : public ProxyResolverFactory {
+// Creates ProxyResolvers using a platform-specific implementation.
+class ProxyResolverFactoryForSystem : public ProxyResolverFactory {
public:
- ProxyResolverFactoryForNonV8()
+ ProxyResolverFactoryForSystem()
: ProxyResolverFactory(false /*expects_pac_bytes*/) {}
virtual ProxyResolver* CreateProxyResolver() {
+ DCHECK(IsSupported());
#if defined(OS_WIN)
return new ProxyResolverWinHttp();
#elif defined(OS_MACOSX)
return new ProxyResolverMac();
#else
- LOG(WARNING) << "PAC support disabled because there is no fallback "
- "non-V8 implementation";
- return new ProxyResolverNull();
+ NOTREACHED();
+ return NULL;
#endif
}
+
+ static bool IsSupported() {
+#if defined(OS_WIN) || defined(OS_MACOSX)
+ return true;
+#else
+ return false;
+#endif
+ }
};
// NetLog parameter to describe a proxy configuration change.
@@ -381,26 +389,24 @@
}
// static
-ProxyService* ProxyService::Create(
+ProxyService* ProxyService::CreateUsingV8ProxyResolver(
ProxyConfigService* proxy_config_service,
- bool use_v8_resolver,
size_t num_pac_threads,
URLRequestContext* url_request_context,
NetLog* net_log,
MessageLoop* io_loop) {
+ DCHECK(proxy_config_service);
+ DCHECK(url_request_context);
+ DCHECK(io_loop);
+
if (num_pac_threads == 0)
num_pac_threads = kDefaultNumPacThreads;
- ProxyResolverFactory* sync_resolver_factory;
- if (use_v8_resolver) {
- sync_resolver_factory =
- new ProxyResolverFactoryForV8(
- url_request_context->host_resolver(),
- io_loop,
- net_log);
- } else {
- sync_resolver_factory = new ProxyResolverFactoryForNonV8();
- }
+ ProxyResolverFactory* sync_resolver_factory =
+ new ProxyResolverFactoryForV8(
+ url_request_context->host_resolver(),
+ io_loop,
+ net_log);
ProxyResolver* proxy_resolver =
new MultiThreadedProxyResolver(sync_resolver_factory, num_pac_threads);
@@ -408,21 +414,50 @@
ProxyService* proxy_service =
new ProxyService(proxy_config_service, proxy_resolver, net_log);
- if (proxy_resolver->expects_pac_bytes()) {
- // Configure PAC script downloads to be issued using |url_request_context|.
- DCHECK(url_request_context);
- proxy_service->SetProxyScriptFetcher(
- ProxyScriptFetcher::Create(url_request_context));
- }
+ // Configure PAC script downloads to be issued using |url_request_context|.
+ proxy_service->SetProxyScriptFetcher(
+ ProxyScriptFetcher::Create(url_request_context));
return proxy_service;
}
// static
+ProxyService* ProxyService::CreateUsingSystemProxyResolver(
+ ProxyConfigService* proxy_config_service,
+ size_t num_pac_threads,
+ NetLog* net_log) {
+ DCHECK(proxy_config_service);
+
+ if (!ProxyResolverFactoryForSystem::IsSupported()) {
+ LOG(WARNING) << "PAC support disabled because there is no "
+ "system implementation";
+ return CreateWithoutProxyResolver(proxy_config_service, net_log);
+ }
+
+ if (num_pac_threads == 0)
+ num_pac_threads = kDefaultNumPacThreads;
+
+ ProxyResolver* proxy_resolver = new MultiThreadedProxyResolver(
+ new ProxyResolverFactoryForSystem(), num_pac_threads);
+
+ return new ProxyService(proxy_config_service, proxy_resolver, net_log);
+}
+
+// static
+ProxyService* ProxyService::CreateWithoutProxyResolver(
+ ProxyConfigService* proxy_config_service,
+ NetLog* net_log) {
+ return new ProxyService(proxy_config_service,
+ new ProxyResolverNull(),
+ net_log);
+}
+
+// static
ProxyService* ProxyService::CreateFixed(const ProxyConfig& pc) {
// TODO(eroman): This isn't quite right, won't work if |pc| specifies
// a PAC script.
- return Create(new ProxyConfigServiceFixed(pc), false, 0, NULL, NULL, NULL);
+ return CreateUsingSystemProxyResolver(new ProxyConfigServiceFixed(pc),
+ 0, NULL);
}
// static
« no previous file with comments | « net/proxy/proxy_service.h ('k') | webkit/tools/test_shell/test_shell_request_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698