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 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1571 const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner) { | 1571 const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner) { |
1572 // We should be running on the default glib main loop thread right | 1572 // We should be running on the default glib main loop thread right |
1573 // now. gconf can only be accessed from this thread. | 1573 // now. gconf can only be accessed from this thread. |
1574 DCHECK(glib_task_runner->BelongsToCurrentThread()); | 1574 DCHECK(glib_task_runner->BelongsToCurrentThread()); |
1575 glib_task_runner_ = glib_task_runner; | 1575 glib_task_runner_ = glib_task_runner; |
1576 io_task_runner_ = io_task_runner; | 1576 io_task_runner_ = io_task_runner; |
1577 | 1577 |
1578 // If we are passed a NULL |io_task_runner| or |file_task_runner|, then we | 1578 // If we are passed a NULL |io_task_runner| or |file_task_runner|, then we |
1579 // don't set up proxy setting change notifications. This should not be the | 1579 // don't set up proxy setting change notifications. This should not be the |
1580 // usual case but is intended to/ simplify test setups. | 1580 // usual case but is intended to/ simplify test setups. |
1581 if (!io_task_runner_.get() || !file_task_runner) | 1581 if (!io_task_runner_.get() || !file_task_runner.get()) |
1582 VLOG(1) << "Monitoring of proxy setting changes is disabled"; | 1582 VLOG(1) << "Monitoring of proxy setting changes is disabled"; |
1583 | 1583 |
1584 // Fetch and cache the current proxy config. The config is left in | 1584 // Fetch and cache the current proxy config. The config is left in |
1585 // cached_config_, where GetLatestProxyConfig() running on the IO thread | 1585 // cached_config_, where GetLatestProxyConfig() running on the IO thread |
1586 // will expect to find it. This is safe to do because we return | 1586 // will expect to find it. This is safe to do because we return |
1587 // before this ProxyConfigServiceLinux is passed on to | 1587 // before this ProxyConfigServiceLinux is passed on to |
1588 // the ProxyService. | 1588 // the ProxyService. |
1589 | 1589 |
1590 // Note: It would be nice to prioritize environment variables | 1590 // Note: It would be nice to prioritize environment variables |
1591 // and only fall back to gconf if env vars were unset. But | 1591 // and only fall back to gconf if env vars were unset. But |
(...skipping 21 matching lines...) Expand all Loading... |
1613 reference_config_ = cached_config_; | 1613 reference_config_ = cached_config_; |
1614 reference_config_.set_id(1); // Mark it as valid. | 1614 reference_config_.set_id(1); // Mark it as valid. |
1615 | 1615 |
1616 // We only set up notifications if we have IO and file loops available. | 1616 // We only set up notifications if we have IO and file loops available. |
1617 // We do this after getting the initial configuration so that we don't have | 1617 // We do this after getting the initial configuration so that we don't have |
1618 // to worry about cancelling it if the initial fetch above fails. Note that | 1618 // to worry about cancelling it if the initial fetch above fails. Note that |
1619 // setting up notifications has the side effect of simulating a change, so | 1619 // setting up notifications has the side effect of simulating a change, so |
1620 // that we won't lose any updates that may have happened after the initial | 1620 // that we won't lose any updates that may have happened after the initial |
1621 // fetch and before setting up notifications. We'll detect the common case | 1621 // fetch and before setting up notifications. We'll detect the common case |
1622 // of no changes in OnCheckProxyConfigSettings() (or sooner) and ignore it. | 1622 // of no changes in OnCheckProxyConfigSettings() (or sooner) and ignore it. |
1623 if (io_task_runner && file_task_runner) { | 1623 if (io_task_runner.get() && file_task_runner.get()) { |
1624 scoped_refptr<base::SingleThreadTaskRunner> required_loop = | 1624 scoped_refptr<base::SingleThreadTaskRunner> required_loop = |
1625 setting_getter_->GetNotificationTaskRunner(); | 1625 setting_getter_->GetNotificationTaskRunner(); |
1626 if (!required_loop.get() || required_loop->BelongsToCurrentThread()) { | 1626 if (!required_loop.get() || required_loop->BelongsToCurrentThread()) { |
1627 // In this case we are already on an acceptable thread. | 1627 // In this case we are already on an acceptable thread. |
1628 SetUpNotifications(); | 1628 SetUpNotifications(); |
1629 } else { | 1629 } else { |
1630 // Post a task to set up notifications. We don't wait for success. | 1630 // Post a task to set up notifications. We don't wait for success. |
1631 required_loop->PostTask(FROM_HERE, base::Bind( | 1631 required_loop->PostTask(FROM_HERE, base::Bind( |
1632 &ProxyConfigServiceLinux::Delegate::SetUpNotifications, this)); | 1632 &ProxyConfigServiceLinux::Delegate::SetUpNotifications, this)); |
1633 } | 1633 } |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1773 void ProxyConfigServiceLinux::RemoveObserver(Observer* observer) { | 1773 void ProxyConfigServiceLinux::RemoveObserver(Observer* observer) { |
1774 delegate_->RemoveObserver(observer); | 1774 delegate_->RemoveObserver(observer); |
1775 } | 1775 } |
1776 | 1776 |
1777 ProxyConfigService::ConfigAvailability | 1777 ProxyConfigService::ConfigAvailability |
1778 ProxyConfigServiceLinux::GetLatestProxyConfig(ProxyConfig* config) { | 1778 ProxyConfigServiceLinux::GetLatestProxyConfig(ProxyConfig* config) { |
1779 return delegate_->GetLatestProxyConfig(config); | 1779 return delegate_->GetLatestProxyConfig(config); |
1780 } | 1780 } |
1781 | 1781 |
1782 } // namespace net | 1782 } // namespace net |
OLD | NEW |