Chromium Code Reviews| Index: net/proxy/proxy_service.h |
| diff --git a/net/proxy/proxy_service.h b/net/proxy/proxy_service.h |
| index dd9b712c155d376d1fc3b03b3c88329929ad2ad1..41968719b1218a303321bd6cff0d4186e2ff6854 100644 |
| --- a/net/proxy/proxy_service.h |
| +++ b/net/proxy/proxy_service.h |
| @@ -43,11 +43,39 @@ 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. |
| + // This interface defines the set of policies for when to poll the PAC |
| + // script for changes. |
| + // |
| + // The polling policy decides what the next poll delay should be in |
| + // milliseconds. It also decides how to wait for this delay -- either |
| + // by starting a timer to do the poll at exactly |next_delay_ms| |
| + // (MODE_USE_TIMER) or by waiting for the first network request issued after |
| + // |next_delay_ms| (MODE_START_AFTER_ACTIVITY). |
| + // |
| + // The timer method is more precise and guarantees that polling happens when |
| + // it was requested. However it has the disadvantage of causing spurious CPU |
| + // and network activity. It is a reasonable choice to use for short poll |
| + // intervals which only happen a couple times. |
| + // |
| + // However for repeated timers this will prevent the browser from going |
| + // idle. MODE_START_AFTER_ACTIVITY solves this problem by only polling in |
| + // direct response to network activity. The drawback to |
| + // MODE_START_AFTER_ACTIVITY is since the poll is initiated only after the |
| + // request is received, the first couple requests initiated after a long |
| + // period of inactivity will likely see |
|
wtc
2012/01/13 01:08:45
Nit: this line is too short.
eroman
2012/01/13 20:05:27
Done.
|
| + // a stale version of the PAC script until the background polling gets a |
| + // chance to update things. |
| + class NET_EXPORT_PRIVATE PacPollPolicy { |
| + public: |
| + enum Mode { |
| + MODE_USE_TIMER, |
| + MODE_START_AFTER_ACTIVITY, |
| + }; |
| + |
| + virtual ~PacPollPolicy(); |
| + virtual Mode GetInitialDelay(int error, int64* next_delay_ms) const = 0; |
| + virtual Mode GetNextDelay(int64 current_delay_ms, |
| + int64* next_delay_ms) const = 0; |
|
wtc
2012/01/13 01:08:45
You didn't document these two methods.
eroman
2012/01/13 20:05:27
Done.
|
| }; |
| // The instance takes ownership of |config_service| and |resolver|. |
| @@ -246,7 +274,12 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver, |
| // This method should only be used by unit tests. Returns the previously |
| // active policy. |
| - static PollPolicy set_pac_script_poll_policy(PollPolicy policy); |
| + static const PacPollPolicy* set_pac_script_poll_policy( |
| + const PacPollPolicy* policy); |
| + |
| + // This method should only be used by unit tests. Creates an instance |
| + // of the default internal PacPollPolicy used by ProxyService. |
| + static scoped_ptr<PacPollPolicy> CreateDefaultPacPollPolicy(); |
| private: |
| FRIEND_TEST_ALL_PREFIXES(ProxyServiceTest, UpdateConfigAfterFailedAutodetect); |