diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-05 05:47:56 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-05 05:47:56 +0000 |
commit | 1f6fdd45b31443447f6cdc7b6454f751fec9296d (patch) | |
tree | 751ac9d50d605e12c66e0505c432125a0d6fea9c /net/proxy/proxy_service.h | |
parent | d66c757a9a434f48069b114fb49191e4790f9038 (diff) | |
download | chromium_src-1f6fdd45b31443447f6cdc7b6454f751fec9296d.zip chromium_src-1f6fdd45b31443447f6cdc7b6454f751fec9296d.tar.gz chromium_src-1f6fdd45b31443447f6cdc7b6454f751fec9296d.tar.bz2 |
Poll PAC scripts for content changes.
An exponential poll delay is used which doubles the delay after each attempt (for instance polls might occur at 4 seconds, then 8 seconds, then 16 seconds, up to a maximum of 2 minutes).
This same mechanism also applies to the resolution of "auto-detect" settings.
The intent of this change is to make it possible to
(1) Notice server-side changes made to the PAC scripts
(2) Recover from spurious network errors when initially downloading PAC scripts.
BUG=90581
TEST=Configure Chrome to use a PAC script which fails to load (i.e. a non-existent file:// url, or remap the host's DNS record). Start Chrome and verify using about:net-internals that it has failed to fetch the PAC script and has fallen back to DIRECT settings. Fix the PAC URL to work and wait for chrome to notice the change and reconfigure itself (will take a maximum of 2 minutes).
Review URL: http://codereview.chromium.org/9078003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116462 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy/proxy_service.h')
-rw-r--r-- | net/proxy/proxy_service.h | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/net/proxy/proxy_service.h b/net/proxy/proxy_service.h index 41eabb3..dd9b712 100644 --- a/net/proxy/proxy_service.h +++ b/net/proxy/proxy_service.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -32,6 +32,7 @@ class DhcpProxyScriptFetcher; class HostResolver; class NetworkDelegate; class ProxyResolver; +class ProxyResolverScriptData; class ProxyScriptDecider; class ProxyScriptFetcher; @@ -42,6 +43,13 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver, public ProxyConfigService::Observer, NON_EXPORTED_BASE(public base::NonThreadSafe) { public: + // Only used by unit-tests. + enum PollPolicy { + POLL_POLICY_REGULAR, // Normal PAC poll policy (retry periodically). + POLL_POLICY_NEVER, // Don't re-fetch PAC scripts for changes. + POLL_POLICY_IMMEDIATE, // Check every 1 ms. + }; + // The instance takes ownership of |config_service| and |resolver|. // |net_log| is a possibly NULL destination to send log events to. It must // remain alive for the lifetime of this ProxyService. @@ -236,11 +244,16 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver, stall_proxy_auto_config_delay_ = delay; } + // This method should only be used by unit tests. Returns the previously + // active policy. + static PollPolicy set_pac_script_poll_policy(PollPolicy policy); + private: FRIEND_TEST_ALL_PREFIXES(ProxyServiceTest, UpdateConfigAfterFailedAutodetect); FRIEND_TEST_ALL_PREFIXES(ProxyServiceTest, UpdateConfigFromPACToDirect); friend class PacRequest; class InitProxyResolver; + class ProxyScriptDeciderPoller; // TODO(eroman): change this to a std::set. Note that this requires updating // some tests in proxy_service_unittest.cc such as: @@ -300,6 +313,12 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver, // Start initialization using |fetched_config_|. void InitializeUsingLastFetchedConfig(); + // Start the initialization skipping past the "decision" phase. + void InitializeUsingDecidedConfig( + int decider_result, + ProxyResolverScriptData* script_data, + const ProxyConfig& effective_config); + // NetworkChangeNotifier::IPAddressObserver // When this is called, we re-fetch PAC scripts and re-run WPAD. virtual void OnIPAddressChanged() OVERRIDE; @@ -348,6 +367,9 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver, // |proxy_resolver_| must outlive |init_proxy_resolver_|. scoped_ptr<InitProxyResolver> init_proxy_resolver_; + // Helper to poll the PAC script for changes. + scoped_ptr<ProxyScriptDeciderPoller> script_poller_; + State current_state_; // Either OK or an ERR_* value indicating that a permanent error (e.g. |