diff options
author | rtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-07 23:36:09 +0000 |
---|---|---|
committer | rtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-07 23:36:09 +0000 |
commit | 1e0771efa8db5353eea04c3e29781e7e902edd02 (patch) | |
tree | f34da095e29c36b31f67b9adcb989c6bf49bc924 /net | |
parent | c0f559dd06e7d1fb5a7a4fa118b1acd1c89fc26c (diff) | |
download | chromium_src-1e0771efa8db5353eea04c3e29781e7e902edd02.zip chromium_src-1e0771efa8db5353eea04c3e29781e7e902edd02.tar.gz chromium_src-1e0771efa8db5353eea04c3e29781e7e902edd02.tar.bz2 |
SPDY - Adjust the send window size of all streams (new and current)
based on initial window size sent in settings frame from the server.
R=willchan
BUG=112778
TEST=network unit tests
Review URL: http://codereview.chromium.org/9346003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120855 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/spdy/spdy_session.cc | 33 | ||||
-rw-r--r-- | net/spdy/spdy_session.h | 3 | ||||
-rw-r--r-- | net/spdy/spdy_stream.cc | 6 | ||||
-rw-r--r-- | net/spdy/spdy_stream.h | 5 |
4 files changed, 45 insertions, 2 deletions
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc index e385d84..1c82ad3 100644 --- a/net/spdy/spdy_session.cc +++ b/net/spdy/spdy_session.cc @@ -1213,6 +1213,8 @@ void SpdySession::OnSyn(const spdy::SpdySynStreamControlFrame& frame, new SpdyStream(this, stream_id, true, net_log_)); stream->set_path(gurl.PathForRequest()); + stream->set_send_window_size(initial_send_window_size_); + stream->set_recv_window_size(initial_recv_window_size_); unclaimed_pushed_streams_[url] = stream; @@ -1568,6 +1570,37 @@ void SpdySession::HandleSettings(const spdy::SpdySettings& settings) { max_concurrent_stream_limit_); ProcessPendingCreateStreams(); break; + case spdy::SETTINGS_INITIAL_WINDOW_SIZE: + int prev_initial_send_window_size = initial_send_window_size_; + initial_send_window_size_ = static_cast<size_t>(val); + int32 delta_window_size = + initial_send_window_size_ - prev_initial_send_window_size; + UpdateStreamsSendWindowSize(delta_window_size); + break; + } + } +} + +void SpdySession::UpdateStreamsSendWindowSize(int32 delta_window_size) { + ActiveStreamMap::iterator it; + for (it = active_streams_.begin(); it != active_streams_.end(); ++it) { + const scoped_refptr<SpdyStream>& stream = it->second; + DCHECK(stream); + stream->AdjustSendWindowSize(delta_window_size); + } + + for (int i = 0; i < NUM_PRIORITIES; ++i) { + PendingCreateStreamQueue tmp; + while (!create_stream_queues_[i].empty()) { + PendingCreateStream pending_create = create_stream_queues_[i].front(); + const scoped_refptr<SpdyStream>& stream = *(pending_create.spdy_stream); + stream->AdjustSendWindowSize(delta_window_size); + create_stream_queues_[i].pop(); + tmp.push(pending_create); + } + while (!tmp.empty()) { + create_stream_queues_[i].push(tmp.front()); + tmp.pop(); } } } diff --git a/net/spdy/spdy_session.h b/net/spdy/spdy_session.h index 20570be..5514d4c 100644 --- a/net/spdy/spdy_session.h +++ b/net/spdy/spdy_session.h @@ -330,6 +330,9 @@ class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>, // SETTINGS control frame, update our SpdySession accordingly. void HandleSettings(const spdy::SpdySettings& settings); + // Adjust the send window size of all ActiveStreams and PendingCreateStreams. + void UpdateStreamsSendWindowSize(int32 delta_window_size); + // Send the PING (preface-PING and trailing-PING) frames. void SendPrefacePingIfNoneInFlight(); diff --git a/net/spdy/spdy_stream.cc b/net/spdy/spdy_stream.cc index 55cebbe..c9fb3d6 100644 --- a/net/spdy/spdy_stream.cc +++ b/net/spdy/spdy_stream.cc @@ -128,6 +128,10 @@ void SpdyStream::set_spdy_headers( request_ = headers; } +void SpdyStream::AdjustSendWindowSize(int delta_window_size) { + send_window_size_ = send_window_size_ + delta_window_size; +} + void SpdyStream::IncreaseSendWindowSize(int delta_window_size) { DCHECK_GE(delta_window_size, 1); int new_window_size = send_window_size_ + delta_window_size; @@ -157,7 +161,7 @@ void SpdyStream::IncreaseSendWindowSize(int delta_window_size) { NetLog::TYPE_SPDY_STREAM_UPDATE_SEND_WINDOW, make_scoped_refptr(new NetLogSpdyStreamWindowUpdateParameter( stream_id_, delta_window_size, send_window_size_))); - if (stalled_by_flow_control_) { + if (send_window_size_ > 0 && stalled_by_flow_control_) { stalled_by_flow_control_ = false; io_state_ = STATE_SEND_BODY; DoLoop(OK); diff --git a/net/spdy/spdy_stream.h b/net/spdy/spdy_stream.h index f022322..64b7060 100644 --- a/net/spdy/spdy_stream.h +++ b/net/spdy/spdy_stream.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -137,6 +137,9 @@ class NET_EXPORT_PRIVATE SpdyStream stalled_by_flow_control_ = stalled; } + // Adjust the |send_window_size_| by |delta_window_size|. + void AdjustSendWindowSize(int delta_window_size); + // Increases |send_window_size_| with delta extracted from a WINDOW_UPDATE // frame; sends a RST_STREAM if delta overflows |send_window_size_| and // removes the stream from the session. |