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_config_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_config_service.h')
-rw-r--r-- | net/proxy/proxy_config_service.h | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/net/proxy/proxy_config_service.h b/net/proxy/proxy_config_service.h index 9f6bb50..1c65e3a 100644 --- a/net/proxy/proxy_config_service.h +++ b/net/proxy/proxy_config_service.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 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. @@ -9,16 +9,39 @@ namespace net { class ProxyConfig; -// Synchronously fetch the system's proxy configuration settings. Called on -// the IO Thread. +// Service for watching when the proxy settings have changed. class ProxyConfigService { public: + // Observer for being notified when the proxy settings have changed. + class Observer { + public: + virtual ~Observer() {} + virtual void OnProxyConfigChanged(const ProxyConfig& config) = 0; + }; + 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; + // Adds/Removes an observer that will be called whenever the proxy + // configuration has changed. + virtual void AddObserver(Observer* observer) = 0; + virtual void RemoveObserver(Observer* observer) = 0; + + // Gets the most recent value of the proxy configuration. Returns false if + // it is not available yet. In the case where we returned false, it is + // guaranteed that subscribed observers will be notified of a change at + // some point in the future once the configuration is available. + // Note that to avoid re-entrancy problems, implementations should not + // dispatch any change notifications from within this function. + virtual bool GetLatestProxyConfig(ProxyConfig* config) = 0; + + // ProxyService will call this periodically during periods of activity. + // It can be used as a signal for polling-based implementations. + // + // Note that this is purely used as an optimization -- polling + // implementations could simply set a global timer that goes off every + // X seconds at which point they check for changes. However that has + // the disadvantage of doing continuous work even during idle periods. + virtual void OnLazyPoll() {} }; } // namespace net |