diff options
author | scottbyer@chromium.org <scottbyer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-28 17:13:11 +0000 |
---|---|---|
committer | scottbyer@chromium.org <scottbyer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-28 17:13:11 +0000 |
commit | e8c5920f109d136da624f6a31ff80d4967fba7bf (patch) | |
tree | f5482f559f98ed667b6084e24a5a71e663dae92b | |
parent | fc9b931da04e8c2738ad33e0de0b2d9ee09a99fd (diff) | |
download | chromium_src-e8c5920f109d136da624f6a31ff80d4967fba7bf.zip chromium_src-e8c5920f109d136da624f6a31ff80d4967fba7bf.tar.gz chromium_src-e8c5920f109d136da624f6a31ff80d4967fba7bf.tar.bz2 |
Fix Linux proxy.
Somewhere along the way, the proxy service creation code got more strict and
the fragile earlier fix broke. This is much more correct and consistent across
platforms. Create the proxy config service on the UI thread, create the proxy
service itself on the IO thread.
BUG=none
TEST=start up the linux proxy, it works again. Check windows, still works. Check Mac, still works.
Review URL: http://codereview.chromium.org/6905046
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83350 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/service/net/service_url_request_context.cc | 43 | ||||
-rw-r--r-- | chrome/service/net/service_url_request_context.h | 15 |
2 files changed, 24 insertions, 34 deletions
diff --git a/chrome/service/net/service_url_request_context.cc b/chrome/service/net/service_url_request_context.cc index 9e876d9..eddbbbf 100644 --- a/chrome/service/net/service_url_request_context.cc +++ b/chrome/service/net/service_url_request_context.cc @@ -24,6 +24,7 @@ #include "net/http/http_auth_handler_factory.h" #include "net/http/http_cache.h" #include "net/http/http_network_session.h" +#include "net/proxy/proxy_config_service.h" #include "net/proxy/proxy_service.h" namespace { @@ -106,13 +107,14 @@ std::string MakeUserAgentForServiceProcess() { ServiceURLRequestContext::ServiceURLRequestContext( const std::string& user_agent, - net::ProxyService* net_proxy_service) + net::ProxyConfigService* net_proxy_config_service) : user_agent_(user_agent), ALLOW_THIS_IN_INITIALIZER_LIST(storage_(this)) { storage_.set_host_resolver( net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism, NULL)); - storage_.set_proxy_service(net_proxy_service); + storage_.set_proxy_service(net::ProxyService::CreateUsingSystemProxyResolver( + net_proxy_config_service, 0u, NULL)); storage_.set_cert_verifier(new net::CertVerifier); storage_.set_dnsrr_resolver(new net::DnsRRResolver); storage_.set_ftp_transaction_factory( @@ -157,26 +159,21 @@ ServiceURLRequestContextGetter::ServiceURLRequestContextGetter() // Build the default user agent. user_agent_ = MakeUserAgentForServiceProcess(); -#if defined(OS_LINUX) - // Create the proxy service now, at initialization time, on the main thread, - // only for Linux, which requires that. - CreateProxyConfigService(); -#endif + // TODO(sanjeevr): Change CreateSystemProxyConfigService to accept a + // MessageLoopProxy* instead of MessageLoop*. + DCHECK(g_service_process); + proxy_config_service_.reset( + net::ProxyService::CreateSystemProxyConfigService( + g_service_process->io_thread()->message_loop(), + g_service_process->file_thread()->message_loop())); } net::URLRequestContext* ServiceURLRequestContextGetter::GetURLRequestContext() { -#if !defined(OS_LINUX) - if (!proxy_config_service_.get()) - CreateProxyConfigService(); -#endif - if (!url_request_context_) { - net::ProxyService* proxy_service = - net::ProxyService::CreateUsingSystemProxyResolver( - proxy_config_service_.release(), 0u, NULL); - url_request_context_ = new ServiceURLRequestContext(user_agent_, - proxy_service); - } + if (!url_request_context_) + url_request_context_ = + new ServiceURLRequestContext(user_agent_, + proxy_config_service_.release()); return url_request_context_; } @@ -186,13 +183,3 @@ ServiceURLRequestContextGetter::GetIOMessageLoopProxy() const { } ServiceURLRequestContextGetter::~ServiceURLRequestContextGetter() {} - -void ServiceURLRequestContextGetter::CreateProxyConfigService() { - // TODO(sanjeevr): Change CreateSystemProxyConfigService to accept a - // MessageLoopProxy* instead of MessageLoop*. - DCHECK(g_service_process); - proxy_config_service_.reset( - net::ProxyService::CreateSystemProxyConfigService( - g_service_process->io_thread()->message_loop(), - g_service_process->file_thread()->message_loop())); -} diff --git a/chrome/service/net/service_url_request_context.h b/chrome/service/net/service_url_request_context.h index 3cf286e..5cb896d 100644 --- a/chrome/service/net/service_url_request_context.h +++ b/chrome/service/net/service_url_request_context.h @@ -8,6 +8,7 @@ #include <string> +#include "base/memory/scoped_ptr.h" #include "net/base/cookie_monster.h" #include "net/base/cookie_policy.h" #include "net/base/host_resolver.h" @@ -17,7 +18,6 @@ #include "net/http/http_auth_handler_factory.h" #include "net/http/http_cache.h" #include "net/http/http_network_layer.h" -#include "net/proxy/proxy_service.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_context_storage.h" @@ -26,15 +26,20 @@ namespace base { class MessageLoopProxy; } +namespace net { +class ProxyConfigService; +} + // Subclass of net::URLRequestContext which can be used to store extra // information for requests. This subclass is meant to be used in the service // process where the profile is not available. // class ServiceURLRequestContext : public net::URLRequestContext { public: - // This context takes ownership of |net_proxy_service|. - explicit ServiceURLRequestContext(const std::string& user_agent, - net::ProxyService* net_proxy_service); + // This context takes ownership of |net_proxy_config_service|. + explicit ServiceURLRequestContext( + const std::string& user_agent, + net::ProxyConfigService* net_proxy_config_service); // Overridden from net::URLRequestContext: virtual const std::string& GetUserAgent(const GURL& url) const; @@ -64,8 +69,6 @@ class ServiceURLRequestContextGetter : public net::URLRequestContextGetter { ServiceURLRequestContextGetter(); virtual ~ServiceURLRequestContextGetter(); - void CreateProxyConfigService(); - std::string user_agent_; scoped_refptr<net::URLRequestContext> url_request_context_; scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; |