diff options
author | Iain Merrick <husky@google.com> | 2010-10-19 14:37:37 +0100 |
---|---|---|
committer | Iain Merrick <husky@google.com> | 2010-10-19 14:37:37 +0100 |
commit | 3345a6884c488ff3a535c2c9acdd33d74b37e311 (patch) | |
tree | 7784b988ef1698cb6967ea1bdf07616237716c6c /net/proxy/proxy_config_service_linux.h | |
parent | efc8475837ec58186051f23bb03542620424f6ce (diff) | |
download | external_chromium-3345a6884c488ff3a535c2c9acdd33d74b37e311.zip external_chromium-3345a6884c488ff3a535c2c9acdd33d74b37e311.tar.gz external_chromium-3345a6884c488ff3a535c2c9acdd33d74b37e311.tar.bz2 |
Merge Chromium at 7.0.540.0 : Initial merge by git
Not including third_party/icu as it contains huge data files that break Gerrit, and aren't actually used.
Change-Id: I428a386e70f3b58cacd28677b8cfda282e891e15
Diffstat (limited to 'net/proxy/proxy_config_service_linux.h')
-rw-r--r-- | net/proxy/proxy_config_service_linux.h | 53 |
1 files changed, 34 insertions, 19 deletions
diff --git a/net/proxy/proxy_config_service_linux.h b/net/proxy/proxy_config_service_linux.h index 44ea4de..cd70ea7 100644 --- a/net/proxy/proxy_config_service_linux.h +++ b/net/proxy/proxy_config_service_linux.h @@ -4,13 +4,15 @@ #ifndef NET_PROXY_PROXY_CONFIG_SERVICE_LINUX_H_ #define NET_PROXY_PROXY_CONFIG_SERVICE_LINUX_H_ +#pragma once #include <string> #include <vector> #include "base/basictypes.h" -#include "base/env_var.h" +#include "base/environment.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 +92,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. // @@ -113,10 +117,10 @@ class ProxyConfigServiceLinux : public ProxyConfigService { public: // Constructor receives env var getter implementation to use, and // takes ownership of it. This is the normal constructor. - explicit Delegate(base::EnvVarGetter* env_var_getter); + explicit Delegate(base::Environment* env_var_getter); // Constructor receives gconf and env var getter implementations // to use, and takes ownership of them. Used for testing. - Delegate(base::EnvVarGetter* env_var_getter, + Delegate(base::Environment* env_var_getter, GConfSettingGetter* gconf_getter); // Synchronously obtains the proxy configuration. If gconf is // used, also enables gconf notification for setting @@ -138,7 +142,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. @@ -149,7 +155,7 @@ class ProxyConfigServiceLinux : public ProxyConfigService { private: friend class base::RefCountedThreadSafe<Delegate>; - ~Delegate() {} + ~Delegate(); // Obtains an environment variable's value. Parses a proxy server // specification from it and puts it in result. Returns true if the @@ -176,11 +182,11 @@ class ProxyConfigServiceLinux : public ProxyConfigService { // carry the new config information. void SetNewProxyConfig(const ProxyConfig& new_config); - scoped_ptr<base::EnvVarGetter> env_var_getter_; + scoped_ptr<base::Environment> env_var_getter_; 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 +205,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); }; @@ -211,13 +219,11 @@ class ProxyConfigServiceLinux : public ProxyConfigService { // Usual constructor ProxyConfigServiceLinux(); // For testing: take alternate gconf and env var getter implementations. - explicit ProxyConfigServiceLinux(base::EnvVarGetter* env_var_getter); - ProxyConfigServiceLinux(base::EnvVarGetter* env_var_getter, + explicit ProxyConfigServiceLinux(base::Environment* env_var_getter); + ProxyConfigServiceLinux(base::Environment* env_var_getter, GConfSettingGetter* gconf_getter); - virtual ~ProxyConfigServiceLinux() { - delegate_->PostDestroyTask(); - } + virtual ~ProxyConfigServiceLinux(); void SetupAndFetchInitialConfig(MessageLoop* glib_default_loop, MessageLoop* io_loop, @@ -233,8 +239,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: |