summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-21 01:21:06 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-21 01:21:06 +0000
commite52acc82944001db1632919f5970fc32c849b732 (patch)
treeb9ab0fc484f1a5a9fda7cac7209d1b73ce77a27a
parentadf2e8a025e6ed93e6858d0cd996db5e36791a52 (diff)
downloadchromium_src-e52acc82944001db1632919f5970fc32c849b732.zip
chromium_src-e52acc82944001db1632919f5970fc32c849b732.tar.gz
chromium_src-e52acc82944001db1632919f5970fc32c849b732.tar.bz2
Support simple proxy configuration for all platforms other than Linux
For Linux, a ProxyConfigService must be provided. BUG=122779 TEST=none Review URL: http://codereview.chromium.org/10155004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133318 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--net/url_request/url_request_context_builder.cc25
-rw-r--r--net/url_request/url_request_context_builder.h10
-rw-r--r--net/url_request/url_request_context_builder_unittest.cc13
3 files changed, 39 insertions, 9 deletions
diff --git a/net/url_request/url_request_context_builder.cc b/net/url_request/url_request_context_builder.cc
index 7a38431..5f217d6 100644
--- a/net/url_request/url_request_context_builder.cc
+++ b/net/url_request/url_request_context_builder.cc
@@ -167,6 +167,13 @@ URLRequestContextBuilder::URLRequestContextBuilder()
http_cache_enabled_(true) {}
URLRequestContextBuilder::~URLRequestContextBuilder() {}
+#if defined(OS_LINUX)
+void URLRequestContextBuilder::set_proxy_config_service(
+ ProxyConfigService* proxy_config_service) {
+ proxy_config_service_.reset(proxy_config_service);
+}
+#endif // defined(OS_LINUX)
+
scoped_refptr<URLRequestContext> URLRequestContextBuilder::Build() {
BasicURLRequestContext* context = new BasicURLRequestContext;
URLRequestContextStorage* storage = context->storage();
@@ -188,19 +195,21 @@ scoped_refptr<URLRequestContext> URLRequestContextBuilder::Build() {
context->StartFileThread();
- storage->set_proxy_service(
- ProxyService::CreateDirectWithNetLog(context->net_log()));
-
// TODO(willchan): Switch to using this code when
// ProxyService::CreateSystemProxyConfigService()'s signature doesn't suck.
-#if 0
+#if defined(OS_LINUX)
+ ProxyConfigService* proxy_config_service = proxy_config_service_.release();
+#else
+ ProxyConfigService* proxy_config_service =
+ ProxyService::CreateSystemProxyConfigService(
+ MessageLoop::current(),
+ context->file_message_loop());
+#endif // defined(OS_LINUX)
+ storage->set_proxy_service(
ProxyService::CreateUsingSystemProxyResolver(
- ProxyService::CreateSystemProxyConfigService(
- MessageLoop::current(),
- context->file_message_loop()),
+ proxy_config_service,
4, // TODO(willchan): Find a better constant somewhere.
context->net_log()));
-#endif
storage->set_ssl_config_service(new net::SSLConfigServiceDefaults);
storage->set_http_auth_handler_factory(
net::HttpAuthHandlerRegistryFactory::CreateDefault(host_resolver));
diff --git a/net/url_request/url_request_context_builder.h b/net/url_request/url_request_context_builder.h
index ba7541d..dbb521e 100644
--- a/net/url_request/url_request_context_builder.h
+++ b/net/url_request/url_request_context_builder.h
@@ -20,10 +20,13 @@
#include "base/basictypes.h"
#include "base/file_path.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "build/build_config.h"
#include "net/base/net_export.h"
namespace net {
+class ProxyConfigService;
class URLRequestContext;
class NET_EXPORT URLRequestContextBuilder {
@@ -63,6 +66,10 @@ class NET_EXPORT URLRequestContextBuilder {
URLRequestContextBuilder();
~URLRequestContextBuilder();
+#if defined(OS_LINUX)
+ void set_proxy_config_service(ProxyConfigService* proxy_config_service);
+#endif // defined(OS_LINUX)
+
// Call this function to specify a hard-coded User-Agent for all requests that
// don't have a User-Agent already set.
void set_user_agent(const std::string& user_agent) {
@@ -92,6 +99,9 @@ class NET_EXPORT URLRequestContextBuilder {
HostResolverParams host_resolver_params_;
bool http_cache_enabled_;
HttpCacheParams http_cache_params_;
+#if defined(OS_LINUX)
+ scoped_ptr<ProxyConfigService> proxy_config_service_;
+#endif // defined(OS_LINUX)
DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder);
};
diff --git a/net/url_request/url_request_context_builder_unittest.cc b/net/url_request/url_request_context_builder_unittest.cc
index 039b15d..8fcb19c 100644
--- a/net/url_request/url_request_context_builder_unittest.cc
+++ b/net/url_request/url_request_context_builder_unittest.cc
@@ -4,12 +4,18 @@
#include "net/url_request/url_request_context_builder.h"
+#include "build/build_config.h"
#include "net/test/test_server.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
+#if defined(OS_LINUX)
+#include "net/proxy/proxy_config.h"
+#include "net/proxy/proxy_config_service_fixed.h"
+#endif // defined(OS_LINUX)
+
namespace net {
namespace {
@@ -33,7 +39,12 @@ class URLRequestContextBuilderTest : public PlatformTest {
protected:
URLRequestContextBuilderTest()
: test_server_(
- FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest"))) {}
+ FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest"))) {
+#if defined(OS_LINUX)
+ builder_.set_proxy_config_service(
+ new ProxyConfigServiceFixed(ProxyConfig::CreateDirect()));
+#endif // defined(OS_LINUX)
+ }
LocalHttpTestServer test_server_;
URLRequestContextBuilder builder_;