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/http/http_stream_factory_impl_job.h" | 5 #include "net/http/http_stream_factory_impl_job.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 // static | 534 // static |
535 int HttpStreamFactoryImpl::Job::OnHostResolution( | 535 int HttpStreamFactoryImpl::Job::OnHostResolution( |
536 SpdySessionPool* spdy_session_pool, | 536 SpdySessionPool* spdy_session_pool, |
537 const SpdySessionKey& spdy_session_key, | 537 const SpdySessionKey& spdy_session_key, |
538 const GURL& origin_url, | 538 const GURL& origin_url, |
539 const AddressList& addresses, | 539 const AddressList& addresses, |
540 const NetLogWithSource& net_log) { | 540 const NetLogWithSource& net_log) { |
541 // It is OK to dereference spdy_session_pool, because the | 541 // It is OK to dereference spdy_session_pool, because the |
542 // ClientSocketPoolManager will be destroyed in the same callback that | 542 // ClientSocketPoolManager will be destroyed in the same callback that |
543 // destroys the SpdySessionPool. | 543 // destroys the SpdySessionPool. |
544 return spdy_session_pool->FindAvailableSession(spdy_session_key, origin_url, | 544 return spdy_session_pool->FindAvailableSession( |
545 net_log) | 545 spdy_session_key, origin_url, /* enable_ip_based_pooling = */ true, |
| 546 net_log) |
546 ? ERR_SPDY_SESSION_ALREADY_EXISTS | 547 ? ERR_SPDY_SESSION_ALREADY_EXISTS |
547 : OK; | 548 : OK; |
548 } | 549 } |
549 | 550 |
550 void HttpStreamFactoryImpl::Job::OnIOComplete(int result) { | 551 void HttpStreamFactoryImpl::Job::OnIOComplete(int result) { |
551 TRACE_EVENT0(kNetTracingCategory, "HttpStreamFactoryImpl::Job::OnIOComplete"); | 552 TRACE_EVENT0(kNetTracingCategory, "HttpStreamFactoryImpl::Job::OnIOComplete"); |
552 RunLoop(result); | 553 RunLoop(result); |
553 } | 554 } |
554 | 555 |
555 int HttpStreamFactoryImpl::Job::RunLoop(int result) { | 556 int HttpStreamFactoryImpl::Job::RunLoop(int result) { |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 return rv; | 946 return rv; |
946 } | 947 } |
947 | 948 |
948 SpdySessionKey spdy_session_key = GetSpdySessionKey(); | 949 SpdySessionKey spdy_session_key = GetSpdySessionKey(); |
949 | 950 |
950 // Check first if we have a spdy session for this group. If so, then go | 951 // Check first if we have a spdy session for this group. If so, then go |
951 // straight to using that. | 952 // straight to using that. |
952 if (CanUseExistingSpdySession()) { | 953 if (CanUseExistingSpdySession()) { |
953 base::WeakPtr<SpdySession> spdy_session = | 954 base::WeakPtr<SpdySession> spdy_session = |
954 session_->spdy_session_pool()->FindAvailableSession( | 955 session_->spdy_session_pool()->FindAvailableSession( |
955 spdy_session_key, origin_url_, net_log_); | 956 spdy_session_key, origin_url_, /* enable_ip_based_pooling = */ true, |
| 957 net_log_); |
956 if (spdy_session) { | 958 if (spdy_session) { |
957 // If we're preconnecting, but we already have a SpdySession, we don't | 959 // If we're preconnecting, but we already have a SpdySession, we don't |
958 // actually need to preconnect any sockets, so we're done. | 960 // actually need to preconnect any sockets, so we're done. |
959 if (job_type_ == PRECONNECT) | 961 if (job_type_ == PRECONNECT) |
960 return OK; | 962 return OK; |
961 using_spdy_ = true; | 963 using_spdy_ = true; |
962 next_state_ = STATE_CREATE_STREAM; | 964 next_state_ = STATE_CREATE_STREAM; |
963 existing_spdy_session_ = spdy_session; | 965 existing_spdy_session_ = spdy_session; |
964 return OK; | 966 return OK; |
965 } | 967 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1027 DCHECK_EQ(OK, result); | 1029 DCHECK_EQ(OK, result); |
1028 return OK; | 1030 return OK; |
1029 } | 1031 } |
1030 | 1032 |
1031 if (result == ERR_SPDY_SESSION_ALREADY_EXISTS) { | 1033 if (result == ERR_SPDY_SESSION_ALREADY_EXISTS) { |
1032 // We found a SPDY connection after resolving the host. This is | 1034 // We found a SPDY connection after resolving the host. This is |
1033 // probably an IP pooled connection. | 1035 // probably an IP pooled connection. |
1034 SpdySessionKey spdy_session_key = GetSpdySessionKey(); | 1036 SpdySessionKey spdy_session_key = GetSpdySessionKey(); |
1035 existing_spdy_session_ = | 1037 existing_spdy_session_ = |
1036 session_->spdy_session_pool()->FindAvailableSession( | 1038 session_->spdy_session_pool()->FindAvailableSession( |
1037 spdy_session_key, origin_url_, net_log_); | 1039 spdy_session_key, origin_url_, |
| 1040 /* enable_ip_based_pooling = */ true, net_log_); |
1038 if (existing_spdy_session_) { | 1041 if (existing_spdy_session_) { |
1039 using_spdy_ = true; | 1042 using_spdy_ = true; |
1040 next_state_ = STATE_CREATE_STREAM; | 1043 next_state_ = STATE_CREATE_STREAM; |
1041 } else { | 1044 } else { |
1042 // It is possible that the spdy session no longer exists. | 1045 // It is possible that the spdy session no longer exists. |
1043 ReturnToStateInitConnection(true /* close connection */); | 1046 ReturnToStateInitConnection(true /* close connection */); |
1044 } | 1047 } |
1045 return OK; | 1048 return OK; |
1046 } | 1049 } |
1047 | 1050 |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1239 } | 1242 } |
1240 return OK; | 1243 return OK; |
1241 } | 1244 } |
1242 | 1245 |
1243 CHECK(!stream_.get()); | 1246 CHECK(!stream_.get()); |
1244 | 1247 |
1245 SpdySessionKey spdy_session_key = GetSpdySessionKey(); | 1248 SpdySessionKey spdy_session_key = GetSpdySessionKey(); |
1246 if (!existing_spdy_session_) { | 1249 if (!existing_spdy_session_) { |
1247 existing_spdy_session_ = | 1250 existing_spdy_session_ = |
1248 session_->spdy_session_pool()->FindAvailableSession( | 1251 session_->spdy_session_pool()->FindAvailableSession( |
1249 spdy_session_key, origin_url_, net_log_); | 1252 spdy_session_key, origin_url_, |
| 1253 /* enable_ip_based_pooling = */ true, net_log_); |
1250 } | 1254 } |
1251 bool direct = !IsHttpsProxyAndHttpUrl(); | 1255 bool direct = !IsHttpsProxyAndHttpUrl(); |
1252 if (existing_spdy_session_.get()) { | 1256 if (existing_spdy_session_.get()) { |
1253 // We picked up an existing session, so we don't need our socket. | 1257 // We picked up an existing session, so we don't need our socket. |
1254 if (connection_->socket()) | 1258 if (connection_->socket()) |
1255 connection_->socket()->Disconnect(); | 1259 connection_->socket()->Disconnect(); |
1256 connection_->Reset(); | 1260 connection_->Reset(); |
1257 | 1261 |
1258 int set_result = SetSpdyHttpStreamOrBidirectionalStreamImpl( | 1262 int set_result = SetSpdyHttpStreamOrBidirectionalStreamImpl( |
1259 existing_spdy_session_, direct); | 1263 existing_spdy_session_, direct); |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1551 | 1555 |
1552 ConnectionAttempts socket_attempts = connection_->connection_attempts(); | 1556 ConnectionAttempts socket_attempts = connection_->connection_attempts(); |
1553 if (connection_->socket()) { | 1557 if (connection_->socket()) { |
1554 connection_->socket()->GetConnectionAttempts(&socket_attempts); | 1558 connection_->socket()->GetConnectionAttempts(&socket_attempts); |
1555 } | 1559 } |
1556 | 1560 |
1557 delegate_->AddConnectionAttemptsToRequest(this, socket_attempts); | 1561 delegate_->AddConnectionAttemptsToRequest(this, socket_attempts); |
1558 } | 1562 } |
1559 | 1563 |
1560 } // namespace net | 1564 } // namespace net |
OLD | NEW |