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

Side by Side Diff: net/socket/transport_client_socket_pool.cc

Issue 1006643002: Plumb connection attempts from (non-proxy) ConnectJobs to HttpNetworkTransaction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
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/transport_client_socket_pool.h" 5 #include "net/socket/transport_client_socket_pool.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 193
194 TransportConnectJob::TransportConnectJob( 194 TransportConnectJob::TransportConnectJob(
195 const std::string& group_name, 195 const std::string& group_name,
196 RequestPriority priority, 196 RequestPriority priority,
197 const scoped_refptr<TransportSocketParams>& params, 197 const scoped_refptr<TransportSocketParams>& params,
198 base::TimeDelta timeout_duration, 198 base::TimeDelta timeout_duration,
199 ClientSocketFactory* client_socket_factory, 199 ClientSocketFactory* client_socket_factory,
200 HostResolver* host_resolver, 200 HostResolver* host_resolver,
201 Delegate* delegate, 201 Delegate* delegate,
202 NetLog* net_log) 202 NetLog* net_log)
203 : ConnectJob(group_name, timeout_duration, priority, delegate, 203 : ConnectJob(group_name,
204 timeout_duration,
205 priority,
206 delegate,
204 BoundNetLog::Make(net_log, NetLog::SOURCE_CONNECT_JOB)), 207 BoundNetLog::Make(net_log, NetLog::SOURCE_CONNECT_JOB)),
205 helper_(params, client_socket_factory, host_resolver, &connect_timing_), 208 helper_(params, client_socket_factory, host_resolver, &connect_timing_),
206 interval_between_connects_(CONNECT_INTERVAL_GT_20MS) { 209 interval_between_connects_(CONNECT_INTERVAL_GT_20MS),
210 connect_result_(OK) {
207 helper_.SetOnIOComplete(this); 211 helper_.SetOnIOComplete(this);
208 } 212 }
209 213
210 TransportConnectJob::~TransportConnectJob() { 214 TransportConnectJob::~TransportConnectJob() {
211 // We don't worry about cancelling the host resolution and TCP connect, since 215 // We don't worry about cancelling the host resolution and TCP connect, since
212 // ~SingleRequestHostResolver and ~StreamSocket will take care of it. 216 // ~SingleRequestHostResolver and ~StreamSocket will take care of it.
213 } 217 }
214 218
215 LoadState TransportConnectJob::GetLoadState() const { 219 LoadState TransportConnectJob::GetLoadState() const {
216 switch (helper_.next_state()) { 220 switch (helper_.next_state()) {
217 case TransportConnectJobHelper::STATE_RESOLVE_HOST: 221 case TransportConnectJobHelper::STATE_RESOLVE_HOST:
218 case TransportConnectJobHelper::STATE_RESOLVE_HOST_COMPLETE: 222 case TransportConnectJobHelper::STATE_RESOLVE_HOST_COMPLETE:
219 return LOAD_STATE_RESOLVING_HOST; 223 return LOAD_STATE_RESOLVING_HOST;
220 case TransportConnectJobHelper::STATE_TRANSPORT_CONNECT: 224 case TransportConnectJobHelper::STATE_TRANSPORT_CONNECT:
221 case TransportConnectJobHelper::STATE_TRANSPORT_CONNECT_COMPLETE: 225 case TransportConnectJobHelper::STATE_TRANSPORT_CONNECT_COMPLETE:
222 return LOAD_STATE_CONNECTING; 226 return LOAD_STATE_CONNECTING;
223 case TransportConnectJobHelper::STATE_NONE: 227 case TransportConnectJobHelper::STATE_NONE:
224 return LOAD_STATE_IDLE; 228 return LOAD_STATE_IDLE;
225 } 229 }
226 NOTREACHED(); 230 NOTREACHED();
227 return LOAD_STATE_IDLE; 231 return LOAD_STATE_IDLE;
228 } 232 }
229 233
234 void TransportConnectJob::GetAdditionalErrorState(ClientSocketHandle* handle) {
235 // If the actual socket Connect call failed, record the result and the last
236 // address attempted.
237 // TODO(ttuttle): Plumb into the socket layer and record *all* attempts.
238 if (connect_result_ != OK) {
Ryan Hamilton 2015/03/12 20:06:04 nit: early return for the win if (connect_result_
Deprecated (see juliatuttle) 2015/03/16 15:53:54 Done.
239 DCHECK_LT(0u, helper_.addresses().size());
240 ClientSocketHandle::ConnectionAttempt attempt;
241 attempt.endpoint = helper_.addresses().back();
242 attempt.result = connect_result_;
Ryan Hamilton 2015/03/12 20:06:04 consider adding a 2 arg constructor to ConnectionA
Deprecated (see juliatuttle) 2015/03/16 15:53:54 Done.
243 std::vector<ClientSocketHandle::ConnectionAttempt> attempts;
Ryan Hamilton 2015/03/12 20:06:04 Consider using a typdef to make this expression so
Deprecated (see juliatuttle) 2015/03/16 15:53:54 Done.
244 attempts.push_back(attempt);
245 handle->set_connection_attempts(attempts);
246 }
247 }
248
230 // static 249 // static
231 void TransportConnectJob::MakeAddressListStartWithIPv4(AddressList* list) { 250 void TransportConnectJob::MakeAddressListStartWithIPv4(AddressList* list) {
232 for (AddressList::iterator i = list->begin(); i != list->end(); ++i) { 251 for (AddressList::iterator i = list->begin(); i != list->end(); ++i) {
233 if (i->GetFamily() == ADDRESS_FAMILY_IPV4) { 252 if (i->GetFamily() == ADDRESS_FAMILY_IPV4) {
234 std::rotate(list->begin(), i, list->end()); 253 std::rotate(list->begin(), i, list->end());
235 break; 254 break;
236 } 255 }
237 } 256 }
238 } 257 }
239 258
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 } 402 }
384 403
385 SetSocket(transport_socket_.Pass()); 404 SetSocket(transport_socket_.Pass());
386 fallback_timer_.Stop(); 405 fallback_timer_.Stop();
387 } else { 406 } else {
388 // Be a bit paranoid and kill off the fallback members to prevent reuse. 407 // Be a bit paranoid and kill off the fallback members to prevent reuse.
389 fallback_transport_socket_.reset(); 408 fallback_transport_socket_.reset();
390 fallback_addresses_.reset(); 409 fallback_addresses_.reset();
391 } 410 }
392 411
412 connect_result_ = result;
413
393 return result; 414 return result;
394 } 415 }
395 416
396 void TransportConnectJob::DoIPv6FallbackTransportConnect() { 417 void TransportConnectJob::DoIPv6FallbackTransportConnect() {
397 // The timer should only fire while we're waiting for the main connect to 418 // The timer should only fire while we're waiting for the main connect to
398 // succeed. 419 // succeed.
399 if (helper_.next_state() != 420 if (helper_.next_state() !=
400 TransportConnectJobHelper::STATE_TRANSPORT_CONNECT_COMPLETE) { 421 TransportConnectJobHelper::STATE_TRANSPORT_CONNECT_COMPLETE) {
401 NOTREACHED(); 422 NOTREACHED();
402 return; 423 return;
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 HigherLayeredPool* higher_pool) { 616 HigherLayeredPool* higher_pool) {
596 base_.AddHigherLayeredPool(higher_pool); 617 base_.AddHigherLayeredPool(higher_pool);
597 } 618 }
598 619
599 void TransportClientSocketPool::RemoveHigherLayeredPool( 620 void TransportClientSocketPool::RemoveHigherLayeredPool(
600 HigherLayeredPool* higher_pool) { 621 HigherLayeredPool* higher_pool) {
601 base_.RemoveHigherLayeredPool(higher_pool); 622 base_.RemoveHigherLayeredPool(higher_pool);
602 } 623 }
603 624
604 } // namespace net 625 } // namespace net
OLDNEW
« net/socket/ssl_client_socket_pool.cc ('K') | « net/socket/transport_client_socket_pool.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698