| 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_service.h" | 5 #include "net/proxy/proxy_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 ProxyService::ProxyService(ProxyConfigService* config_service, | 860 ProxyService::ProxyService(ProxyConfigService* config_service, |
| 861 ProxyResolver* resolver, | 861 ProxyResolver* resolver, |
| 862 NetLog* net_log) | 862 NetLog* net_log) |
| 863 : resolver_(resolver), | 863 : resolver_(resolver), |
| 864 next_config_id_(1), | 864 next_config_id_(1), |
| 865 current_state_(STATE_NONE) , | 865 current_state_(STATE_NONE) , |
| 866 net_log_(net_log), | 866 net_log_(net_log), |
| 867 stall_proxy_auto_config_delay_(TimeDelta::FromMilliseconds( | 867 stall_proxy_auto_config_delay_(TimeDelta::FromMilliseconds( |
| 868 kDelayAfterNetworkChangesMs)) { | 868 kDelayAfterNetworkChangesMs)) { |
| 869 NetworkChangeNotifier::AddIPAddressObserver(this); | 869 NetworkChangeNotifier::AddIPAddressObserver(this); |
| 870 NetworkChangeNotifier::AddDNSObserver(this); |
| 870 ResetConfigService(config_service); | 871 ResetConfigService(config_service); |
| 871 } | 872 } |
| 872 | 873 |
| 873 // static | 874 // static |
| 874 ProxyService* ProxyService::CreateUsingSystemProxyResolver( | 875 ProxyService* ProxyService::CreateUsingSystemProxyResolver( |
| 875 ProxyConfigService* proxy_config_service, | 876 ProxyConfigService* proxy_config_service, |
| 876 size_t num_pac_threads, | 877 size_t num_pac_threads, |
| 877 NetLog* net_log) { | 878 NetLog* net_log) { |
| 878 DCHECK(proxy_config_service); | 879 DCHECK(proxy_config_service); |
| 879 | 880 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1015 | 1016 |
| 1016 // Use the manual proxy settings. | 1017 // Use the manual proxy settings. |
| 1017 config_.proxy_rules().Apply(url, result); | 1018 config_.proxy_rules().Apply(url, result); |
| 1018 result->config_source_ = config_.source(); | 1019 result->config_source_ = config_.source(); |
| 1019 result->config_id_ = config_.id(); | 1020 result->config_id_ = config_.id(); |
| 1020 return OK; | 1021 return OK; |
| 1021 } | 1022 } |
| 1022 | 1023 |
| 1023 ProxyService::~ProxyService() { | 1024 ProxyService::~ProxyService() { |
| 1024 NetworkChangeNotifier::RemoveIPAddressObserver(this); | 1025 NetworkChangeNotifier::RemoveIPAddressObserver(this); |
| 1026 NetworkChangeNotifier::RemoveDNSObserver(this); |
| 1025 config_service_->RemoveObserver(this); | 1027 config_service_->RemoveObserver(this); |
| 1026 | 1028 |
| 1027 // Cancel any inprogress requests. | 1029 // Cancel any inprogress requests. |
| 1028 for (PendingRequests::iterator it = pending_requests_.begin(); | 1030 for (PendingRequests::iterator it = pending_requests_.begin(); |
| 1029 it != pending_requests_.end(); | 1031 it != pending_requests_.end(); |
| 1030 ++it) { | 1032 ++it) { |
| 1031 (*it)->Cancel(); | 1033 (*it)->Cancel(); |
| 1032 } | 1034 } |
| 1033 } | 1035 } |
| 1034 | 1036 |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1474 void ProxyService::OnIPAddressChanged() { | 1476 void ProxyService::OnIPAddressChanged() { |
| 1475 // See the comment block by |kDelayAfterNetworkChangesMs| for info. | 1477 // See the comment block by |kDelayAfterNetworkChangesMs| for info. |
| 1476 stall_proxy_autoconfig_until_ = | 1478 stall_proxy_autoconfig_until_ = |
| 1477 TimeTicks::Now() + stall_proxy_auto_config_delay_; | 1479 TimeTicks::Now() + stall_proxy_auto_config_delay_; |
| 1478 | 1480 |
| 1479 State previous_state = ResetProxyConfig(false); | 1481 State previous_state = ResetProxyConfig(false); |
| 1480 if (previous_state != STATE_NONE) | 1482 if (previous_state != STATE_NONE) |
| 1481 ApplyProxyConfigIfAvailable(); | 1483 ApplyProxyConfigIfAvailable(); |
| 1482 } | 1484 } |
| 1483 | 1485 |
| 1486 void ProxyService::OnDNSChanged() { |
| 1487 OnIPAddressChanged(); |
| 1488 } |
| 1489 |
| 1484 SyncProxyServiceHelper::SyncProxyServiceHelper(MessageLoop* io_message_loop, | 1490 SyncProxyServiceHelper::SyncProxyServiceHelper(MessageLoop* io_message_loop, |
| 1485 ProxyService* proxy_service) | 1491 ProxyService* proxy_service) |
| 1486 : io_message_loop_(io_message_loop), | 1492 : io_message_loop_(io_message_loop), |
| 1487 proxy_service_(proxy_service), | 1493 proxy_service_(proxy_service), |
| 1488 event_(false, false), | 1494 event_(false, false), |
| 1489 ALLOW_THIS_IN_INITIALIZER_LIST(callback_( | 1495 ALLOW_THIS_IN_INITIALIZER_LIST(callback_( |
| 1490 base::Bind(&SyncProxyServiceHelper::OnCompletion, | 1496 base::Bind(&SyncProxyServiceHelper::OnCompletion, |
| 1491 base::Unretained(this)))) { | 1497 base::Unretained(this)))) { |
| 1492 DCHECK(io_message_loop_ != MessageLoop::current()); | 1498 DCHECK(io_message_loop_ != MessageLoop::current()); |
| 1493 } | 1499 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1546 OnCompletion(result_); | 1552 OnCompletion(result_); |
| 1547 } | 1553 } |
| 1548 } | 1554 } |
| 1549 | 1555 |
| 1550 void SyncProxyServiceHelper::OnCompletion(int rv) { | 1556 void SyncProxyServiceHelper::OnCompletion(int rv) { |
| 1551 result_ = rv; | 1557 result_ = rv; |
| 1552 event_.Signal(); | 1558 event_.Signal(); |
| 1553 } | 1559 } |
| 1554 | 1560 |
| 1555 } // namespace net | 1561 } // namespace net |
| OLD | NEW |