Chromium Code Reviews| Index: net/proxy/init_proxy_resolver.h |
| diff --git a/net/proxy/init_proxy_resolver.h b/net/proxy/init_proxy_resolver.h |
| index 67cf1cb2811e7c8fd8e56ac9f7d4df31fc01b1ab..cc43d316be354c6e249865ed342f1133866e51e4 100644 |
| --- a/net/proxy/init_proxy_resolver.h |
| +++ b/net/proxy/init_proxy_resolver.h |
| @@ -11,15 +11,19 @@ |
| #include "base/string16.h" |
| #include "base/time.h" |
| #include "base/timer.h" |
| +#include "base/scoped_ptr.h" |
| #include "googleurl/src/gurl.h" |
| #include "net/base/completion_callback.h" |
| #include "net/base/net_log.h" |
| namespace net { |
| +class DhcpProxyScriptFetcher; |
| +class NetLogParameter; |
| class ProxyConfig; |
| class ProxyResolver; |
| class ProxyScriptFetcher; |
| +class URLRequestContext; |
| // InitProxyResolver is a helper class used by ProxyService to |
| // initialize a ProxyResolver with the PAC script data specified |
| @@ -43,10 +47,11 @@ class InitProxyResolver { |
| // the lifespan of InitProxyResolver. |
| InitProxyResolver(ProxyResolver* resolver, |
| ProxyScriptFetcher* proxy_script_fetcher, |
| + DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher, |
| NetLog* net_log); |
| // Aborts any in-progress request. |
| - ~InitProxyResolver(); |
| + virtual ~InitProxyResolver(); |
|
eroman
2011/05/17 04:39:39
virtual is no longer needed here.
Jói
2011/05/17 15:38:35
Done.
|
| // Applies the PAC settings of |config| to |resolver_|. |
| // If |wait_delay| is positive, the initialization will pause for this |
| @@ -63,14 +68,23 @@ class InitProxyResolver { |
| CompletionCallback* callback); |
| private: |
| - struct PacURL { |
| - PacURL(bool auto_detect, const GURL& url) |
| - : auto_detect(auto_detect), url(url) {} |
| - bool auto_detect; |
| - GURL url; |
| + // Represents the sources from which we can get PAC files; two types of |
| + // auto-detect or a custom URL. |
| + struct PacSource { |
| + enum Type { |
| + WPAD_DHCP, |
| + WPAD_DNS, |
| + CUSTOM |
| + }; |
| + |
| + PacSource(Type type, const GURL& url) |
| + : type(type), url(url) {} |
| + |
| + Type type; |
| + GURL url; // Empty unless |type == PAC_SOURCE_CUSTOM|. |
| }; |
| - typedef std::vector<PacURL> UrlList; |
| + typedef std::vector<PacSource> PacSourceList; |
| enum State { |
| STATE_NONE, |
| @@ -83,7 +97,7 @@ class InitProxyResolver { |
| }; |
| // Returns ordered list of PAC urls to try for |config|. |
| - UrlList BuildPacUrlsFallbackList(const ProxyConfig& config) const; |
| + PacSourceList BuildPacSourcesFallbackList(const ProxyConfig& config) const; |
| void OnIOCompletion(int result); |
| int DoLoop(int result); |
| @@ -99,17 +113,20 @@ class InitProxyResolver { |
| int DoSetPacScriptComplete(int result); |
| // Tries restarting using the next fallback PAC URL: |
| - // |pac_urls_[++current_pac_url_index]|. |
| + // |pac_sources_[++current_pac_source_index]|. |
| // Returns OK and rewinds the state machine when there |
| // is something to try, otherwise returns |error|. |
| - int TryToFallbackPacUrl(int error); |
| + int TryToFallbackPacSource(int error); |
| // Gets the initial state (we skip fetching when the |
| // ProxyResolver doesn't |expect_pac_bytes()|. |
| State GetStartState() const; |
| + NetLogStringParameter* CreateNetLogParameterForSource( |
| + const PacSource& pac_source, GURL* effective_pac_url); |
| + |
| // Returns the current PAC URL we are fetching/testing. |
| - const PacURL& current_pac_url() const; |
| + const PacSource& current_pac_source() const; |
| void OnWaitTimerFired(); |
| void DidCompleteInit(); |
| @@ -117,11 +134,12 @@ class InitProxyResolver { |
| ProxyResolver* resolver_; |
| ProxyScriptFetcher* proxy_script_fetcher_; |
| + DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher_; |
| CompletionCallbackImpl<InitProxyResolver> io_callback_; |
| CompletionCallback* user_callback_; |
| - size_t current_pac_url_index_; |
| + size_t current_pac_source_index_; |
| // Filled when the PAC script fetch completes. |
| string16 pac_script_; |
| @@ -130,7 +148,7 @@ class InitProxyResolver { |
| // (i.e. fallback to direct connections are prohibited). |
| bool pac_mandatory_; |
| - UrlList pac_urls_; |
| + PacSourceList pac_sources_; |
| State next_state_; |
| BoundNetLog net_log_; |