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 <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 178 |
179 // Synchronously obtains the proxy configuration. If gconf, | 179 // Synchronously obtains the proxy configuration. If gconf, |
180 // gsettings, or kioslaverc are used, also enables notifications for | 180 // gsettings, or kioslaverc are used, also enables notifications for |
181 // setting changes. gconf/gsettings must only be accessed from the | 181 // setting changes. gconf/gsettings must only be accessed from the |
182 // thread running the default glib main loop, and so this method | 182 // thread running the default glib main loop, and so this method |
183 // must be called from the UI thread. The message loop for the IO | 183 // must be called from the UI thread. The message loop for the IO |
184 // thread is specified so that notifications can post tasks to it | 184 // thread is specified so that notifications can post tasks to it |
185 // (and for assertions). | 185 // (and for assertions). |
186 void SetUpAndFetchInitialConfig( | 186 void SetUpAndFetchInitialConfig( |
187 const scoped_refptr<base::SingleThreadTaskRunner>& glib_task_runner, | 187 const scoped_refptr<base::SingleThreadTaskRunner>& glib_task_runner, |
188 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); | 188 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner); |
189 | 189 |
190 // Handler for setting change notifications: fetches a new proxy | 190 // Handler for setting change notifications: fetches a new proxy |
191 // configuration from settings, and if this config is different | 191 // configuration from settings, and if this config is different |
192 // than what we had before, posts a task to have it stored in | 192 // than what we had before, posts a task to have it stored in |
193 // cached_config_. | 193 // cached_config_. |
194 // Left public for simplicity. | 194 // Left public for simplicity. |
195 void OnCheckProxyConfigSettings(); | 195 void OnCheckProxyConfigSettings(); |
196 | 196 |
197 // Called from IO thread. | 197 // Called from IO thread. |
198 void AddObserver(Observer* observer); | 198 void AddObserver(Observer* observer); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 // base/message_loop/message_pump_glib.h). It is the glib default loop in | 260 // base/message_loop/message_pump_glib.h). It is the glib default loop in |
261 // the sense that it runs the glib default context: as in the context where | 261 // the sense that it runs the glib default context: as in the context where |
262 // sources are added by g_timeout_add and g_idle_add, and returned by | 262 // sources are added by g_timeout_add and g_idle_add, and returned by |
263 // g_main_context_default. gconf uses glib timeouts and idles and possibly | 263 // g_main_context_default. gconf uses glib timeouts and idles and possibly |
264 // other callbacks that will all be dispatched on this thread. Since gconf | 264 // other callbacks that will all be dispatched on this thread. Since gconf |
265 // is not thread safe, any use of gconf must be done on the thread running | 265 // is not thread safe, any use of gconf must be done on the thread running |
266 // this loop. | 266 // this loop. |
267 scoped_refptr<base::SingleThreadTaskRunner> glib_task_runner_; | 267 scoped_refptr<base::SingleThreadTaskRunner> glib_task_runner_; |
268 // Task runner for the IO thread. GetLatestProxyConfig() is called from | 268 // Task runner for the IO thread. GetLatestProxyConfig() is called from |
269 // the thread running this loop. | 269 // the thread running this loop. |
270 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 270 scoped_refptr<base::SequencedTaskRunner> io_task_runner_; |
271 | 271 |
272 base::ObserverList<Observer> observers_; | 272 base::ObserverList<Observer> observers_; |
273 | 273 |
274 DISALLOW_COPY_AND_ASSIGN(Delegate); | 274 DISALLOW_COPY_AND_ASSIGN(Delegate); |
275 }; | 275 }; |
276 | 276 |
277 // Thin wrapper shell around Delegate. | 277 // Thin wrapper shell around Delegate. |
278 | 278 |
279 // Usual constructor | 279 // Usual constructor |
280 ProxyConfigServiceLinux(); | 280 ProxyConfigServiceLinux(); |
281 | 281 |
282 // For testing: take alternate setting and env var getter implementations. | 282 // For testing: take alternate setting and env var getter implementations. |
283 explicit ProxyConfigServiceLinux( | 283 explicit ProxyConfigServiceLinux( |
284 std::unique_ptr<base::Environment> env_var_getter); | 284 std::unique_ptr<base::Environment> env_var_getter); |
285 ProxyConfigServiceLinux(std::unique_ptr<base::Environment> env_var_getter, | 285 ProxyConfigServiceLinux(std::unique_ptr<base::Environment> env_var_getter, |
286 SettingGetter* setting_getter); | 286 SettingGetter* setting_getter); |
287 | 287 |
288 ~ProxyConfigServiceLinux() override; | 288 ~ProxyConfigServiceLinux() override; |
289 | 289 |
290 void SetupAndFetchInitialConfig( | 290 void SetupAndFetchInitialConfig( |
291 const scoped_refptr<base::SingleThreadTaskRunner>& glib_task_runner, | 291 const scoped_refptr<base::SingleThreadTaskRunner>& glib_task_runner, |
292 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) { | 292 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner) { |
293 delegate_->SetUpAndFetchInitialConfig(glib_task_runner, io_task_runner); | 293 delegate_->SetUpAndFetchInitialConfig(glib_task_runner, io_task_runner); |
294 } | 294 } |
295 void OnCheckProxyConfigSettings() { | 295 void OnCheckProxyConfigSettings() { |
296 delegate_->OnCheckProxyConfigSettings(); | 296 delegate_->OnCheckProxyConfigSettings(); |
297 } | 297 } |
298 | 298 |
299 // ProxyConfigService methods: | 299 // ProxyConfigService methods: |
300 // Called from IO thread. | 300 // Called from IO thread. |
301 void AddObserver(Observer* observer) override; | 301 void AddObserver(Observer* observer) override; |
302 void RemoveObserver(Observer* observer) override; | 302 void RemoveObserver(Observer* observer) override; |
303 ProxyConfigService::ConfigAvailability GetLatestProxyConfig( | 303 ProxyConfigService::ConfigAvailability GetLatestProxyConfig( |
304 ProxyConfig* config) override; | 304 ProxyConfig* config) override; |
305 | 305 |
306 private: | 306 private: |
307 scoped_refptr<Delegate> delegate_; | 307 scoped_refptr<Delegate> delegate_; |
308 | 308 |
309 DISALLOW_COPY_AND_ASSIGN(ProxyConfigServiceLinux); | 309 DISALLOW_COPY_AND_ASSIGN(ProxyConfigServiceLinux); |
310 }; | 310 }; |
311 | 311 |
312 } // namespace net | 312 } // namespace net |
313 | 313 |
314 #endif // NET_PROXY_PROXY_CONFIG_SERVICE_LINUX_H_ | 314 #endif // NET_PROXY_PROXY_CONFIG_SERVICE_LINUX_H_ |
OLD | NEW |