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

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

Issue 11620007: Switch from OnIPAddressChanged and OnConnectionTypeChange to OnNetworkChanged Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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
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_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 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 862
863 ProxyService::ProxyService(ProxyConfigService* config_service, 863 ProxyService::ProxyService(ProxyConfigService* config_service,
864 ProxyResolver* resolver, 864 ProxyResolver* resolver,
865 NetLog* net_log) 865 NetLog* net_log)
866 : resolver_(resolver), 866 : resolver_(resolver),
867 next_config_id_(1), 867 next_config_id_(1),
868 current_state_(STATE_NONE) , 868 current_state_(STATE_NONE) ,
869 net_log_(net_log), 869 net_log_(net_log),
870 stall_proxy_auto_config_delay_(TimeDelta::FromMilliseconds( 870 stall_proxy_auto_config_delay_(TimeDelta::FromMilliseconds(
871 kDelayAfterNetworkChangesMs)) { 871 kDelayAfterNetworkChangesMs)) {
872 NetworkChangeNotifier::AddIPAddressObserver(this); 872 NetworkChangeNotifier::AddNetworkChangeObserver(this);
873 NetworkChangeNotifier::AddDNSObserver(this); 873 NetworkChangeNotifier::AddDNSObserver(this);
874 ResetConfigService(config_service); 874 ResetConfigService(config_service);
875 } 875 }
876 876
877 // static 877 // static
878 ProxyService* ProxyService::CreateUsingSystemProxyResolver( 878 ProxyService* ProxyService::CreateUsingSystemProxyResolver(
879 ProxyConfigService* proxy_config_service, 879 ProxyConfigService* proxy_config_service,
880 size_t num_pac_threads, 880 size_t num_pac_threads,
881 NetLog* net_log) { 881 NetLog* net_log) {
882 DCHECK(proxy_config_service); 882 DCHECK(proxy_config_service);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 return ERR_IO_PENDING; // Must submit the request to the proxy resolver. 1018 return ERR_IO_PENDING; // Must submit the request to the proxy resolver.
1019 1019
1020 // Use the manual proxy settings. 1020 // Use the manual proxy settings.
1021 config_.proxy_rules().Apply(url, result); 1021 config_.proxy_rules().Apply(url, result);
1022 result->config_source_ = config_.source(); 1022 result->config_source_ = config_.source();
1023 result->config_id_ = config_.id(); 1023 result->config_id_ = config_.id();
1024 return OK; 1024 return OK;
1025 } 1025 }
1026 1026
1027 ProxyService::~ProxyService() { 1027 ProxyService::~ProxyService() {
1028 NetworkChangeNotifier::RemoveIPAddressObserver(this); 1028 NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
1029 NetworkChangeNotifier::RemoveDNSObserver(this); 1029 NetworkChangeNotifier::RemoveDNSObserver(this);
1030 config_service_->RemoveObserver(this); 1030 config_service_->RemoveObserver(this);
1031 1031
1032 // Cancel any inprogress requests. 1032 // Cancel any inprogress requests.
1033 for (PendingRequests::iterator it = pending_requests_.begin(); 1033 for (PendingRequests::iterator it = pending_requests_.begin();
1034 it != pending_requests_.end(); 1034 it != pending_requests_.end();
1035 ++it) { 1035 ++it) {
1036 (*it)->Cancel(); 1036 (*it)->Cancel();
1037 } 1037 }
1038 } 1038 }
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 effective_config, 1475 effective_config,
1476 decider_result, 1476 decider_result,
1477 script_data, 1477 script_data,
1478 base::Bind(&ProxyService::OnInitProxyResolverComplete, 1478 base::Bind(&ProxyService::OnInitProxyResolverComplete,
1479 base::Unretained(this))); 1479 base::Unretained(this)));
1480 1480
1481 if (rv != ERR_IO_PENDING) 1481 if (rv != ERR_IO_PENDING)
1482 OnInitProxyResolverComplete(rv); 1482 OnInitProxyResolverComplete(rv);
1483 } 1483 }
1484 1484
1485 void ProxyService::OnIPAddressChanged() { 1485 void ProxyService::OnNetworkChanged(
1486 net::NetworkChangeNotifier::ConnectionType type) {
1487 if (type != net::NetworkChangeNotifier::CONNECTION_NONE)
szym 2013/01/20 06:52:08 Same concern as before in AddressTrackerPosix.
1488 return;
1486 // See the comment block by |kDelayAfterNetworkChangesMs| for info. 1489 // See the comment block by |kDelayAfterNetworkChangesMs| for info.
1487 stall_proxy_autoconfig_until_ = 1490 stall_proxy_autoconfig_until_ =
1488 TimeTicks::Now() + stall_proxy_auto_config_delay_; 1491 TimeTicks::Now() + stall_proxy_auto_config_delay_;
1489 1492
1490 State previous_state = ResetProxyConfig(false); 1493 State previous_state = ResetProxyConfig(false);
1491 if (previous_state != STATE_NONE) 1494 if (previous_state != STATE_NONE)
1492 ApplyProxyConfigIfAvailable(); 1495 ApplyProxyConfigIfAvailable();
1493 } 1496 }
1494 1497
1495 void ProxyService::OnDNSChanged() { 1498 void ProxyService::OnDNSChanged() {
1496 OnIPAddressChanged(); 1499 OnNetworkChanged(net::NetworkChangeNotifier::CONNECTION_NONE);
1497 } 1500 }
1498 1501
1499 SyncProxyServiceHelper::SyncProxyServiceHelper(MessageLoop* io_message_loop, 1502 SyncProxyServiceHelper::SyncProxyServiceHelper(MessageLoop* io_message_loop,
1500 ProxyService* proxy_service) 1503 ProxyService* proxy_service)
1501 : io_message_loop_(io_message_loop), 1504 : io_message_loop_(io_message_loop),
1502 proxy_service_(proxy_service), 1505 proxy_service_(proxy_service),
1503 event_(false, false), 1506 event_(false, false),
1504 ALLOW_THIS_IN_INITIALIZER_LIST(callback_( 1507 ALLOW_THIS_IN_INITIALIZER_LIST(callback_(
1505 base::Bind(&SyncProxyServiceHelper::OnCompletion, 1508 base::Bind(&SyncProxyServiceHelper::OnCompletion,
1506 base::Unretained(this)))) { 1509 base::Unretained(this)))) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1561 OnCompletion(result_); 1564 OnCompletion(result_);
1562 } 1565 }
1563 } 1566 }
1564 1567
1565 void SyncProxyServiceHelper::OnCompletion(int rv) { 1568 void SyncProxyServiceHelper::OnCompletion(int rv) {
1566 result_ = rv; 1569 result_ = rv;
1567 event_.Signal(); 1570 event_.Signal();
1568 } 1571 }
1569 1572
1570 } // namespace net 1573 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698