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

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: Better Close() handling and tests Created 9 years, 3 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_stream_factory.h" 44 #include "net/http/http_stream_factory.h"
46 #include "net/http/http_util.h" 45 #include "net/http/http_util.h"
47 #include "net/http/url_security_manager.h" 46 #include "net/http/url_security_manager.h"
48 #include "net/socket/client_socket_factory.h" 47 #include "net/socket/client_socket_factory.h"
49 #include "net/socket/socks_client_socket_pool.h" 48 #include "net/socket/socks_client_socket_pool.h"
50 #include "net/socket/ssl_client_socket.h" 49 #include "net/socket/ssl_client_socket.h"
51 #include "net/socket/ssl_client_socket_pool.h" 50 #include "net/socket/ssl_client_socket_pool.h"
52 #include "net/socket/transport_client_socket_pool.h" 51 #include "net/socket/transport_client_socket_pool.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 stream_->Close(true /* not reusable */); 125 stream_->Close(true /* not reusable */);
127 } else { 126 } else {
128 if (stream_->IsResponseBodyComplete()) { 127 if (stream_->IsResponseBodyComplete()) {
129 // If the response body is complete, we can just reuse the socket. 128 // If the response body is complete, we can just reuse the socket.
130 stream_->Close(false /* reusable */); 129 stream_->Close(false /* reusable */);
131 } else if (stream_->IsSpdyHttpStream()) { 130 } else if (stream_->IsSpdyHttpStream()) {
132 // Doesn't really matter for SpdyHttpStream. Just close it. 131 // Doesn't really matter for SpdyHttpStream. Just close it.
133 stream_->Close(true /* not reusable */); 132 stream_->Close(true /* not reusable */);
134 } else { 133 } else {
135 // Otherwise, we try to drain the response body. 134 // Otherwise, we try to drain the response body.
136 // TODO(willchan): Consider moving this response body draining to the 135 HttpStream* stream = stream_.release();
137 // stream implementation. For SPDY, there's clearly no point. For 136 stream->Drain(session_);
138 // HTTP, it can vary depending on whether or not we're pipelining. It's
139 // stream dependent, so the different subtypes should be implementing
140 // their solutions.
141 HttpResponseBodyDrainer* drainer =
142 new HttpResponseBodyDrainer(stream_.release());
143 drainer->Start(session_);
144 // |drainer| will delete itself.
145 } 137 }
146 } 138 }
147 } 139 }
148 } 140 }
149 141
150 int HttpNetworkTransaction::Start(const HttpRequestInfo* request_info, 142 int HttpNetworkTransaction::Start(const HttpRequestInfo* request_info,
151 CompletionCallback* callback, 143 CompletionCallback* callback,
152 const BoundNetLog& net_log) { 144 const BoundNetLog& net_log) {
153 SIMPLE_STATS_COUNTER("HttpNetworkTransaction.Count"); 145 SIMPLE_STATS_COUNTER("HttpNetworkTransaction.Count");
154 146
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 DCHECK(user_callback_); 464 DCHECK(user_callback_);
473 465
474 // Since Run may result in Read being called, clear user_callback_ up front. 466 // Since Run may result in Read being called, clear user_callback_ up front.
475 CompletionCallback* c = user_callback_; 467 CompletionCallback* c = user_callback_;
476 user_callback_ = NULL; 468 user_callback_ = NULL;
477 c->Run(rv); 469 c->Run(rv);
478 } 470 }
479 471
480 void HttpNetworkTransaction::OnIOComplete(int result) { 472 void HttpNetworkTransaction::OnIOComplete(int result) {
481 int rv = DoLoop(result); 473 int rv = DoLoop(result);
474 if (rv == ERR_PIPELINE_EVICTION) {
475 stream_->Close(false);
476 stream_.reset();
477 stream_request_.reset();
478 next_state_ = STATE_NONE;
479 RestartIgnoringLastError(user_callback_);
mmenke 2011/09/01 21:15:39 You want to return here. Otherwise, you'll pass t
James Simonsen 2011/09/07 21:20:10 Eek. Yep. Fixed. Added test cases for the transact
480 }
482 if (rv != ERR_IO_PENDING) 481 if (rv != ERR_IO_PENDING)
483 DoCallback(rv); 482 DoCallback(rv);
484 } 483 }
485 484
486 int HttpNetworkTransaction::DoLoop(int result) { 485 int HttpNetworkTransaction::DoLoop(int result) {
487 DCHECK(next_state_ != STATE_NONE); 486 DCHECK(next_state_ != STATE_NONE);
488 487
489 int rv = result; 488 int rv = result;
490 do { 489 do {
491 State state = next_state_; 490 State state = next_state_;
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, 1326 description = base::StringPrintf("Unknown state 0x%08X (%u)", state,
1328 state); 1327 state);
1329 break; 1328 break;
1330 } 1329 }
1331 return description; 1330 return description;
1332 } 1331 }
1333 1332
1334 #undef STATE_CASE 1333 #undef STATE_CASE
1335 1334
1336 } // namespace net 1335 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698