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

Side by Side Diff: net/socket/client_socket_pool_base.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/socket/client_socket_pool_base.h" 5 #include "net/socket/client_socket_pool_base.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 use_cleanup_timer_(g_cleanup_timer_enabled), 177 use_cleanup_timer_(g_cleanup_timer_enabled),
178 unused_idle_socket_timeout_(unused_idle_socket_timeout), 178 unused_idle_socket_timeout_(unused_idle_socket_timeout),
179 used_idle_socket_timeout_(used_idle_socket_timeout), 179 used_idle_socket_timeout_(used_idle_socket_timeout),
180 connect_job_factory_(connect_job_factory), 180 connect_job_factory_(connect_job_factory),
181 connect_backup_jobs_enabled_(false), 181 connect_backup_jobs_enabled_(false),
182 pool_generation_number_(0), 182 pool_generation_number_(0),
183 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { 183 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
184 DCHECK_LE(0, max_sockets_per_group); 184 DCHECK_LE(0, max_sockets_per_group);
185 DCHECK_LE(max_sockets_per_group, max_sockets); 185 DCHECK_LE(max_sockets_per_group, max_sockets);
186 186
187 NetworkChangeNotifier::AddIPAddressObserver(this); 187 NetworkChangeNotifier::AddNetworkChangeObserver(this);
188 } 188 }
189 189
190 ClientSocketPoolBaseHelper::~ClientSocketPoolBaseHelper() { 190 ClientSocketPoolBaseHelper::~ClientSocketPoolBaseHelper() {
191 // Clean up any idle sockets and pending connect jobs. Assert that we have no 191 // Clean up any idle sockets and pending connect jobs. Assert that we have no
192 // remaining active sockets or pending requests. They should have all been 192 // remaining active sockets or pending requests. They should have all been
193 // cleaned up prior to |this| being destroyed. 193 // cleaned up prior to |this| being destroyed.
194 FlushWithError(ERR_ABORTED); 194 FlushWithError(ERR_ABORTED);
195 DCHECK(group_map_.empty()); 195 DCHECK(group_map_.empty());
196 DCHECK(pending_callback_map_.empty()); 196 DCHECK(pending_callback_map_.empty());
197 DCHECK_EQ(0, connecting_socket_count_); 197 DCHECK_EQ(0, connecting_socket_count_);
198 CHECK(higher_layer_pools_.empty()); 198 CHECK(higher_layer_pools_.empty());
199 199
200 NetworkChangeNotifier::RemoveIPAddressObserver(this); 200 NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
201 } 201 }
202 202
203 ClientSocketPoolBaseHelper::CallbackResultPair::CallbackResultPair() 203 ClientSocketPoolBaseHelper::CallbackResultPair::CallbackResultPair()
204 : result(OK) { 204 : result(OK) {
205 } 205 }
206 206
207 ClientSocketPoolBaseHelper::CallbackResultPair::CallbackResultPair( 207 ClientSocketPoolBaseHelper::CallbackResultPair::CallbackResultPair(
208 const CompletionCallback& callback_in, int result_in) 208 const CompletionCallback& callback_in, int result_in)
209 : callback(callback_in), 209 : callback(callback_in),
210 result(result_in) { 210 result(result_in) {
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 } else { 903 } else {
904 RemoveConnectJob(job, group); 904 RemoveConnectJob(job, group);
905 } 905 }
906 if (!handed_out_socket) { 906 if (!handed_out_socket) {
907 OnAvailableSocketSlot(group_name, group); 907 OnAvailableSocketSlot(group_name, group);
908 CheckForStalledSocketGroups(); 908 CheckForStalledSocketGroups();
909 } 909 }
910 } 910 }
911 } 911 }
912 912
913 void ClientSocketPoolBaseHelper::OnIPAddressChanged() { 913 void ClientSocketPoolBaseHelper::OnNetworkChanged(
914 FlushWithError(ERR_NETWORK_CHANGED); 914 net::NetworkChangeNotifier::ConnectionType type) {
915 if (type == net::NetworkChangeNotifier::CONNECTION_NONE)
916 FlushWithError(ERR_NETWORK_CHANGED);
915 } 917 }
916 918
917 void ClientSocketPoolBaseHelper::FlushWithError(int error) { 919 void ClientSocketPoolBaseHelper::FlushWithError(int error) {
918 pool_generation_number_++; 920 pool_generation_number_++;
919 CancelAllConnectJobs(); 921 CancelAllConnectJobs();
920 CloseIdleSockets(); 922 CloseIdleSockets();
921 CancelAllRequestsWithError(error); 923 CancelAllRequestsWithError(error);
922 } 924 }
923 925
924 bool ClientSocketPoolBaseHelper::IsStalled() const { 926 bool ClientSocketPoolBaseHelper::IsStalled() const {
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 STLDeleteElements(&jobs_); 1241 STLDeleteElements(&jobs_);
1240 unassigned_job_count_ = 0; 1242 unassigned_job_count_ = 0;
1241 1243
1242 // Cancel pending backup job. 1244 // Cancel pending backup job.
1243 weak_factory_.InvalidateWeakPtrs(); 1245 weak_factory_.InvalidateWeakPtrs();
1244 } 1246 }
1245 1247
1246 } // namespace internal 1248 } // namespace internal
1247 1249
1248 } // namespace net 1250 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698