summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-14 00:44:59 +0000
committereroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-14 00:44:59 +0000
commit1517425f81d0f49afcf4cc49f62ee2aa1995a4ca (patch)
tree5e3b44c0eecc5e95322b65e93c3b6a33874dcec5
parent2687ad7d62c737430aa780f9db9a0a166931a735 (diff)
downloadchromium_src-1517425f81d0f49afcf4cc49f62ee2aa1995a4ca.zip
chromium_src-1517425f81d0f49afcf4cc49f62ee2aa1995a4ca.tar.gz
chromium_src-1517425f81d0f49afcf4cc49f62ee2aa1995a4ca.tar.bz2
Add an option ProxyService::Create() to disable use of proxy auto-config.
BUG=40797 Review URL: http://codereview.chromium.org/3646004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62487 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/net/chrome_url_request_context.cc16
-rw-r--r--chrome/browser/net/connection_tester.cc3
-rw-r--r--chrome/service/net/service_url_request_context.cc5
-rw-r--r--chrome/test/plugin/plugin_test.cpp5
-rw-r--r--chrome_frame/metrics_service.cc8
-rw-r--r--net/proxy/proxy_service.cc85
-rw-r--r--net/proxy/proxy_service.h26
-rw-r--r--webkit/tools/test_shell/test_shell_request_context.cc4
8 files changed, 100 insertions, 52 deletions
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc
index e1aa4ae..0134717 100644
--- a/chrome/browser/net/chrome_url_request_context.cc
+++ b/chrome/browser/net/chrome_url_request_context.cc
@@ -122,13 +122,19 @@ net::ProxyService* CreateProxyService(
}
}
- return net::ProxyService::Create(
+ if (use_v8) {
+ return net::ProxyService::CreateUsingV8ProxyResolver(
+ proxy_config_service,
+ num_pac_threads,
+ context,
+ net_log,
+ io_loop);
+ }
+
+ return net::ProxyService::CreateUsingSystemProxyResolver(
proxy_config_service,
- use_v8,
num_pac_threads,
- context,
- net_log,
- io_loop);
+ net_log);
}
// ----------------------------------------------------------------------------
diff --git a/chrome/browser/net/connection_tester.cc b/chrome/browser/net/connection_tester.cc
index 91d6afe..8658240 100644
--- a/chrome/browser/net/connection_tester.cc
+++ b/chrome/browser/net/connection_tester.cc
@@ -159,7 +159,8 @@ class ExperimentURLRequestContext : public URLRequestContext {
return net::ERR_NOT_IMPLEMENTED;
}
- *proxy_service = net::ProxyService::Create(config_service.release(), true,
+ *proxy_service = net::ProxyService::CreateUsingV8ProxyResolver(
+ config_service.release(),
0u, this, NULL, MessageLoop::current());
return net::OK;
diff --git a/chrome/service/net/service_url_request_context.cc b/chrome/service/net/service_url_request_context.cc
index 2b55d0c..cdfe6ec 100644
--- a/chrome/service/net/service_url_request_context.cc
+++ b/chrome/service/net/service_url_request_context.cc
@@ -33,9 +33,8 @@ ServiceURLRequestContext::ServiceURLRequestContext() {
net::ProxyService::CreateSystemProxyConfigService(
g_service_process->io_thread()->message_loop(),
g_service_process->file_thread()->message_loop());
- proxy_service_ =
- net::ProxyService::Create(
- proxy_config_service, false, 0u, this, NULL, NULL);
+ proxy_service_ = net::ProxyService::CreateUsingSystemProxyResolver(
+ proxy_config_service, 0u, NULL);
dnsrr_resolver_ = new net::DnsRRResolver;
ftp_transaction_factory_ = new net::FtpNetworkLayer(host_resolver_);
ssl_config_service_ = new net::SSLConfigServiceDefaults;
diff --git a/chrome/test/plugin/plugin_test.cpp b/chrome/test/plugin/plugin_test.cpp
index 92c3832..0a9ca83 100644
--- a/chrome/test/plugin/plugin_test.cpp
+++ b/chrome/test/plugin/plugin_test.cpp
@@ -225,9 +225,8 @@ class PluginInstallerDownloadTest
const size_t kNetLogBound = 50u;
net_log_.reset(new net::CapturingNetLog(kNetLogBound));
- proxy_service_ = net::ProxyService::Create(proxy_config_service, false, 0,
- this, net_log_.get(),
- MessageLoop::current());
+ proxy_service_ = net::ProxyService::CreateUsingSystemProxyResolver(
+ proxy_config_service, 0, net_log_.get());
DCHECK(proxy_service_);
ssl_config_service_ = new net::SSLConfigServiceDefaults;
diff --git a/chrome_frame/metrics_service.cc b/chrome_frame/metrics_service.cc
index 9d135a7..20d55ce 100644
--- a/chrome_frame/metrics_service.cc
+++ b/chrome_frame/metrics_service.cc
@@ -131,7 +131,7 @@ extern base::LazyInstance<StatisticsRecorder> g_statistics_recorder_;
// requests initiated by ChromeFrame.
class ChromeFrameUploadRequestContext : public URLRequestContext {
public:
- ChromeFrameUploadRequestContext(MessageLoop* io_loop)
+ explicit ChromeFrameUploadRequestContext(MessageLoop* io_loop)
: io_loop_(io_loop) {
Initialize();
}
@@ -157,8 +157,8 @@ class ChromeFrameUploadRequestContext : public URLRequestContext {
const size_t kNetLogBound = 50u;
net_log_.reset(new net::CapturingNetLog(kNetLogBound));
- proxy_service_ = net::ProxyService::Create(proxy_config_service, false, 0,
- this, net_log_.get(), io_loop_);
+ proxy_service_ = net::ProxyService::CreateUsingSystemProxyResolver(
+ proxy_config_service, 0, net_log_.get());
DCHECK(proxy_service_);
ssl_config_service_ = new net::SSLConfigServiceDefaults;
@@ -200,7 +200,7 @@ class ChromeFrameUploadRequestContext : public URLRequestContext {
// metrics HTTP upload requests initiated by ChromeFrame.
class ChromeFrameUploadRequestContextGetter : public URLRequestContextGetter {
public:
- ChromeFrameUploadRequestContextGetter(MessageLoop* io_loop)
+ explicit ChromeFrameUploadRequestContextGetter(MessageLoop* io_loop)
: io_loop_(io_loop) {}
virtual URLRequestContext* GetURLRequestContext() {
diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc
index 80a849a..2884d27 100644
--- a/net/proxy/proxy_service.cc
+++ b/net/proxy/proxy_service.cc
@@ -193,21 +193,29 @@ class ProxyResolverFactoryForV8 : public ProxyResolverFactory {
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
}
};
@@ -381,26 +389,24 @@ ProxyService::ProxyService(ProxyConfigService* config_service,
}
// 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* ProxyService::Create(
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
diff --git a/net/proxy/proxy_service.h b/net/proxy/proxy_service.h
index da0013f..0b8f873 100644
--- a/net/proxy/proxy_service.h
+++ b/net/proxy/proxy_service.h
@@ -137,8 +137,6 @@ class ProxyService : public base::RefCountedThreadSafe<ProxyService>,
// Creates a proxy service that polls |proxy_config_service| to notice when
// the proxy settings change. We take ownership of |proxy_config_service|.
- // Iff |use_v8_resolver| is true, then the V8 implementation is
- // used.
//
// |num_pac_threads| specifies the maximum number of threads to use for
// executing PAC scripts. Threads are created lazily on demand.
@@ -155,24 +153,34 @@ class ProxyService : public base::RefCountedThreadSafe<ProxyService>,
// (b) increases the memory used by proxy resolving, as each thread will
// duplicate its own script context.
- // |url_request_context| is only used when use_v8_resolver is true:
- // it specifies the URL request context that will be used if a PAC
- // script needs to be fetched.
- // |io_loop| points to the IO thread's message loop. It is only used
- // when pc is NULL.
+ // |url_request_context| specifies the URL request context that will
+ // be used if a PAC script needs to be fetched.
+ // |io_loop| points to the IO thread's message loop.
// ##########################################################################
// # See the warnings in net/proxy/proxy_resolver_v8.h describing the
// # multi-threading model. In order for this to be safe to use, *ALL* the
// # other V8's running in the process must use v8::Locker.
// ##########################################################################
- static ProxyService* Create(
+ static 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);
+ // Same as CreateUsingV8ProxyResolver, except it uses system libraries
+ // for evaluating the PAC script if available, otherwise skips
+ // proxy autoconfig.
+ static ProxyService* CreateUsingSystemProxyResolver(
+ ProxyConfigService* proxy_config_service,
+ size_t num_pac_threads,
+ NetLog* net_log);
+
+ // Creates a ProxyService without support for proxy autoconfig.
+ static ProxyService* CreateWithoutProxyResolver(
+ ProxyConfigService* proxy_config_service,
+ NetLog* net_log);
+
// Convenience method that creates a proxy service using the
// specified fixed settings. |pc| must not be NULL.
static ProxyService* CreateFixed(const ProxyConfig& pc);
diff --git a/webkit/tools/test_shell/test_shell_request_context.cc b/webkit/tools/test_shell/test_shell_request_context.cc
index 0eace44..9057fc0 100644
--- a/webkit/tools/test_shell/test_shell_request_context.cc
+++ b/webkit/tools/test_shell/test_shell_request_context.cc
@@ -62,8 +62,8 @@ void TestShellRequestContext::Init(
host_resolver_ =
net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism,
NULL);
- proxy_service_ = net::ProxyService::Create(proxy_config_service.release(),
- false, 0, NULL, NULL, NULL);
+ proxy_service_ = net::ProxyService::CreateUsingSystemProxyResolver(
+ proxy_config_service.release(), 0, NULL);
ssl_config_service_ = net::SSLConfigService::CreateSystemSSLConfigService();
http_auth_handler_factory_ = net::HttpAuthHandlerFactory::CreateDefault(