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

Side by Side Diff: net/base/host_resolver_impl.cc

Issue 1615005: Flush socket pools and SPDY session pool properly on explicit requests and network changes. (Closed)
Patch Set: Fix minor leak. Created 10 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
« no previous file with comments | « net/base/host_resolver_impl.h ('k') | net/base/host_resolver_impl_unittest.cc » ('j') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/base/host_resolver_impl.h" 5 #include "net/base/host_resolver_impl.h"
6 #include "net/base/net_log.h" 6 #include "net/base/net_log.h"
7 7
8 #include <cmath> 8 #include <cmath>
9 #include <deque> 9 #include <deque>
10 10
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 ipv6_probe_monitoring_(false) { 672 ipv6_probe_monitoring_(false) {
673 DCHECK_GT(max_jobs, 0u); 673 DCHECK_GT(max_jobs, 0u);
674 674
675 // It is cumbersome to expose all of the constraints in the constructor, 675 // It is cumbersome to expose all of the constraints in the constructor,
676 // so we choose some defaults, which users can override later. 676 // so we choose some defaults, which users can override later.
677 job_pools_[POOL_NORMAL] = new JobPool(max_jobs, 100u * max_jobs); 677 job_pools_[POOL_NORMAL] = new JobPool(max_jobs, 100u * max_jobs);
678 678
679 #if defined(OS_WIN) 679 #if defined(OS_WIN)
680 EnsureWinsockInit(); 680 EnsureWinsockInit();
681 #endif 681 #endif
682 if (network_change_notifier_)
683 network_change_notifier_->AddObserver(this);
684 } 682 }
685 683
686 HostResolverImpl::~HostResolverImpl() { 684 HostResolverImpl::~HostResolverImpl() {
687 // Cancel the outstanding jobs. Those jobs may contain several attached 685 // Cancel the outstanding jobs. Those jobs may contain several attached
688 // requests, which will also be cancelled. 686 // requests, which will also be cancelled.
689 DiscardIPv6ProbeJob(); 687 DiscardIPv6ProbeJob();
690 688
691 for (JobMap::iterator it = jobs_.begin(); it != jobs_.end(); ++it) 689 for (JobMap::iterator it = jobs_.begin(); it != jobs_.end(); ++it)
692 it->second->Cancel(); 690 it->second->Cancel();
693 691
694 // In case we are being deleted during the processing of a callback. 692 // In case we are being deleted during the processing of a callback.
695 if (cur_completing_job_) 693 if (cur_completing_job_)
696 cur_completing_job_->Cancel(); 694 cur_completing_job_->Cancel();
697 695
698 if (network_change_notifier_)
699 network_change_notifier_->RemoveObserver(this);
700
701 // Delete the job pools. 696 // Delete the job pools.
702 for (size_t i = 0u; i < arraysize(job_pools_); ++i) 697 for (size_t i = 0u; i < arraysize(job_pools_); ++i)
703 delete job_pools_[i]; 698 delete job_pools_[i];
704 } 699 }
705 700
706 // TODO(eroman): Don't create cache entries for hostnames which are simply IP 701 // TODO(eroman): Don't create cache entries for hostnames which are simply IP
707 // address literals. 702 // address literals.
708 int HostResolverImpl::Resolve(const RequestInfo& info, 703 int HostResolverImpl::Resolve(const RequestInfo& info,
709 AddressList* addresses, 704 AddressList* addresses,
710 CompletionCallback* callback, 705 CompletionCallback* callback,
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 829
835 void HostResolverImpl::SetDefaultAddressFamily(AddressFamily address_family) { 830 void HostResolverImpl::SetDefaultAddressFamily(AddressFamily address_family) {
836 ipv6_probe_monitoring_ = false; 831 ipv6_probe_monitoring_ = false;
837 DiscardIPv6ProbeJob(); 832 DiscardIPv6ProbeJob();
838 default_address_family_ = address_family; 833 default_address_family_ = address_family;
839 } 834 }
840 835
841 void HostResolverImpl::ProbeIPv6Support() { 836 void HostResolverImpl::ProbeIPv6Support() {
842 DCHECK(!ipv6_probe_monitoring_); 837 DCHECK(!ipv6_probe_monitoring_);
843 ipv6_probe_monitoring_ = true; 838 ipv6_probe_monitoring_ = true;
844 OnIPAddressChanged(); // Give initial setup call. 839 Flush(); // Give initial setup call.
845 } 840 }
846 841
847 void HostResolverImpl::Shutdown() { 842 void HostResolverImpl::Shutdown() {
848 shutdown_ = true; 843 shutdown_ = true;
849 844
850 // Cancel the outstanding jobs. 845 // Cancel the outstanding jobs.
851 for (JobMap::iterator it = jobs_.begin(); it != jobs_.end(); ++it) 846 for (JobMap::iterator it = jobs_.begin(); it != jobs_.end(); ++it)
852 it->second->Cancel(); 847 it->second->Cancel();
853 jobs_.clear(); 848 jobs_.clear();
854 } 849 }
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 it != observers_.end(); ++it) { 1062 it != observers_.end(); ++it) {
1068 (*it)->OnCancelResolution(request_id, info); 1063 (*it)->OnCancelResolution(request_id, info);
1069 } 1064 }
1070 1065
1071 net_log.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONCANCEL); 1066 net_log.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONCANCEL);
1072 } 1067 }
1073 1068
1074 net_log.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL); 1069 net_log.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL);
1075 } 1070 }
1076 1071
1077 void HostResolverImpl::OnIPAddressChanged() { 1072 void HostResolverImpl::Flush() {
1078 if (cache_.get()) 1073 if (cache_.get())
1079 cache_->clear(); 1074 cache_->clear();
1080 if (ipv6_probe_monitoring_) { 1075 if (ipv6_probe_monitoring_) {
1081 DiscardIPv6ProbeJob(); 1076 DiscardIPv6ProbeJob();
1082 ipv6_probe_job_ = new IPv6ProbeJob(this); 1077 ipv6_probe_job_ = new IPv6ProbeJob(this);
1083 ipv6_probe_job_->Start(); 1078 ipv6_probe_job_->Start();
1084 } 1079 }
1085 } 1080 }
1086 1081
1087 void HostResolverImpl::DiscardIPv6ProbeJob() { 1082 void HostResolverImpl::DiscardIPv6ProbeJob() {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 if (r == req) 1179 if (r == req)
1185 return error; 1180 return error;
1186 1181
1187 r->OnComplete(error, AddressList()); 1182 r->OnComplete(error, AddressList());
1188 } 1183 }
1189 1184
1190 return ERR_IO_PENDING; 1185 return ERR_IO_PENDING;
1191 } 1186 }
1192 1187
1193 } // namespace net 1188 } // namespace net
OLDNEW
« no previous file with comments | « net/base/host_resolver_impl.h ('k') | net/base/host_resolver_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698