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

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

Issue 7289006: Basic HTTP pipelining support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix trybot issues Created 9 years, 2 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 21 matching lines...) Expand all
32 #include "net/http/http_auth_handler.h" 32 #include "net/http/http_auth_handler.h"
33 #include "net/http/http_auth_handler_factory.h" 33 #include "net/http/http_auth_handler_factory.h"
34 #include "net/http/http_basic_stream.h" 34 #include "net/http/http_basic_stream.h"
35 #include "net/http/http_chunked_decoder.h" 35 #include "net/http/http_chunked_decoder.h"
36 #include "net/http/http_net_log_params.h" 36 #include "net/http/http_net_log_params.h"
37 #include "net/http/http_network_session.h" 37 #include "net/http/http_network_session.h"
38 #include "net/http/http_proxy_client_socket.h" 38 #include "net/http/http_proxy_client_socket.h"
39 #include "net/http/http_proxy_client_socket_pool.h" 39 #include "net/http/http_proxy_client_socket_pool.h"
40 #include "net/http/http_request_headers.h" 40 #include "net/http/http_request_headers.h"
41 #include "net/http/http_request_info.h" 41 #include "net/http/http_request_info.h"
42 #include "net/http/http_response_body_drainer.h"
43 #include "net/http/http_response_headers.h" 42 #include "net/http/http_response_headers.h"
44 #include "net/http/http_response_info.h" 43 #include "net/http/http_response_info.h"
45 #include "net/http/http_server_properties.h" 44 #include "net/http/http_server_properties.h"
46 #include "net/http/http_stream_factory.h" 45 #include "net/http/http_stream_factory.h"
47 #include "net/http/http_util.h" 46 #include "net/http/http_util.h"
48 #include "net/http/url_security_manager.h" 47 #include "net/http/url_security_manager.h"
49 #include "net/socket/client_socket_factory.h" 48 #include "net/socket/client_socket_factory.h"
50 #include "net/socket/socks_client_socket_pool.h" 49 #include "net/socket/socks_client_socket_pool.h"
51 #include "net/socket/ssl_client_socket.h" 50 #include "net/socket/ssl_client_socket.h"
52 #include "net/socket/ssl_client_socket_pool.h" 51 #include "net/socket/ssl_client_socket_pool.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 stream_->Close(true /* not reusable */); 129 stream_->Close(true /* not reusable */);
131 } else { 130 } else {
132 if (stream_->IsResponseBodyComplete()) { 131 if (stream_->IsResponseBodyComplete()) {
133 // If the response body is complete, we can just reuse the socket. 132 // If the response body is complete, we can just reuse the socket.
134 stream_->Close(false /* reusable */); 133 stream_->Close(false /* reusable */);
135 } else if (stream_->IsSpdyHttpStream()) { 134 } else if (stream_->IsSpdyHttpStream()) {
136 // Doesn't really matter for SpdyHttpStream. Just close it. 135 // Doesn't really matter for SpdyHttpStream. Just close it.
137 stream_->Close(true /* not reusable */); 136 stream_->Close(true /* not reusable */);
138 } else { 137 } else {
139 // Otherwise, we try to drain the response body. 138 // Otherwise, we try to drain the response body.
140 // TODO(willchan): Consider moving this response body draining to the 139 HttpStream* stream = stream_.release();
141 // stream implementation. For SPDY, there's clearly no point. For 140 stream->Drain(session_);
142 // HTTP, it can vary depending on whether or not we're pipelining. It's
143 // stream dependent, so the different subtypes should be implementing
144 // their solutions.
145 HttpResponseBodyDrainer* drainer =
146 new HttpResponseBodyDrainer(stream_.release());
147 drainer->Start(session_);
148 // |drainer| will delete itself.
149 } 141 }
150 } 142 }
151 } 143 }
152 } 144 }
153 145
154 int HttpNetworkTransaction::Start(const HttpRequestInfo* request_info, 146 int HttpNetworkTransaction::Start(const HttpRequestInfo* request_info,
155 OldCompletionCallback* callback, 147 OldCompletionCallback* callback,
156 const BoundNetLog& net_log) { 148 const BoundNetLog& net_log) {
157 SIMPLE_STATS_COUNTER("HttpNetworkTransaction.Count"); 149 SIMPLE_STATS_COUNTER("HttpNetworkTransaction.Count");
158 150
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 1183
1192 switch (error) { 1184 switch (error) {
1193 // If we try to reuse a connection that the server is in the process of 1185 // If we try to reuse a connection that the server is in the process of
1194 // closing, we may end up successfully writing out our request (or a 1186 // closing, we may end up successfully writing out our request (or a
1195 // portion of our request) only to find a connection error when we try to 1187 // portion of our request) only to find a connection error when we try to
1196 // read from (or finish writing to) the socket. 1188 // read from (or finish writing to) the socket.
1197 case ERR_CONNECTION_RESET: 1189 case ERR_CONNECTION_RESET:
1198 case ERR_CONNECTION_CLOSED: 1190 case ERR_CONNECTION_CLOSED:
1199 case ERR_CONNECTION_ABORTED: 1191 case ERR_CONNECTION_ABORTED:
1200 if (ShouldResendRequest(error)) { 1192 if (ShouldResendRequest(error)) {
1193 net_log_.AddEvent(
1194 NetLog::TYPE_HTTP_TRANSACTION_RESTART_AFTER_ERROR,
1195 make_scoped_refptr(new NetLogIntegerParameter("net_error", error)));
1201 ResetConnectionAndRequestForResend(); 1196 ResetConnectionAndRequestForResend();
1202 error = OK; 1197 error = OK;
1203 } 1198 }
1204 break; 1199 break;
1200 case ERR_PIPELINE_EVICTION:
1205 case ERR_SPDY_SERVER_REFUSED_STREAM: 1201 case ERR_SPDY_SERVER_REFUSED_STREAM:
1202 net_log_.AddEvent(
1203 NetLog::TYPE_HTTP_TRANSACTION_RESTART_AFTER_ERROR,
1204 make_scoped_refptr(new NetLogIntegerParameter("net_error", error)));
1206 ResetConnectionAndRequestForResend(); 1205 ResetConnectionAndRequestForResend();
1207 error = OK; 1206 error = OK;
1208 break; 1207 break;
1209 } 1208 }
1210 return error; 1209 return error;
1211 } 1210 }
1212 1211
1213 void HttpNetworkTransaction::ResetStateForRestart() { 1212 void HttpNetworkTransaction::ResetStateForRestart() {
1214 ResetStateForAuthRestart(); 1213 ResetStateForAuthRestart();
1215 stream_.reset(); 1214 stream_.reset();
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, 1341 description = base::StringPrintf("Unknown state 0x%08X (%u)", state,
1343 state); 1342 state);
1344 break; 1343 break;
1345 } 1344 }
1346 return description; 1345 return description;
1347 } 1346 }
1348 1347
1349 #undef STATE_CASE 1348 #undef STATE_CASE
1350 1349
1351 } // namespace net 1350 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698