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 #include "net/proxy/proxy_config_service_linux.h" | 5 #include "net/proxy/proxy_config_service_linux.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #if defined(USE_GCONF) | 9 #if defined(USE_GCONF) |
10 #include <gconf/gconf-client.h> | 10 #include <gconf/gconf-client.h> |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 | 201 |
202 #if defined(USE_GCONF) | 202 #if defined(USE_GCONF) |
203 // This setting getter uses gconf, as used in GNOME 2 and some GNOME 3 desktops. | 203 // This setting getter uses gconf, as used in GNOME 2 and some GNOME 3 desktops. |
204 class SettingGetterImplGConf : public ProxyConfigServiceLinux::SettingGetter { | 204 class SettingGetterImplGConf : public ProxyConfigServiceLinux::SettingGetter { |
205 public: | 205 public: |
206 SettingGetterImplGConf() | 206 SettingGetterImplGConf() |
207 : client_(NULL), | 207 : client_(NULL), |
208 system_proxy_id_(0), | 208 system_proxy_id_(0), |
209 system_http_proxy_id_(0), | 209 system_http_proxy_id_(0), |
210 notify_delegate_(NULL), | 210 notify_delegate_(NULL), |
211 debounce_timer_(new base::OneShotTimer<SettingGetterImplGConf>()) { | 211 debounce_timer_(new base::OneShotTimer()) {} |
212 } | |
213 | 212 |
214 ~SettingGetterImplGConf() override { | 213 ~SettingGetterImplGConf() override { |
215 // client_ should have been released before now, from | 214 // client_ should have been released before now, from |
216 // Delegate::OnDestroy(), while running on the UI thread. However | 215 // Delegate::OnDestroy(), while running on the UI thread. However |
217 // on exiting the process, it may happen that Delegate::OnDestroy() | 216 // on exiting the process, it may happen that Delegate::OnDestroy() |
218 // task is left pending on the glib loop after the loop was quit, | 217 // task is left pending on the glib loop after the loop was quit, |
219 // and pending tasks may then be deleted without being run. | 218 // and pending tasks may then be deleted without being run. |
220 if (client_) { | 219 if (client_) { |
221 // gconf client was not cleaned up. | 220 // gconf client was not cleaned up. |
222 if (task_runner_->BelongsToCurrentThread()) { | 221 if (task_runner_->BelongsToCurrentThread()) { |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 setting_getter->OnChangeNotification(); | 497 setting_getter->OnChangeNotification(); |
499 } | 498 } |
500 | 499 |
501 GConfClient* client_; | 500 GConfClient* client_; |
502 // These ids are the values returned from gconf_client_notify_add(), which we | 501 // These ids are the values returned from gconf_client_notify_add(), which we |
503 // will need in order to later call gconf_client_notify_remove(). | 502 // will need in order to later call gconf_client_notify_remove(). |
504 guint system_proxy_id_; | 503 guint system_proxy_id_; |
505 guint system_http_proxy_id_; | 504 guint system_http_proxy_id_; |
506 | 505 |
507 ProxyConfigServiceLinux::Delegate* notify_delegate_; | 506 ProxyConfigServiceLinux::Delegate* notify_delegate_; |
508 scoped_ptr<base::OneShotTimer<SettingGetterImplGConf> > debounce_timer_; | 507 scoped_ptr<base::OneShotTimer> debounce_timer_; |
509 | 508 |
510 // Task runner for the thread that we make gconf calls on. It should | 509 // Task runner for the thread that we make gconf calls on. It should |
511 // be the UI thread and all our methods should be called on this | 510 // be the UI thread and all our methods should be called on this |
512 // thread. Only for assertions. | 511 // thread. Only for assertions. |
513 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 512 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
514 | 513 |
515 DISALLOW_COPY_AND_ASSIGN(SettingGetterImplGConf); | 514 DISALLOW_COPY_AND_ASSIGN(SettingGetterImplGConf); |
516 }; | 515 }; |
517 #endif // defined(USE_GCONF) | 516 #endif // defined(USE_GCONF) |
518 | 517 |
519 #if defined(USE_GIO) | 518 #if defined(USE_GIO) |
520 const char kProxyGConfSchema[] = "org.gnome.system.proxy"; | 519 const char kProxyGConfSchema[] = "org.gnome.system.proxy"; |
521 | 520 |
522 // This setting getter uses gsettings, as used in most GNOME 3 desktops. | 521 // This setting getter uses gsettings, as used in most GNOME 3 desktops. |
523 class SettingGetterImplGSettings | 522 class SettingGetterImplGSettings |
524 : public ProxyConfigServiceLinux::SettingGetter { | 523 : public ProxyConfigServiceLinux::SettingGetter { |
525 public: | 524 public: |
526 SettingGetterImplGSettings() : | 525 SettingGetterImplGSettings() |
527 client_(NULL), | 526 : client_(NULL), |
528 http_client_(NULL), | 527 http_client_(NULL), |
529 https_client_(NULL), | 528 https_client_(NULL), |
530 ftp_client_(NULL), | 529 ftp_client_(NULL), |
531 socks_client_(NULL), | 530 socks_client_(NULL), |
532 notify_delegate_(NULL), | 531 notify_delegate_(NULL), |
533 debounce_timer_(new base::OneShotTimer<SettingGetterImplGSettings>()) { | 532 debounce_timer_(new base::OneShotTimer()) {} |
534 } | |
535 | 533 |
536 ~SettingGetterImplGSettings() override { | 534 ~SettingGetterImplGSettings() override { |
537 // client_ should have been released before now, from | 535 // client_ should have been released before now, from |
538 // Delegate::OnDestroy(), while running on the UI thread. However | 536 // Delegate::OnDestroy(), while running on the UI thread. However |
539 // on exiting the process, it may happen that | 537 // on exiting the process, it may happen that |
540 // Delegate::OnDestroy() task is left pending on the glib loop | 538 // Delegate::OnDestroy() task is left pending on the glib loop |
541 // after the loop was quit, and pending tasks may then be deleted | 539 // after the loop was quit, and pending tasks may then be deleted |
542 // without being run. | 540 // without being run. |
543 if (client_) { | 541 if (client_) { |
544 // gconf client was not cleaned up. | 542 // gconf client was not cleaned up. |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 reinterpret_cast<SettingGetterImplGSettings*>(user_data); | 767 reinterpret_cast<SettingGetterImplGSettings*>(user_data); |
770 setting_getter->OnChangeNotification(); | 768 setting_getter->OnChangeNotification(); |
771 } | 769 } |
772 | 770 |
773 GSettings* client_; | 771 GSettings* client_; |
774 GSettings* http_client_; | 772 GSettings* http_client_; |
775 GSettings* https_client_; | 773 GSettings* https_client_; |
776 GSettings* ftp_client_; | 774 GSettings* ftp_client_; |
777 GSettings* socks_client_; | 775 GSettings* socks_client_; |
778 ProxyConfigServiceLinux::Delegate* notify_delegate_; | 776 ProxyConfigServiceLinux::Delegate* notify_delegate_; |
779 scoped_ptr<base::OneShotTimer<SettingGetterImplGSettings> > debounce_timer_; | 777 scoped_ptr<base::OneShotTimer> debounce_timer_; |
780 | 778 |
781 // Task runner for the thread that we make gsettings calls on. It should | 779 // Task runner for the thread that we make gsettings calls on. It should |
782 // be the UI thread and all our methods should be called on this | 780 // be the UI thread and all our methods should be called on this |
783 // thread. Only for assertions. | 781 // thread. Only for assertions. |
784 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 782 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
785 | 783 |
786 LibGioLoader libgio_loader_; | 784 LibGioLoader libgio_loader_; |
787 | 785 |
788 DISALLOW_COPY_AND_ASSIGN(SettingGetterImplGSettings); | 786 DISALLOW_COPY_AND_ASSIGN(SettingGetterImplGSettings); |
789 }; | 787 }; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 | 853 |
856 // This is the KDE version that reads kioslaverc and simulates gconf. | 854 // This is the KDE version that reads kioslaverc and simulates gconf. |
857 // Doing this allows the main Delegate code, as well as the unit tests | 855 // Doing this allows the main Delegate code, as well as the unit tests |
858 // for it, to stay the same - and the settings map fairly well besides. | 856 // for it, to stay the same - and the settings map fairly well besides. |
859 class SettingGetterImplKDE : public ProxyConfigServiceLinux::SettingGetter, | 857 class SettingGetterImplKDE : public ProxyConfigServiceLinux::SettingGetter, |
860 public base::MessagePumpLibevent::Watcher { | 858 public base::MessagePumpLibevent::Watcher { |
861 public: | 859 public: |
862 explicit SettingGetterImplKDE(base::Environment* env_var_getter) | 860 explicit SettingGetterImplKDE(base::Environment* env_var_getter) |
863 : inotify_fd_(-1), | 861 : inotify_fd_(-1), |
864 notify_delegate_(NULL), | 862 notify_delegate_(NULL), |
865 debounce_timer_(new base::OneShotTimer<SettingGetterImplKDE>()), | 863 debounce_timer_(new base::OneShotTimer()), |
866 indirect_manual_(false), | 864 indirect_manual_(false), |
867 auto_no_pac_(false), | 865 auto_no_pac_(false), |
868 reversed_bypass_list_(false), | 866 reversed_bypass_list_(false), |
869 env_var_getter_(env_var_getter), | 867 env_var_getter_(env_var_getter), |
870 file_task_runner_(NULL) { | 868 file_task_runner_(NULL) { |
871 // This has to be called on the UI thread (http://crbug.com/69057). | 869 // This has to be called on the UI thread (http://crbug.com/69057). |
872 base::ThreadRestrictions::ScopedAllowIO allow_io; | 870 base::ThreadRestrictions::ScopedAllowIO allow_io; |
873 | 871 |
874 // Derive the location of the kde config dir from the environment. | 872 // Derive the location of the kde config dir from the environment. |
875 std::string home; | 873 std::string home; |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1326 } | 1324 } |
1327 } | 1325 } |
1328 | 1326 |
1329 typedef std::map<StringSetting, std::string> string_map_type; | 1327 typedef std::map<StringSetting, std::string> string_map_type; |
1330 typedef std::map<StringListSetting, | 1328 typedef std::map<StringListSetting, |
1331 std::vector<std::string> > strings_map_type; | 1329 std::vector<std::string> > strings_map_type; |
1332 | 1330 |
1333 int inotify_fd_; | 1331 int inotify_fd_; |
1334 base::MessagePumpLibevent::FileDescriptorWatcher inotify_watcher_; | 1332 base::MessagePumpLibevent::FileDescriptorWatcher inotify_watcher_; |
1335 ProxyConfigServiceLinux::Delegate* notify_delegate_; | 1333 ProxyConfigServiceLinux::Delegate* notify_delegate_; |
1336 scoped_ptr<base::OneShotTimer<SettingGetterImplKDE> > debounce_timer_; | 1334 scoped_ptr<base::OneShotTimer> debounce_timer_; |
1337 base::FilePath kde_config_dir_; | 1335 base::FilePath kde_config_dir_; |
1338 bool indirect_manual_; | 1336 bool indirect_manual_; |
1339 bool auto_no_pac_; | 1337 bool auto_no_pac_; |
1340 bool reversed_bypass_list_; | 1338 bool reversed_bypass_list_; |
1341 // We don't own |env_var_getter_|. It's safe to hold a pointer to it, since | 1339 // We don't own |env_var_getter_|. It's safe to hold a pointer to it, since |
1342 // both it and us are owned by ProxyConfigServiceLinux::Delegate, and have the | 1340 // both it and us are owned by ProxyConfigServiceLinux::Delegate, and have the |
1343 // same lifetime. | 1341 // same lifetime. |
1344 base::Environment* env_var_getter_; | 1342 base::Environment* env_var_getter_; |
1345 | 1343 |
1346 // We cache these settings whenever we re-read the kioslaverc file. | 1344 // We cache these settings whenever we re-read the kioslaverc file. |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1774 void ProxyConfigServiceLinux::RemoveObserver(Observer* observer) { | 1772 void ProxyConfigServiceLinux::RemoveObserver(Observer* observer) { |
1775 delegate_->RemoveObserver(observer); | 1773 delegate_->RemoveObserver(observer); |
1776 } | 1774 } |
1777 | 1775 |
1778 ProxyConfigService::ConfigAvailability | 1776 ProxyConfigService::ConfigAvailability |
1779 ProxyConfigServiceLinux::GetLatestProxyConfig(ProxyConfig* config) { | 1777 ProxyConfigServiceLinux::GetLatestProxyConfig(ProxyConfig* config) { |
1780 return delegate_->GetLatestProxyConfig(config); | 1778 return delegate_->GetLatestProxyConfig(config); |
1781 } | 1779 } |
1782 | 1780 |
1783 } // namespace net | 1781 } // namespace net |
OLD | NEW |