summaryrefslogtreecommitdiffstats
path: root/net/proxy/polling_proxy_config_service.h
diff options
context:
space:
mode:
authoreroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-23 06:02:40 +0000
committereroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-23 06:02:40 +0000
commit119655003d8f225282179043e990df879062e529 (patch)
tree4ee907ddfb8e308a00b5bb9b624e072b028623b6 /net/proxy/polling_proxy_config_service.h
parentdacc2c255ae3f823e4a39d975e97c067a76dacf9 (diff)
downloadchromium_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/polling_proxy_config_service.h')
-rw-r--r--net/proxy/polling_proxy_config_service.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/net/proxy/polling_proxy_config_service.h b/net/proxy/polling_proxy_config_service.h
new file mode 100644
index 0000000..1bf889b
--- /dev/null
+++ b/net/proxy/polling_proxy_config_service.h
@@ -0,0 +1,49 @@
+// 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.
+
+#ifndef NET_PROXY_POLLING_PROXY_CONFIG_SERVICE_H_
+#define NET_PROXY_POLLING_PROXY_CONFIG_SERVICE_H_
+
+#include "base/time.h"
+#include "base/ref_counted.h"
+#include "net/proxy/proxy_config_service.h"
+
+namespace net {
+
+// PollingProxyConfigService is a base class for creating ProxyConfigService
+// implementations that use polling to notice when settings have change.
+//
+// It runs code to get the current proxy settings on a background worker
+// thread, and notifies registered observers when the value changes.
+class PollingProxyConfigService : public ProxyConfigService {
+ public:
+ // ProxyConfigService implementation:
+ virtual void AddObserver(Observer* observer);
+ virtual void RemoveObserver(Observer* observer);
+ virtual bool GetLatestProxyConfig(ProxyConfig* config);
+ virtual void OnLazyPoll();
+
+ protected:
+ // Function for retrieving the current proxy configuration.
+ // Implementors must be threadsafe as the function will be invoked from
+ // worker threads.
+ typedef void (*GetConfigFunction)(ProxyConfig*);
+
+ // Creates a polling-based ProxyConfigService which will test for new
+ // settings at most every |poll_interval| time by calling |get_config_func|
+ // on a worker thread.
+ PollingProxyConfigService(
+ base::TimeDelta poll_interval,
+ GetConfigFunction get_config_func);
+
+ virtual ~PollingProxyConfigService();
+
+ private:
+ class Core;
+ scoped_refptr<Core> core_;
+};
+
+} // namespace net
+
+#endif // NET_PROXY_POLLING_PROXY_CONFIG_SERVICE_H_