| OLD | NEW |
| 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 <stdlib.h> | 8 #include <stdlib.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 } | 505 } |
| 506 | 506 |
| 507 void ProxyConfigServiceLinux::Delegate::SetupAndFetchInitialConfig( | 507 void ProxyConfigServiceLinux::Delegate::SetupAndFetchInitialConfig( |
| 508 MessageLoop* glib_default_loop, MessageLoop* io_loop) { | 508 MessageLoop* glib_default_loop, MessageLoop* io_loop) { |
| 509 // We should be running on the default glib main loop thread right | 509 // We should be running on the default glib main loop thread right |
| 510 // now. gconf can only be accessed from this thread. | 510 // now. gconf can only be accessed from this thread. |
| 511 DCHECK(MessageLoop::current() == glib_default_loop); | 511 DCHECK(MessageLoop::current() == glib_default_loop); |
| 512 glib_default_loop_ = glib_default_loop; | 512 glib_default_loop_ = glib_default_loop; |
| 513 io_loop_ = io_loop; | 513 io_loop_ = io_loop; |
| 514 | 514 |
| 515 // If we are passed a NULL io_loop, then we don't setup gconf | 515 // If we are passed a NULL io_loop, then we don't set up gconf |
| 516 // notifications. This should not be the usual case but is intended | 516 // notifications. This should not be the usual case but is intended |
| 517 // to simplify test setups. | 517 // to simplify test setups. |
| 518 if (!io_loop_) | 518 if (!io_loop_) |
| 519 LOG(INFO) << "Monitoring of gconf setting changes is disabled"; | 519 LOG(INFO) << "Monitoring of gconf setting changes is disabled"; |
| 520 | 520 |
| 521 // Fetch and cache the current proxy config. The config is left in | 521 // Fetch and cache the current proxy config. The config is left in |
| 522 // cached_config_, where GetProxyConfig() running on the IO thread | 522 // cached_config_, where GetProxyConfig() running on the IO thread |
| 523 // will expect to find it. This is safe to do because we return | 523 // will expect to find it. This is safe to do because we return |
| 524 // before this ProxyConfigServiceLinux is passed on to | 524 // before this ProxyConfigServiceLinux is passed on to |
| 525 // the ProxyService. | 525 // the ProxyService. |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 if (new_config.is_valid() != reference_config_.is_valid() || | 605 if (new_config.is_valid() != reference_config_.is_valid() || |
| 606 !new_config.Equals(reference_config_)) { | 606 !new_config.Equals(reference_config_)) { |
| 607 // Post a task to |io_loop| with the new configuration, so it can | 607 // Post a task to |io_loop| with the new configuration, so it can |
| 608 // update |cached_config_|. | 608 // update |cached_config_|. |
| 609 io_loop_->PostTask( | 609 io_loop_->PostTask( |
| 610 FROM_HERE, | 610 FROM_HERE, |
| 611 NewRunnableMethod( | 611 NewRunnableMethod( |
| 612 this, | 612 this, |
| 613 &ProxyConfigServiceLinux::Delegate::SetNewProxyConfig, | 613 &ProxyConfigServiceLinux::Delegate::SetNewProxyConfig, |
| 614 new_config)); | 614 new_config)); |
| 615 // Update the thread-private copy in |reference_config_| as well. |
| 616 reference_config_ = new_config; |
| 615 } | 617 } |
| 616 } | 618 } |
| 617 | 619 |
| 618 void ProxyConfigServiceLinux::Delegate::SetNewProxyConfig( | 620 void ProxyConfigServiceLinux::Delegate::SetNewProxyConfig( |
| 619 const ProxyConfig& new_config) { | 621 const ProxyConfig& new_config) { |
| 620 DCHECK(MessageLoop::current() == io_loop_); | 622 DCHECK(MessageLoop::current() == io_loop_); |
| 621 LOG(INFO) << "Proxy configuration changed"; | 623 LOG(INFO) << "Proxy configuration changed"; |
| 622 cached_config_ = new_config; | 624 cached_config_ = new_config; |
| 623 } | 625 } |
| 624 | 626 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 648 new GConfSettingGetterImpl())) { | 650 new GConfSettingGetterImpl())) { |
| 649 } | 651 } |
| 650 | 652 |
| 651 ProxyConfigServiceLinux::ProxyConfigServiceLinux( | 653 ProxyConfigServiceLinux::ProxyConfigServiceLinux( |
| 652 base::EnvironmentVariableGetter* env_var_getter, | 654 base::EnvironmentVariableGetter* env_var_getter, |
| 653 GConfSettingGetter* gconf_getter) | 655 GConfSettingGetter* gconf_getter) |
| 654 : delegate_(new Delegate(env_var_getter, gconf_getter)) { | 656 : delegate_(new Delegate(env_var_getter, gconf_getter)) { |
| 655 } | 657 } |
| 656 | 658 |
| 657 } // namespace net | 659 } // namespace net |
| OLD | NEW |