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

Side by Side Diff: net/http/http_stream_factory_impl_job.cc

Issue 208663003: Revert of Fix SPDY error-handling if the connection gets closed just after use. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_proxy_client_socket_pool.cc ('k') | net/http/http_stream_factory_impl_request.h » ('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) 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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 using_spdy(), 327 using_spdy(),
328 net_log_); 328 net_log_);
329 request_->OnWebSocketHandshakeStreamReady(this, 329 request_->OnWebSocketHandshakeStreamReady(this,
330 server_ssl_config_, 330 server_ssl_config_,
331 proxy_info_, 331 proxy_info_,
332 websocket_stream_.release()); 332 websocket_stream_.release());
333 // |this| may be deleted after this call. 333 // |this| may be deleted after this call.
334 } 334 }
335 335
336 void HttpStreamFactoryImpl::Job::OnNewSpdySessionReadyCallback() { 336 void HttpStreamFactoryImpl::Job::OnNewSpdySessionReadyCallback() {
337 DCHECK(stream_.get()); 337 DCHECK(!stream_.get());
338 DCHECK(!IsPreconnecting()); 338 DCHECK(!IsPreconnecting());
339 DCHECK(using_spdy()); 339 DCHECK(using_spdy());
340 // Note: an event loop iteration has passed, so |new_spdy_session_| may be 340 if (!new_spdy_session_)
341 // NULL at this point if the SpdySession closed immediately after creation. 341 return;
342 base::WeakPtr<SpdySession> spdy_session = new_spdy_session_; 342 base::WeakPtr<SpdySession> spdy_session = new_spdy_session_;
343 new_spdy_session_.reset(); 343 new_spdy_session_.reset();
344 if (IsOrphaned()) { 344 if (IsOrphaned()) {
345 if (spdy_session) { 345 stream_factory_->OnNewSpdySessionReady(
346 stream_factory_->OnNewSpdySessionReady( 346 spdy_session, spdy_session_direct_, server_ssl_config_, proxy_info_,
347 spdy_session, spdy_session_direct_, server_ssl_config_, proxy_info_, 347 was_npn_negotiated(), protocol_negotiated(), using_spdy(), net_log_);
348 was_npn_negotiated(), protocol_negotiated(), using_spdy(), net_log_);
349 }
350 stream_factory_->OnOrphanedJobComplete(this); 348 stream_factory_->OnOrphanedJobComplete(this);
351 } else { 349 } else {
352 request_->OnNewSpdySessionReady( 350 request_->OnNewSpdySessionReady(this, spdy_session, spdy_session_direct_);
353 this, stream_.Pass(), spdy_session, spdy_session_direct_);
354 } 351 }
355 // |this| may be deleted after this call. 352 // |this| may be deleted after this call.
356 } 353 }
357 354
358 void HttpStreamFactoryImpl::Job::OnStreamFailedCallback(int result) { 355 void HttpStreamFactoryImpl::Job::OnStreamFailedCallback(int result) {
359 DCHECK(!IsPreconnecting()); 356 DCHECK(!IsPreconnecting());
360 if (IsOrphaned()) 357 if (IsOrphaned())
361 stream_factory_->OnOrphanedJobComplete(this); 358 stream_factory_->OnOrphanedJobComplete(this);
362 else 359 else
363 request_->OnStreamFailed(this, result, server_ssl_config_); 360 request_->OnStreamFailed(this, result, server_ssl_config_);
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 if (existing_spdy_session_.get()) { 1115 if (existing_spdy_session_.get()) {
1119 // We picked up an existing session, so we don't need our socket. 1116 // We picked up an existing session, so we don't need our socket.
1120 if (connection_->socket()) 1117 if (connection_->socket())
1121 connection_->socket()->Disconnect(); 1118 connection_->socket()->Disconnect();
1122 connection_->Reset(); 1119 connection_->Reset();
1123 std::swap(spdy_session, existing_spdy_session_); 1120 std::swap(spdy_session, existing_spdy_session_);
1124 } else { 1121 } else {
1125 SpdySessionPool* spdy_pool = session_->spdy_session_pool(); 1122 SpdySessionPool* spdy_pool = session_->spdy_session_pool();
1126 spdy_session = spdy_pool->FindAvailableSession(spdy_session_key, net_log_); 1123 spdy_session = spdy_pool->FindAvailableSession(spdy_session_key, net_log_);
1127 if (!spdy_session) { 1124 if (!spdy_session) {
1128 new_spdy_session_ = 1125 int error =
1129 spdy_pool->CreateAvailableSessionFromSocket(spdy_session_key, 1126 spdy_pool->CreateAvailableSessionFromSocket(spdy_session_key,
1130 connection_.Pass(), 1127 connection_.Pass(),
1131 net_log_, 1128 net_log_,
1132 spdy_certificate_error_, 1129 spdy_certificate_error_,
1130 &new_spdy_session_,
1133 using_ssl_); 1131 using_ssl_);
1132 if (error != OK)
1133 return error;
1134 const HostPortPair& host_port_pair = spdy_session_key.host_port_pair(); 1134 const HostPortPair& host_port_pair = spdy_session_key.host_port_pair();
1135 base::WeakPtr<HttpServerProperties> http_server_properties = 1135 base::WeakPtr<HttpServerProperties> http_server_properties =
1136 session_->http_server_properties(); 1136 session_->http_server_properties();
1137 if (http_server_properties) 1137 if (http_server_properties)
1138 http_server_properties->SetSupportsSpdy(host_port_pair, true); 1138 http_server_properties->SetSupportsSpdy(host_port_pair, true);
1139 spdy_session_direct_ = direct; 1139 spdy_session_direct_ = direct;
1140
1141 // Create a SpdyHttpStream attached to the session;
1142 // OnNewSpdySessionReadyCallback is not called until an event loop
1143 // iteration later, so if the SpdySession is closed between then, allow
1144 // reuse state from the underlying socket, sampled by SpdyHttpStream,
1145 // bubble up to the request.
1146 bool use_relative_url = direct || request_info_.url.SchemeIs("https");
1147 stream_.reset(new SpdyHttpStream(new_spdy_session_, use_relative_url));
1148
1149 return OK; 1140 return OK;
1150 } 1141 }
1151 } 1142 }
1152 1143
1153 if (!spdy_session) 1144 if (!spdy_session)
1154 return ERR_CONNECTION_CLOSED; 1145 return ERR_CONNECTION_CLOSED;
1155 1146
1156 // TODO(willchan): Delete this code, because eventually, the 1147 // TODO(willchan): Delete this code, because eventually, the
1157 // HttpStreamFactoryImpl will be creating all the SpdyHttpStreams, since it 1148 // HttpStreamFactoryImpl will be creating all the SpdyHttpStreams, since it
1158 // will know when SpdySessions become available. 1149 // will know when SpdySessions become available.
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1483 (net::LOAD_MAIN_FRAME | net::LOAD_SUB_FRAME | net::LOAD_PREFETCH | 1474 (net::LOAD_MAIN_FRAME | net::LOAD_SUB_FRAME | net::LOAD_PREFETCH |
1484 net::LOAD_IS_DOWNLOAD)) { 1475 net::LOAD_IS_DOWNLOAD)) {
1485 // Avoid pipelining resources that may be streamed for a long time. 1476 // Avoid pipelining resources that may be streamed for a long time.
1486 return false; 1477 return false;
1487 } 1478 }
1488 return stream_factory_->http_pipelined_host_pool_.IsKeyEligibleForPipelining( 1479 return stream_factory_->http_pipelined_host_pool_.IsKeyEligibleForPipelining(
1489 *http_pipelining_key_.get()); 1480 *http_pipelining_key_.get());
1490 } 1481 }
1491 1482
1492 } // namespace net 1483 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_proxy_client_socket_pool.cc ('k') | net/http/http_stream_factory_impl_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698