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

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

Issue 99126: Mutual exclusion between gconf and the glib main loop. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 8 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 | « chrome/app/chrome_dll_main.cc ('k') | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 <gconf/gconf-client.h> 7 #include <gconf/gconf-client.h>
8 #include <gdk/gdk.h> 8 #include <gdk/gdk.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 10
11 #include "base/lock.h"
11 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/message_pump_glib.h"
12 #include "base/string_tokenizer.h" 14 #include "base/string_tokenizer.h"
13 #include "base/string_util.h" 15 #include "base/string_util.h"
14 #include "googleurl/src/url_canon.h" 16 #include "googleurl/src/url_canon.h"
15 #include "net/base/net_errors.h" 17 #include "net/base/net_errors.h"
16 #include "net/http/http_util.h" 18 #include "net/http/http_util.h"
17 #include "net/proxy/proxy_config.h" 19 #include "net/proxy/proxy_config.h"
18 #include "net/proxy/proxy_server.h" 20 #include "net/proxy/proxy_server.h"
19 21
20 namespace net { 22 namespace net {
21 23
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 class GConfSettingGetterImpl 253 class GConfSettingGetterImpl
252 : public ProxyConfigServiceLinux::GConfSettingGetter { 254 : public ProxyConfigServiceLinux::GConfSettingGetter {
253 public: 255 public:
254 GConfSettingGetterImpl() : client_(NULL) {} 256 GConfSettingGetterImpl() : client_(NULL) {}
255 virtual ~GConfSettingGetterImpl() { 257 virtual ~GConfSettingGetterImpl() {
256 if (client_) 258 if (client_)
257 g_object_unref(client_); 259 g_object_unref(client_);
258 } 260 }
259 261
260 virtual void Enter() { 262 virtual void Enter() {
261 gdk_threads_enter(); 263 // Gconf is not thread-safe against itself, and it's meant to be
264 // used from the thread running the glib main loop. The proxy
265 // configuration is being fetched from the I/O thread, while the
266 // glib main loop runs in the UI thread. gconf has callbacks,
267 // timeouts and idles that will be dispatched from the glib main
268 // loop. We take this lock to enforce mutual exclusion with the
269 // glib main loop.
270 base::MessagePumpForUI::glib_main_loop_lock_.Acquire();
262 } 271 }
263 virtual void Leave() { 272 virtual void Leave() {
264 gdk_threads_leave(); 273 base::MessagePumpForUI::glib_main_loop_lock_.Release();
265 } 274 }
266 275
267 virtual bool InitIfNeeded() { 276 virtual bool InitIfNeeded() {
268 if (!client_) { 277 if (!client_) {
269 Enter(); 278 Enter();
270 client_ = gconf_client_get_default(); 279 client_ = gconf_client_get_default();
271 Leave(); 280 Leave();
272 // It's not clear whether/when this can return NULL. 281 // It's not clear whether/when this can return NULL.
273 if (!client_) 282 if (!client_)
274 LOG(ERROR) << "ProxyConfigServiceLinux: Unable to create " 283 LOG(ERROR) << "ProxyConfigServiceLinux: Unable to create "
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 if (!ok) { 556 if (!ok) {
548 ok = GetConfigFromEnv(config); 557 ok = GetConfigFromEnv(config);
549 if (ok) 558 if (ok)
550 LOG(INFO) << "ProxyConfigServiceLinux: obtained proxy setting " 559 LOG(INFO) << "ProxyConfigServiceLinux: obtained proxy setting "
551 "from environment variables"; 560 "from environment variables";
552 } 561 }
553 return ok ? OK : ERR_FAILED; 562 return ok ? OK : ERR_FAILED;
554 } 563 }
555 564
556 } // namespace net 565 } // namespace net
OLDNEW
« no previous file with comments | « chrome/app/chrome_dll_main.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698