Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: net/proxy/proxy_config_service_linux.cc

Issue 316013006: Annotate a third-party leak in SettingGetterImplGSettings::LoadAndCheckVersion(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: refactor Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // glib >=2.40 deprecate g_settings_list_schemas in favor of 7 // glib >=2.40 deprecate g_settings_list_schemas in favor of
8 // g_settings_schema_source_list_schemas. This function is not available on 8 // g_settings_schema_source_list_schemas. This function is not available on
9 // earlier versions that we still need to support (specifically, 2.32), so 9 // earlier versions that we still need to support (specifically, 2.32), so
10 // disable the warning. 10 // disable the warning.
(...skipping 10 matching lines...) Expand all
21 #include <limits.h> 21 #include <limits.h>
22 #include <stdio.h> 22 #include <stdio.h>
23 #include <stdlib.h> 23 #include <stdlib.h>
24 #include <sys/inotify.h> 24 #include <sys/inotify.h>
25 #include <unistd.h> 25 #include <unistd.h>
26 26
27 #include <map> 27 #include <map>
28 28
29 #include "base/bind.h" 29 #include "base/bind.h"
30 #include "base/compiler_specific.h" 30 #include "base/compiler_specific.h"
31 #include "base/debug/leak_annotations.h"
31 #include "base/environment.h" 32 #include "base/environment.h"
32 #include "base/file_util.h" 33 #include "base/file_util.h"
33 #include "base/files/file_path.h" 34 #include "base/files/file_path.h"
34 #include "base/files/scoped_file.h" 35 #include "base/files/scoped_file.h"
35 #include "base/logging.h" 36 #include "base/logging.h"
36 #include "base/message_loop/message_loop.h" 37 #include "base/message_loop/message_loop.h"
37 #include "base/nix/xdg_util.h" 38 #include "base/nix/xdg_util.h"
38 #include "base/single_thread_task_runner.h" 39 #include "base/single_thread_task_runner.h"
39 #include "base/strings/string_number_conversions.h" 40 #include "base/strings/string_number_conversions.h"
40 #include "base/strings/string_tokenizer.h" 41 #include "base/strings/string_tokenizer.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 // Note that this uses "suffix" matching. So a bypass of "google.com" 198 // Note that this uses "suffix" matching. So a bypass of "google.com"
198 // is understood to mean a bypass of "*google.com". 199 // is understood to mean a bypass of "*google.com".
199 config->proxy_rules().bypass_rules.ParseFromStringUsingSuffixMatching( 200 config->proxy_rules().bypass_rules.ParseFromStringUsingSuffixMatching(
200 no_proxy); 201 no_proxy);
201 return true; 202 return true;
202 } 203 }
203 204
204 namespace { 205 namespace {
205 206
206 const int kDebounceTimeoutMilliseconds = 250; 207 const int kDebounceTimeoutMilliseconds = 250;
208 const char kProxyGConfSchema[] = "org.gnome.system.proxy";
207 209
208 #if defined(USE_GCONF) 210 #if defined(USE_GCONF)
209 // This setting getter uses gconf, as used in GNOME 2 and some GNOME 3 desktops. 211 // This setting getter uses gconf, as used in GNOME 2 and some GNOME 3 desktops.
210 class SettingGetterImplGConf : public ProxyConfigServiceLinux::SettingGetter { 212 class SettingGetterImplGConf : public ProxyConfigServiceLinux::SettingGetter {
211 public: 213 public:
212 SettingGetterImplGConf() 214 SettingGetterImplGConf()
213 : client_(NULL), system_proxy_id_(0), system_http_proxy_id_(0), 215 : client_(NULL), system_proxy_id_(0), system_http_proxy_id_(0),
214 notify_delegate_(NULL) { 216 notify_delegate_(NULL) {
215 } 217 }
216 218
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 569
568 // LoadAndCheckVersion() must be called *before* Init()! 570 // LoadAndCheckVersion() must be called *before* Init()!
569 bool LoadAndCheckVersion(base::Environment* env); 571 bool LoadAndCheckVersion(base::Environment* env);
570 572
571 virtual bool Init(base::SingleThreadTaskRunner* glib_thread_task_runner, 573 virtual bool Init(base::SingleThreadTaskRunner* glib_thread_task_runner,
572 base::MessageLoopForIO* file_loop) OVERRIDE { 574 base::MessageLoopForIO* file_loop) OVERRIDE {
573 DCHECK(glib_thread_task_runner->BelongsToCurrentThread()); 575 DCHECK(glib_thread_task_runner->BelongsToCurrentThread());
574 DCHECK(!client_); 576 DCHECK(!client_);
575 DCHECK(!task_runner_.get()); 577 DCHECK(!task_runner_.get());
576 578
577 if (!SchemaExists("org.gnome.system.proxy") || 579 if (!SchemaExists(kProxyGConfSchema) ||
578 !(client_ = libgio_loader_.g_settings_new("org.gnome.system.proxy"))) { 580 !(client_ = libgio_loader_.g_settings_new(kProxyGConfSchema))) {
579 // It's not clear whether/when this can return NULL. 581 // It's not clear whether/when this can return NULL.
580 LOG(ERROR) << "Unable to create a gsettings client"; 582 LOG(ERROR) << "Unable to create a gsettings client";
581 return false; 583 return false;
582 } 584 }
583 task_runner_ = glib_thread_task_runner; 585 task_runner_ = glib_thread_task_runner;
584 // We assume these all work if the above call worked. 586 // We assume these all work if the above call worked.
585 http_client_ = libgio_loader_.g_settings_get_child(client_, "http"); 587 http_client_ = libgio_loader_.g_settings_get_child(client_, "http");
586 https_client_ = libgio_loader_.g_settings_get_child(client_, "https"); 588 https_client_ = libgio_loader_.g_settings_get_child(client_, "https");
587 ftp_client_ = libgio_loader_.g_settings_get_child(client_, "ftp"); 589 ftp_client_ = libgio_loader_.g_settings_get_child(client_, "ftp");
588 socks_client_ = libgio_loader_.g_settings_get_child(client_, "socks"); 590 socks_client_ = libgio_loader_.g_settings_get_child(client_, "socks");
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 base::ThreadRestrictions::ScopedAllowIO allow_io; 810 base::ThreadRestrictions::ScopedAllowIO allow_io;
809 811
810 // Try also without .0 at the end; on some systems this may be required. 812 // Try also without .0 at the end; on some systems this may be required.
811 if (!libgio_loader_.Load("libgio-2.0.so.0") && 813 if (!libgio_loader_.Load("libgio-2.0.so.0") &&
812 !libgio_loader_.Load("libgio-2.0.so")) { 814 !libgio_loader_.Load("libgio-2.0.so")) {
813 VLOG(1) << "Cannot load gio library. Will fall back to gconf."; 815 VLOG(1) << "Cannot load gio library. Will fall back to gconf.";
814 return false; 816 return false;
815 } 817 }
816 } 818 }
817 819
818 GSettings* client; 820 GSettings* client = NULL;
819 if (!SchemaExists("org.gnome.system.proxy") || 821 if (SchemaExists(kProxyGConfSchema)) {
820 !(client = libgio_loader_.g_settings_new("org.gnome.system.proxy"))) { 822 ANNOTATE_SCOPED_MEMORY_LEAK; // http://crbug.com/380782
823 client = libgio_loader_.g_settings_new(kProxyGConfSchema);
824 }
825 if (!client) {
821 VLOG(1) << "Cannot create gsettings client. Will fall back to gconf."; 826 VLOG(1) << "Cannot create gsettings client. Will fall back to gconf.";
822 return false; 827 return false;
823 } 828 }
824 g_object_unref(client); 829 g_object_unref(client);
825 830
826 std::string path; 831 std::string path;
827 if (!env->GetVar("PATH", &path)) { 832 if (!env->GetVar("PATH", &path)) {
828 LOG(ERROR) << "No $PATH variable. Assuming no gnome-network-properties."; 833 LOG(ERROR) << "No $PATH variable. Assuming no gnome-network-properties.";
829 } else { 834 } else {
830 // Yes, we're on the UI thread. Yes, we're accessing the file system. 835 // Yes, we're on the UI thread. Yes, we're accessing the file system.
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after
1767 void ProxyConfigServiceLinux::RemoveObserver(Observer* observer) { 1772 void ProxyConfigServiceLinux::RemoveObserver(Observer* observer) {
1768 delegate_->RemoveObserver(observer); 1773 delegate_->RemoveObserver(observer);
1769 } 1774 }
1770 1775
1771 ProxyConfigService::ConfigAvailability 1776 ProxyConfigService::ConfigAvailability
1772 ProxyConfigServiceLinux::GetLatestProxyConfig(ProxyConfig* config) { 1777 ProxyConfigServiceLinux::GetLatestProxyConfig(ProxyConfig* config) {
1773 return delegate_->GetLatestProxyConfig(config); 1778 return delegate_->GetLatestProxyConfig(config);
1774 } 1779 }
1775 1780
1776 } // namespace net 1781 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698