summaryrefslogtreecommitdiffstats
path: root/net/http/http_network_transaction.cc
diff options
context:
space:
mode:
authorgavinp@google.com <gavinp@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-17 00:58:44 +0000
committergavinp@google.com <gavinp@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-17 00:58:44 +0000
commit2bd930265ee663668e49d41eb35fddd94934eae2 (patch)
tree995f47c031908b58b5780b228fa405de1b0ff407 /net/http/http_network_transaction.cc
parent485cd456a503e6698c75ea6185ed93de832d493a (diff)
downloadchromium_src-2bd930265ee663668e49d41eb35fddd94934eae2.zip
chromium_src-2bd930265ee663668e49d41eb35fddd94934eae2.tar.gz
chromium_src-2bd930265ee663668e49d41eb35fddd94934eae2.tar.bz2
Implement MAX_CONCURRENT_STREAMS SETTINGS header
This CL helps chrome respect the SETTINGS header MAX_CONCURRENT_STREAMS. Note that this means that SpdySession::CreateStream can now return ERR_IO_PENDING, so it requires a callback. There's a noted TODO that if an http_network_transaction dissapears betweeen STATE_SPDY_GET_STREAM and STATE_SPDY_SEND_REQUEST I don't know if we end up with an orphan stream in our spdy_session. As well, spdy_test_util.cc had a lot of functions with default arguments; I didn't fix them all, but the functions I modified no longer take default arguments and meet the coding standard. I'd like to circle back at some point and possibly make the tests call SpdyFramer directly: these test utils seem sometimes more trouble than they're worth if the framer was a bit more convenient for direct use. BUG=34750 TEST=net_unittests Spdy.ThreeGets* Review URL: http://codereview.chromium.org/2919011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52791 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_network_transaction.cc')
-rw-r--r--net/http/http_network_transaction.cc73
1 files changed, 39 insertions, 34 deletions
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc
index a14d682..a85a1ca 100644
--- a/net/http/http_network_transaction.cc
+++ b/net/http/http_network_transaction.cc
@@ -266,7 +266,7 @@ int HttpNetworkTransaction::RestartIgnoringLastError(
// update in DoSSLConnectComplete if |result| is OK?
if (using_spdy_) {
// TODO(cbentzel): Add auth support to spdy. See http://crbug.com/46620
- next_state_ = STATE_SPDY_SEND_REQUEST;
+ next_state_ = STATE_SPDY_GET_STREAM;
} else {
next_state_ = STATE_GENERATE_PROXY_AUTH_TOKEN;
}
@@ -435,6 +435,7 @@ LoadState HttpNetworkTransaction::GetLoadState() const {
case STATE_GENERATE_PROXY_AUTH_TOKEN_COMPLETE:
case STATE_GENERATE_SERVER_AUTH_TOKEN_COMPLETE:
case STATE_SEND_REQUEST_COMPLETE:
+ case STATE_SPDY_GET_STREAM:
case STATE_SPDY_SEND_REQUEST_COMPLETE:
return LOAD_STATE_SENDING_REQUEST;
case STATE_READ_HEADERS_COMPLETE:
@@ -568,6 +569,13 @@ int HttpNetworkTransaction::DoLoop(int result) {
net_log_.EndEvent(
NetLog::TYPE_HTTP_TRANSACTION_DRAIN_BODY_FOR_AUTH_RESTART, NULL);
break;
+ case STATE_SPDY_GET_STREAM:
+ DCHECK_EQ(OK, rv);
+ rv = DoSpdyGetStream();
+ break;
+ case STATE_SPDY_GET_STREAM_COMPLETE:
+ rv = DoSpdyGetStreamComplete(rv);
+ break;
case STATE_SPDY_SEND_REQUEST:
DCHECK_EQ(OK, rv);
net_log_.BeginEvent(NetLog::TYPE_SPDY_TRANSACTION_SEND_REQUEST, NULL);
@@ -720,7 +728,7 @@ int HttpNetworkTransaction::DoInitConnection() {
if (session_->spdy_session_pool()->HasSession(endpoint_)) {
using_spdy_ = true;
reused_socket_ = true;
- next_state_ = STATE_SPDY_SEND_REQUEST;
+ next_state_ = STATE_SPDY_GET_STREAM;
return OK;
}
@@ -933,7 +941,7 @@ int HttpNetworkTransaction::DoInitConnectionComplete(int result) {
if (using_spdy_) {
UpdateConnectionTypeHistograms(CONNECTION_SPDY);
// TODO(cbentzel): Add auth support to spdy. See http://crbug.com/46620
- next_state_ = STATE_SPDY_SEND_REQUEST;
+ next_state_ = STATE_SPDY_GET_STREAM;
} else {
next_state_ = STATE_GENERATE_PROXY_AUTH_TOKEN;
}
@@ -1219,8 +1227,8 @@ int HttpNetworkTransaction::DoDrainBodyForAuthRestartComplete(int result) {
return OK;
}
-int HttpNetworkTransaction::DoSpdySendRequest() {
- next_state_ = STATE_SPDY_SEND_REQUEST_COMPLETE;
+int HttpNetworkTransaction::DoSpdyGetStream() {
+ next_state_ = STATE_SPDY_GET_STREAM_COMPLETE;
CHECK(!spdy_http_stream_.get());
// First we get a SPDY session. Theoretically, we've just negotiated one, but
@@ -1249,39 +1257,34 @@ int HttpNetworkTransaction::DoSpdySendRequest() {
if(spdy_session->IsClosed())
return ERR_CONNECTION_CLOSED;
- UploadDataStream* upload_data = NULL;
+ headers_valid_ = false;
+
+ spdy_http_stream_.reset(new SpdyHttpStream());
+ return spdy_http_stream_->InitializeStream(spdy_session, *request_,
+ net_log_, &io_callback_);
+}
+
+int HttpNetworkTransaction::DoSpdyGetStreamComplete(int result) {
+ if (result < 0)
+ return result;
+
+ next_state_ = STATE_SPDY_SEND_REQUEST;
+ return OK;
+}
+
+int HttpNetworkTransaction::DoSpdySendRequest() {
+ next_state_ = STATE_SPDY_SEND_REQUEST_COMPLETE;
+
+ UploadDataStream* upload_data_stream = NULL;
if (request_->upload_data) {
int error_code = OK;
- upload_data = UploadDataStream::Create(request_->upload_data, &error_code);
- if (!upload_data)
+ upload_data_stream = UploadDataStream::Create(request_->upload_data,
+ &error_code);
+ if (!upload_data_stream)
return error_code;
}
- headers_valid_ = false;
- scoped_refptr<SpdyStream> spdy_stream;
- if (request_->method == "GET") {
- int error =
- spdy_session->GetPushStream(request_->url, &spdy_stream, net_log_);
- if (error != OK)
- return error;
- }
- if (spdy_stream.get()) {
- DCHECK(spdy_stream->pushed());
- CHECK(spdy_stream->GetDelegate() == NULL);
- spdy_http_stream_.reset(new SpdyHttpStream(spdy_stream));
- spdy_http_stream_->InitializeRequest(*request_, base::Time::Now(), NULL);
- } else {
- int error = spdy_session->CreateStream(request_->url,
- request_->priority,
- &spdy_stream,
- net_log_);
- if (error != OK)
- return error;
- DCHECK(!spdy_stream->pushed());
- CHECK(spdy_stream->GetDelegate() == NULL);
- spdy_http_stream_.reset(new SpdyHttpStream(spdy_stream));
- spdy_http_stream_->InitializeRequest(
- *request_, base::Time::Now(), upload_data);
- }
+ spdy_http_stream_->InitializeRequest(base::Time::Now(), upload_data_stream);
+
return spdy_http_stream_->SendRequest(&response_, &io_callback_);
}
@@ -1771,6 +1774,8 @@ std::string HttpNetworkTransaction::DescribeState(State state) {
STATE_CASE(STATE_READ_BODY_COMPLETE);
STATE_CASE(STATE_DRAIN_BODY_FOR_AUTH_RESTART);
STATE_CASE(STATE_DRAIN_BODY_FOR_AUTH_RESTART_COMPLETE);
+ STATE_CASE(STATE_SPDY_GET_STREAM);
+ STATE_CASE(STATE_SPDY_GET_STREAM_COMPLETE);
STATE_CASE(STATE_SPDY_SEND_REQUEST);
STATE_CASE(STATE_SPDY_SEND_REQUEST_COMPLETE);
STATE_CASE(STATE_SPDY_READ_HEADERS);