diff options
author | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-19 22:17:53 +0000 |
---|---|---|
committer | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-19 22:17:53 +0000 |
commit | 51fff29dc2dae1a8be5ea107d2b13205510c4e46 (patch) | |
tree | 56a82f110e5605f9aed8f75b2cf954cc5765ed1a /net/proxy/proxy_service.h | |
parent | 4750a86ea19e14d99a6b5fc94cd18d08ced463da (diff) | |
download | chromium_src-51fff29dc2dae1a8be5ea107d2b13205510c4e46.zip chromium_src-51fff29dc2dae1a8be5ea107d2b13205510c4e46.tar.gz chromium_src-51fff29dc2dae1a8be5ea107d2b13205510c4e46.tar.bz2 |
Split ProxyResolver into two interfaces: A. interface for retrieving the system proxy settings (ProxyConfigService) B. interface for resolving the proxy (ProxyResolver)The motivation behind this change is: 1. Simplify sharing the WinHTTP code that fetches IE settings, with the V8 proxy resolver (avoids having platform-specific code in ProxyResolverV8). 2. Restrict objects to one thread. (ProxyService calls the config getter on IO thread, and the proxy resolving on the PAC thread).(ProxyResolver is now only 1 method, but this will grow shortly).
Review URL: http://codereview.chromium.org/15070
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7323 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy/proxy_service.h')
-rw-r--r-- | net/proxy/proxy_service.h | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/net/proxy/proxy_service.h b/net/proxy/proxy_service.h index bea4aef..6a9c04b 100644 --- a/net/proxy/proxy_service.h +++ b/net/proxy/proxy_service.h @@ -24,6 +24,7 @@ class GURL; namespace net { +class ProxyConfigService; class ProxyInfo; class ProxyResolver; @@ -85,8 +86,9 @@ typedef std::map<std::string, ProxyRetryInfo> ProxyRetryInfoMap; // resolution. See ProxyResolverWinHttp for example. class ProxyService { public: - // The instance takes ownership of |resolver|. - explicit ProxyService(ProxyResolver* resolver); + // The instance takes ownership of |config_service| and |resolver|. + ProxyService(ProxyConfigService* config_service, + ProxyResolver* resolver); // Used internally to handle PAC queries. class PacRequest; @@ -138,6 +140,10 @@ class ProxyService { // use IE's settings). static ProxyService* Create(const ProxyInfo* pi); + // Create a proxy service that always fails to fetch the proxy configuration, + // so it falls back to direct connect. + static ProxyService* CreateNull(); + // TODO(eroman): remove once WinHTTP is gone. // Get the ProxyInfo used to create this proxy service (only used by WinHTTP). const ProxyInfo* proxy_info() const { @@ -169,6 +175,7 @@ class ProxyService { // 2. The URL matches one of the entities in the proxy bypass list. bool ShouldBypassProxyForURL(const GURL& url); + scoped_ptr<ProxyConfigService> config_service_; scoped_ptr<ProxyResolver> resolver_; scoped_ptr<base::Thread> pac_thread_; @@ -288,20 +295,27 @@ class ProxyInfo { bool config_was_tried_; }; -// This interface provides the low-level functions to access the proxy -// configuration and resolve proxies for given URLs synchronously. -class ProxyResolver { +// Synchronously fetch the system's proxy configuration settings. Called on +// the IO Thread. +class ProxyConfigService { public: - virtual ~ProxyResolver() {} + virtual ~ProxyConfigService() {} // Get the proxy configuration. Returns OK if successful or an error code if // otherwise. |config| should be in its initial state when this method is // called. virtual int GetProxyConfig(ProxyConfig* config) = 0; +}; + +// Synchronously resolve the proxy for a URL, using a PAC script. Called on the +// PAC Thread. +class ProxyResolver { + public: + virtual ~ProxyResolver() {} // Query the proxy auto-config file (specified by |pac_url|) for the proxy to // use to load the given |query_url|. Returns OK if successful or an error - // code if otherwise. + // code otherwise. virtual int GetProxyForURL(const GURL& query_url, const GURL& pac_url, ProxyInfo* results) = 0; |