diff options
author | gavinp@google.com <gavinp@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-17 00:58:44 +0000 |
---|---|---|
committer | gavinp@google.com <gavinp@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-17 00:58:44 +0000 |
commit | 2bd930265ee663668e49d41eb35fddd94934eae2 (patch) | |
tree | 995f47c031908b58b5780b228fa405de1b0ff407 /net/spdy/spdy_http_stream.cc | |
parent | 485cd456a503e6698c75ea6185ed93de832d493a (diff) | |
download | chromium_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/spdy/spdy_http_stream.cc')
-rw-r--r-- | net/spdy/spdy_http_stream.cc | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/net/spdy/spdy_http_stream.cc b/net/spdy/spdy_http_stream.cc index bb22b9d..68e5e2a 100644 --- a/net/spdy/spdy_http_stream.cc +++ b/net/spdy/spdy_http_stream.cc @@ -4,7 +4,9 @@ #include "net/spdy/spdy_http_stream.h" +#include <algorithm> #include <list> +#include <string> #include "base/logging.h" #include "base/message_loop.h" @@ -126,28 +128,49 @@ void CreateSpdyHeadersFromHttpRequest( namespace net { -SpdyHttpStream::SpdyHttpStream(const scoped_refptr<SpdyStream>& stream) +SpdyHttpStream::SpdyHttpStream() : ALLOW_THIS_IN_INITIALIZER_LIST(read_callback_factory_(this)), - stream_(stream), + stream_(NULL), + spdy_session_(NULL), response_info_(NULL), download_finished_(false), user_callback_(NULL), user_buffer_len_(0), buffered_read_callback_pending_(false), - more_read_data_pending_(false) { - CHECK(stream_.get()); - stream_->SetDelegate(this); -} + more_read_data_pending_(false) { } SpdyHttpStream::~SpdyHttpStream() { - stream_->DetachDelegate(); + if (stream_) + stream_->DetachDelegate(); } -void SpdyHttpStream::InitializeRequest( +int SpdyHttpStream::InitializeStream( + SpdySession* spdy_session, const HttpRequestInfo& request_info, + const BoundNetLog& stream_net_log, + CompletionCallback* callback) { + spdy_session_ = spdy_session; + request_info_ = request_info; + if (request_info_.method == "GET") { + int error = spdy_session_->GetPushStream(request_info.url, &stream_, + stream_net_log); + if (error != OK) + return error; + } + + if (stream_.get()) + return OK; + else + return spdy_session_->CreateStream(request_info_.url, + request_info_.priority, &stream_, + stream_net_log, callback, this); +} + +void SpdyHttpStream::InitializeRequest( base::Time request_time, UploadDataStream* upload_data) { - request_info_ = request_info; + CHECK(stream_.get()); + stream_->SetDelegate(this); linked_ptr<spdy::SpdyHeaderBlock> headers(new spdy::SpdyHeaderBlock); CreateSpdyHeadersFromHttpRequest(request_info_, headers.get()); stream_->set_spdy_headers(headers); @@ -278,8 +301,11 @@ int SpdyHttpStream::SendRequest(HttpResponseInfo* response, } void SpdyHttpStream::Cancel() { + if (spdy_session_) + spdy_session_->CancelPendingCreateStreams(this); user_callback_ = NULL; - stream_->Cancel(); + if (stream_) + stream_->Cancel(); } bool SpdyHttpStream::OnSendHeadersComplete(int status) { |