summaryrefslogtreecommitdiffstats
path: root/net/proxy/proxy_config_service_linux.h
diff options
context:
space:
mode:
Diffstat (limited to 'net/proxy/proxy_config_service_linux.h')
-rw-r--r--net/proxy/proxy_config_service_linux.h34
1 files changed, 25 insertions, 9 deletions
diff --git a/net/proxy/proxy_config_service_linux.h b/net/proxy/proxy_config_service_linux.h
index c6e9c90..600c5cc 100644
--- a/net/proxy/proxy_config_service_linux.h
+++ b/net/proxy/proxy_config_service_linux.h
@@ -11,6 +11,7 @@
#include "base/basictypes.h"
#include "base/env_var.h"
#include "base/message_loop.h"
+#include "base/observer_list.h"
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
#include "net/proxy/proxy_config.h"
@@ -90,16 +91,18 @@ class ProxyConfigServiceLinux : public ProxyConfigService {
// ProxyConfigServiceLinux is created on the UI thread, and
// SetupAndFetchInitialConfig() is immediately called to
- // synchronously fetch the original configuration and setup gconf
+ // synchronously fetch the original configuration and set up gconf
// notifications on the UI thread.
//
- // Passed that point, it is accessed periodically through
- // GetProxyConfig() from the IO thread.
+ // Past that point, it is accessed periodically through the
+ // ProxyConfigService interface (GetLatestProxyConfig, AddObserver,
+ // RemoveObserver) from the IO thread.
//
// gconf change notification callbacks can occur at any time and are
// run on the UI thread. The new gconf settings are fetched on the
// UI thread, and the new resulting proxy config is posted to the IO
- // thread through Delegate::SetNewProxyConfig().
+ // thread through Delegate::SetNewProxyConfig(). We then notify
+ // observers on the IO thread of the configuration change.
//
// ProxyConfigServiceLinux is deleted from the IO thread.
//
@@ -138,7 +141,9 @@ class ProxyConfigServiceLinux : public ProxyConfigService {
void OnCheckProxyConfigSettings();
// Called from IO thread.
- int GetProxyConfig(ProxyConfig* config);
+ void AddObserver(Observer* observer);
+ void RemoveObserver(Observer* observer);
+ bool GetLatestProxyConfig(ProxyConfig* config);
// Posts a call to OnDestroy() to the UI thread. Called from
// ProxyConfigServiceLinux's destructor.
@@ -180,7 +185,7 @@ class ProxyConfigServiceLinux : public ProxyConfigService {
scoped_ptr<GConfSettingGetter> gconf_getter_;
// Cached proxy configuration, to be returned by
- // GetProxyConfig. Initially populated from the UI thread, but
+ // GetLatestProxyConfig. Initially populated from the UI thread, but
// afterwards only accessed from the IO thread.
ProxyConfig cached_config_;
@@ -199,10 +204,12 @@ class ProxyConfigServiceLinux : public ProxyConfigService {
// this thread. Since gconf is not thread safe, any use of gconf
// must be done on the thread running this loop.
MessageLoop* glib_default_loop_;
- // MessageLoop for the IO thread. GetProxyConfig() is called from
+ // MessageLoop for the IO thread. GetLatestProxyConfig() is called from
// the thread running this loop.
MessageLoop* io_loop_;
+ ObserverList<Observer> observers_;
+
DISALLOW_COPY_AND_ASSIGN(Delegate);
};
@@ -231,8 +238,17 @@ class ProxyConfigServiceLinux : public ProxyConfigService {
// ProxyConfigService methods:
// Called from IO thread.
- virtual int GetProxyConfig(ProxyConfig* config) {
- return delegate_->GetProxyConfig(config);
+
+ virtual void AddObserver(Observer* observer) {
+ delegate_->AddObserver(observer);
+ }
+
+ virtual void RemoveObserver(Observer* observer) {
+ delegate_->RemoveObserver(observer);
+ }
+
+ virtual bool GetLatestProxyConfig(ProxyConfig* config) {
+ return delegate_->GetLatestProxyConfig(config);
}
private: