diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-23 06:02:40 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-23 06:02:40 +0000 |
commit | 119655003d8f225282179043e990df879062e529 (patch) | |
tree | 4ee907ddfb8e308a00b5bb9b624e072b028623b6 /net/proxy/proxy_service.h | |
parent | dacc2c255ae3f823e4a39d975e97c067a76dacf9 (diff) | |
download | chromium_src-119655003d8f225282179043e990df879062e529.zip chromium_src-119655003d8f225282179043e990df879062e529.tar.gz chromium_src-119655003d8f225282179043e990df879062e529.tar.bz2 |
Change the ProxyConfigService interface to be asynchronous, and support observers.
The Windows implementation is still using a polling mechanism under the hood, however that polling has been moved to the worker pool so it won't block the IO thread in case WinHttpGetIEProxyConfigForCurrentUser is slow (crbug.com/12189).
BUG=12189
Review URL: http://codereview.chromium.org/3056011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53442 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy/proxy_service.h')
-rw-r--r-- | net/proxy/proxy_service.h | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/net/proxy/proxy_service.h b/net/proxy/proxy_service.h index a702b38..d3699cd 100644 --- a/net/proxy/proxy_service.h +++ b/net/proxy/proxy_service.h @@ -14,6 +14,7 @@ #include "net/base/completion_callback.h" #include "net/base/network_change_notifier.h" #include "net/base/net_log.h" +#include "net/proxy/proxy_config_service.h" #include "net/proxy/proxy_server.h" #include "net/proxy/proxy_info.h" #include "testing/gtest/include/gtest/gtest_prod.h" @@ -25,7 +26,6 @@ class URLRequestContext; namespace net { class InitProxyResolver; -class ProxyConfigService; class ProxyResolver; class ProxyScriptFetcher; @@ -33,7 +33,8 @@ class ProxyScriptFetcher; // HTTP(S) URL. It uses the given ProxyResolver to handle the actual proxy // resolution. See ProxyResolverV8 for example. class ProxyService : public base::RefCountedThreadSafe<ProxyService>, - public NetworkChangeNotifier::Observer { + public NetworkChangeNotifier::Observer, + public ProxyConfigService::Observer { public: // The instance takes ownership of |config_service| and |resolver|. // |net_log| is a possibly NULL destination to send log events to. It must @@ -196,31 +197,23 @@ class ProxyService : public base::RefCountedThreadSafe<ProxyService>, // which expects requests to finish in the order they were added. typedef std::vector<scoped_refptr<PacRequest> > PendingRequests; - ~ProxyService(); - - // Identifies the proxy configuration. - ProxyConfig::ID config_id() const { return config_.id(); } - - // Checks to see if the proxy configuration changed, and then updates config_ - // to reference the new configuration. - void UpdateConfig(const BoundNetLog& net_log); - - // Assign |config| as the current configuration. - void SetConfig(const ProxyConfig& config); + enum State { + STATE_NONE, + STATE_WAITING_FOR_PROXY_CONFIG, + STATE_WAITING_FOR_INIT_PROXY_RESOLVER, + STATE_READY, + }; - // Starts downloading and testing the various PAC choices. - // Calls OnInitProxyResolverComplete() when completed. - void StartInitProxyResolver(); + ~ProxyService(); - // Tries to update the configuration if it hasn't been checked in a while. - void UpdateConfigIfOld(const BoundNetLog& net_log); + // Resets all the variables associated with the current proxy configuration, + // and rewinds the current state to |STATE_NONE|. Returns the previous value + // of |current_state_|. + State ResetProxyConfig(); - // Returns true if the proxy resolver is being initialized for PAC - // (downloading PAC script(s) + testing). - // Resolve requests will be frozen until the initialization has completed. - bool IsInitializingProxyResolver() const { - return init_proxy_resolver_.get() != NULL; - } + // Retrieves the current proxy configuration from the ProxyConfigService, and + // starts initializing for it. + void ApplyProxyConfigIfAvailable(); // Callback for when the proxy resolver has been initialized with a // PAC script. @@ -235,8 +228,9 @@ class ProxyService : public base::RefCountedThreadSafe<ProxyService>, // restarted when calling ResumeAllPendingRequests(). void SuspendAllPendingRequests(); - // Sends all the unstarted pending requests off to the resolver. - void ResumeAllPendingRequests(); + // Advances the current state to |STATE_READY|, and resumes any pending + // requests which had been stalled waiting for initialization to complete. + void SetReady(); // Returns true if |pending_requests_| contains |req|. bool ContainsPendingRequest(PacRequest* req); @@ -255,6 +249,9 @@ class ProxyService : public base::RefCountedThreadSafe<ProxyService>, // When this is called, we re-fetch PAC scripts and re-run WPAD. virtual void OnIPAddressChanged(); + // ProxyConfigService::Observer + virtual void OnProxyConfigChanged(const ProxyConfig& config); + scoped_ptr<ProxyConfigService> config_service_; scoped_ptr<ProxyResolver> resolver_; @@ -291,6 +288,8 @@ class ProxyService : public base::RefCountedThreadSafe<ProxyService>, // |proxy_resolver_| must outlive |init_proxy_resolver_|. scoped_ptr<InitProxyResolver> init_proxy_resolver_; + State current_state_; + // This is the log where any events generated by |init_proxy_resolver_| are // sent to. NetLog* net_log_; |