| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_PROXY_PROXY_CONFIG_SERVICE_LINUX_H_ | 5 #ifndef NET_PROXY_PROXY_CONFIG_SERVICE_LINUX_H_ |
| 6 #define NET_PROXY_PROXY_CONFIG_SERVICE_LINUX_H_ | 6 #define NET_PROXY_PROXY_CONFIG_SERVICE_LINUX_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/environment.h" | 13 #include "base/environment.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
| 17 #include "net/base/net_export.h" | 17 #include "net/base/net_export.h" |
| 18 #include "net/proxy/proxy_config.h" | 18 #include "net/proxy/proxy_config.h" |
| 19 #include "net/proxy/proxy_config_service.h" | 19 #include "net/proxy/proxy_config_service.h" |
| 20 #include "net/proxy/proxy_server.h" | 20 #include "net/proxy/proxy_server.h" |
| 21 | 21 |
| 22 namespace base { |
| 22 class MessageLoopForIO; | 23 class MessageLoopForIO; |
| 23 | |
| 24 namespace base { | |
| 25 class SingleThreadTaskRunner; | 24 class SingleThreadTaskRunner; |
| 26 } // namespace base | 25 } // namespace base |
| 27 | 26 |
| 28 namespace net { | 27 namespace net { |
| 29 | 28 |
| 30 // Implementation of ProxyConfigService that retrieves the system proxy | 29 // Implementation of ProxyConfigService that retrieves the system proxy |
| 31 // settings from environment variables, gconf, gsettings, or kioslaverc (KDE). | 30 // settings from environment variables, gconf, gsettings, or kioslaverc (KDE). |
| 32 class NET_EXPORT_PRIVATE ProxyConfigServiceLinux : public ProxyConfigService { | 31 class NET_EXPORT_PRIVATE ProxyConfigServiceLinux : public ProxyConfigService { |
| 33 public: | 32 public: |
| 34 | 33 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 45 virtual ~SettingGetter() {} | 44 virtual ~SettingGetter() {} |
| 46 | 45 |
| 47 // Initializes the class: obtains a gconf/gsettings client, or simulates | 46 // Initializes the class: obtains a gconf/gsettings client, or simulates |
| 48 // one, in the concrete implementations. Returns true on success. Must be | 47 // one, in the concrete implementations. Returns true on success. Must be |
| 49 // called before using other methods, and should be called on the thread | 48 // called before using other methods, and should be called on the thread |
| 50 // running the glib main loop. | 49 // running the glib main loop. |
| 51 // One of |glib_thread_task_runner| and |file_loop| will be used for | 50 // One of |glib_thread_task_runner| and |file_loop| will be used for |
| 52 // gconf/gsettings calls or reading necessary files, depending on the | 51 // gconf/gsettings calls or reading necessary files, depending on the |
| 53 // implementation. | 52 // implementation. |
| 54 virtual bool Init(base::SingleThreadTaskRunner* glib_thread_task_runner, | 53 virtual bool Init(base::SingleThreadTaskRunner* glib_thread_task_runner, |
| 55 MessageLoopForIO* file_loop) = 0; | 54 base::MessageLoopForIO* file_loop) = 0; |
| 56 | 55 |
| 57 // Releases the gconf/gsettings client, which clears cached directories and | 56 // Releases the gconf/gsettings client, which clears cached directories and |
| 58 // stops notifications. | 57 // stops notifications. |
| 59 virtual void ShutDown() = 0; | 58 virtual void ShutDown() = 0; |
| 60 | 59 |
| 61 // Requests notification of gconf/gsettings changes for proxy | 60 // Requests notification of gconf/gsettings changes for proxy |
| 62 // settings. Returns true on success. | 61 // settings. Returns true on success. |
| 63 virtual bool SetUpNotifications(Delegate* delegate) = 0; | 62 virtual bool SetUpNotifications(Delegate* delegate) = 0; |
| 64 | 63 |
| 65 // Returns the message loop for the thread on which this object | 64 // Returns the message loop for the thread on which this object |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 // gsettings, or kioslaverc are used, also enables notifications for | 175 // gsettings, or kioslaverc are used, also enables notifications for |
| 177 // setting changes. gconf/gsettings must only be accessed from the | 176 // setting changes. gconf/gsettings must only be accessed from the |
| 178 // thread running the default glib main loop, and so this method | 177 // thread running the default glib main loop, and so this method |
| 179 // must be called from the UI thread. The message loop for the IO | 178 // must be called from the UI thread. The message loop for the IO |
| 180 // thread is specified so that notifications can post tasks to it | 179 // thread is specified so that notifications can post tasks to it |
| 181 // (and for assertions). The message loop for the file thread is | 180 // (and for assertions). The message loop for the file thread is |
| 182 // used to read any files needed to determine proxy settings. | 181 // used to read any files needed to determine proxy settings. |
| 183 void SetUpAndFetchInitialConfig( | 182 void SetUpAndFetchInitialConfig( |
| 184 base::SingleThreadTaskRunner* glib_thread_task_runner, | 183 base::SingleThreadTaskRunner* glib_thread_task_runner, |
| 185 base::SingleThreadTaskRunner* io_thread_task_runner, | 184 base::SingleThreadTaskRunner* io_thread_task_runner, |
| 186 MessageLoopForIO* file_loop); | 185 base::MessageLoopForIO* file_loop); |
| 187 | 186 |
| 188 // Handler for setting change notifications: fetches a new proxy | 187 // Handler for setting change notifications: fetches a new proxy |
| 189 // configuration from settings, and if this config is different | 188 // configuration from settings, and if this config is different |
| 190 // than what we had before, posts a task to have it stored in | 189 // than what we had before, posts a task to have it stored in |
| 191 // cached_config_. | 190 // cached_config_. |
| 192 // Left public for simplicity. | 191 // Left public for simplicity. |
| 193 void OnCheckProxyConfigSettings(); | 192 void OnCheckProxyConfigSettings(); |
| 194 | 193 |
| 195 // Called from IO thread. | 194 // Called from IO thread. |
| 196 void AddObserver(Observer* observer); | 195 void AddObserver(Observer* observer); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 // For testing: take alternate setting and env var getter implementations. | 275 // For testing: take alternate setting and env var getter implementations. |
| 277 explicit ProxyConfigServiceLinux(base::Environment* env_var_getter); | 276 explicit ProxyConfigServiceLinux(base::Environment* env_var_getter); |
| 278 ProxyConfigServiceLinux(base::Environment* env_var_getter, | 277 ProxyConfigServiceLinux(base::Environment* env_var_getter, |
| 279 SettingGetter* setting_getter); | 278 SettingGetter* setting_getter); |
| 280 | 279 |
| 281 virtual ~ProxyConfigServiceLinux(); | 280 virtual ~ProxyConfigServiceLinux(); |
| 282 | 281 |
| 283 void SetupAndFetchInitialConfig( | 282 void SetupAndFetchInitialConfig( |
| 284 base::SingleThreadTaskRunner* glib_thread_task_runner, | 283 base::SingleThreadTaskRunner* glib_thread_task_runner, |
| 285 base::SingleThreadTaskRunner* io_thread_task_runner, | 284 base::SingleThreadTaskRunner* io_thread_task_runner, |
| 286 MessageLoopForIO* file_loop) { | 285 base::MessageLoopForIO* file_loop) { |
| 287 delegate_->SetUpAndFetchInitialConfig(glib_thread_task_runner, | 286 delegate_->SetUpAndFetchInitialConfig(glib_thread_task_runner, |
| 288 io_thread_task_runner, file_loop); | 287 io_thread_task_runner, file_loop); |
| 289 } | 288 } |
| 290 void OnCheckProxyConfigSettings() { | 289 void OnCheckProxyConfigSettings() { |
| 291 delegate_->OnCheckProxyConfigSettings(); | 290 delegate_->OnCheckProxyConfigSettings(); |
| 292 } | 291 } |
| 293 | 292 |
| 294 // ProxyConfigService methods: | 293 // ProxyConfigService methods: |
| 295 // Called from IO thread. | 294 // Called from IO thread. |
| 296 virtual void AddObserver(Observer* observer) OVERRIDE; | 295 virtual void AddObserver(Observer* observer) OVERRIDE; |
| 297 virtual void RemoveObserver(Observer* observer) OVERRIDE; | 296 virtual void RemoveObserver(Observer* observer) OVERRIDE; |
| 298 virtual ProxyConfigService::ConfigAvailability GetLatestProxyConfig( | 297 virtual ProxyConfigService::ConfigAvailability GetLatestProxyConfig( |
| 299 ProxyConfig* config) OVERRIDE; | 298 ProxyConfig* config) OVERRIDE; |
| 300 | 299 |
| 301 private: | 300 private: |
| 302 scoped_refptr<Delegate> delegate_; | 301 scoped_refptr<Delegate> delegate_; |
| 303 | 302 |
| 304 DISALLOW_COPY_AND_ASSIGN(ProxyConfigServiceLinux); | 303 DISALLOW_COPY_AND_ASSIGN(ProxyConfigServiceLinux); |
| 305 }; | 304 }; |
| 306 | 305 |
| 307 } // namespace net | 306 } // namespace net |
| 308 | 307 |
| 309 #endif // NET_PROXY_PROXY_CONFIG_SERVICE_LINUX_H_ | 308 #endif // NET_PROXY_PROXY_CONFIG_SERVICE_LINUX_H_ |
| OLD | NEW |