diff options
author | rtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-14 21:52:26 +0000 |
---|---|---|
committer | rtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-14 21:52:26 +0000 |
commit | edfd4914e3c8d87ba716f175a9ad83668f94418e (patch) | |
tree | 6c9215d446caaf5e15d3cd3edd56a775bd512547 /net | |
parent | 9cbe35e8c6dac8cd1a520e01ab38688880e9d55a (diff) | |
download | chromium_src-edfd4914e3c8d87ba716f175a9ad83668f94418e.zip chromium_src-edfd4914e3c8d87ba716f175a9ad83668f94418e.tar.gz chromium_src-edfd4914e3c8d87ba716f175a9ad83668f94418e.tar.bz2 |
SPDY - updated comments and used int32 for window size
per comments from wtc in the following CL.
http://src.chromium.org/viewvc/chrome?view=rev&revision=120855
R=wtc
BUG=112778
Review URL: http://codereview.chromium.org/9358012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121945 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/spdy/spdy_network_transaction_unittest.cc | 4 | ||||
-rw-r--r-- | net/spdy/spdy_session.cc | 30 | ||||
-rw-r--r-- | net/spdy/spdy_session.h | 6 | ||||
-rw-r--r-- | net/spdy/spdy_stream.cc | 24 | ||||
-rw-r--r-- | net/spdy/spdy_stream.h | 22 |
5 files changed, 47 insertions, 39 deletions
diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc index 97e494d..1ea9820 100644 --- a/net/spdy/spdy_network_transaction_unittest.cc +++ b/net/spdy/spdy_network_transaction_unittest.cc @@ -1908,7 +1908,7 @@ TEST_P(SpdyNetworkTransactionTest, WindowUpdateReceived) { CreateMockWrite(*body_end), }; - static const int kDeltaWindowSize = 0xff; + static const int32 kDeltaWindowSize = 0xff; static const int kDeltaCount = 4; scoped_ptr<spdy::SpdyFrame> window_update( ConstructSpdyWindowUpdate(1, kDeltaWindowSize)); @@ -2075,7 +2075,7 @@ TEST_P(SpdyNetworkTransactionTest, WindowUpdateOverflow) { CreateMockWrite(*rst), }; - static const int kDeltaWindowSize = 0x7fffffff; // cause an overflow + static const int32 kDeltaWindowSize = 0x7fffffff; // cause an overflow scoped_ptr<spdy::SpdyFrame> window_update( ConstructSpdyWindowUpdate(1, kDeltaWindowSize)); scoped_ptr<spdy::SpdyFrame> window_update2( diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc index 045f7a2..d4d54c1 100644 --- a/net/spdy/spdy_session.cc +++ b/net/spdy/spdy_session.cc @@ -128,7 +128,7 @@ class NetLogSpdySettingsParameter : public NetLog::EventParameters { class NetLogSpdyWindowUpdateParameter : public NetLog::EventParameters { public: - NetLogSpdyWindowUpdateParameter(spdy::SpdyStreamId stream_id, int delta) + NetLogSpdyWindowUpdateParameter(spdy::SpdyStreamId stream_id, int32 delta) : stream_id_(stream_id), delta_(delta) {} virtual Value* ToValue() const { @@ -141,7 +141,7 @@ class NetLogSpdyWindowUpdateParameter : public NetLog::EventParameters { private: ~NetLogSpdyWindowUpdateParameter() {} const spdy::SpdyStreamId stream_id_; - const int delta_; + const int32 delta_; DISALLOW_COPY_AND_ASSIGN(NetLogSpdyWindowUpdateParameter); }; @@ -1580,7 +1580,7 @@ void SpdySession::OnSettings(const spdy::SpdySettingsControlFrame& frame) { void SpdySession::OnWindowUpdate( const spdy::SpdyWindowUpdateControlFrame& frame) { spdy::SpdyStreamId stream_id = frame.stream_id(); - int delta_window_size = static_cast<int>(frame.delta_window_size()); + int32 delta_window_size = static_cast<int32>(frame.delta_window_size()); net_log_.AddEvent( NetLog::TYPE_SPDY_SESSION_RECEIVED_WINDOW_UPDATE, make_scoped_refptr(new NetLogSpdyWindowUpdateParameter( @@ -1607,7 +1607,7 @@ void SpdySession::OnWindowUpdate( } void SpdySession::SendWindowUpdate(spdy::SpdyStreamId stream_id, - int delta_window_size) { + int32 delta_window_size) { DCHECK(IsStreamActive(stream_id)); scoped_refptr<SpdyStream> stream = active_streams_[stream_id]; CHECK_EQ(stream->stream_id(), stream_id); @@ -1699,8 +1699,11 @@ void SpdySession::HandleSettings(const spdy::SpdySettings& settings) { 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); + // INITIAL_WINDOW_SIZE updates initial_send_window_size_ only. + // TODO(rtenneti): discuss with the server team about + // initial_recv_window_size_. + int32 prev_initial_send_window_size = initial_send_window_size_; + initial_send_window_size_ = val; int32 delta_window_size = initial_send_window_size_ - prev_initial_send_window_size; UpdateStreamsSendWindowSize(delta_window_size); @@ -1718,17 +1721,22 @@ void SpdySession::UpdateStreamsSendWindowSize(int32 delta_window_size) { } for (int i = 0; i < NUM_PRIORITIES; ++i) { - PendingCreateStreamQueue tmp; + PendingCreateStreamQueue temporary_queue; + // Lack of iterator for std::queue forces us to copy the entries to + // temporary_queue and copy them back. + // TODO(rtenneti): Use a different data type that has iterator for + // create_stream_queues_. 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); + temporary_queue.push(pending_create); } - while (!tmp.empty()) { - create_stream_queues_[i].push(tmp.front()); - tmp.pop(); + // Now copy it back. + while (!temporary_queue.empty()) { + create_stream_queues_[i].push(temporary_queue.front()); + temporary_queue.pop(); } } } diff --git a/net/spdy/spdy_session.h b/net/spdy/spdy_session.h index af1b4fc..f3e9636 100644 --- a/net/spdy/spdy_session.h +++ b/net/spdy/spdy_session.h @@ -209,7 +209,7 @@ class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>, // Send WINDOW_UPDATE frame, called by a stream whenever receive window // size is increased. - void SendWindowUpdate(spdy::SpdyStreamId stream_id, int delta_window_size); + void SendWindowUpdate(spdy::SpdyStreamId stream_id, int32 delta_window_size); // If session is closed, no new streams/transactions should be created. bool IsClosed() const { return state_ == CLOSED; } @@ -600,13 +600,13 @@ class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>, // Initial send window size for the session; can be changed by an // arriving SETTINGS frame; newly created streams use this value for the // initial send window size. - int initial_send_window_size_; + int32 initial_send_window_size_; // Initial receive window size for the session; there are plans to add a // command line switch that would cause a SETTINGS frame with window size // announcement to be sent on startup; newly created streams will use // this value for the initial receive window size. - int initial_recv_window_size_; + int32 initial_recv_window_size_; BoundNetLog net_log_; diff --git a/net/spdy/spdy_stream.cc b/net/spdy/spdy_stream.cc index b1eaad2..2c40e47 100644 --- a/net/spdy/spdy_stream.cc +++ b/net/spdy/spdy_stream.cc @@ -17,8 +17,8 @@ namespace { class NetLogSpdyStreamWindowUpdateParameter : public NetLog::EventParameters { public: NetLogSpdyStreamWindowUpdateParameter(spdy::SpdyStreamId stream_id, - int delta, - int window_size) + int32 delta, + int32 window_size) : stream_id_(stream_id), delta_(delta), window_size_(window_size) {} virtual Value* ToValue() const { DictionaryValue* dict = new DictionaryValue(); @@ -29,8 +29,8 @@ class NetLogSpdyStreamWindowUpdateParameter : public NetLog::EventParameters { } private: const spdy::SpdyStreamId stream_id_; - const int delta_; - const int window_size_; + const int32 delta_; + const int32 window_size_; DISALLOW_COPY_AND_ASSIGN(NetLogSpdyStreamWindowUpdateParameter); }; @@ -129,13 +129,13 @@ 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::AdjustSendWindowSize(int32 delta_window_size) { + send_window_size_ += delta_window_size; } -void SpdyStream::IncreaseSendWindowSize(int delta_window_size) { +void SpdyStream::IncreaseSendWindowSize(int32 delta_window_size) { DCHECK_GE(delta_window_size, 1); - int new_window_size = send_window_size_ + delta_window_size; + int32 new_window_size = send_window_size_ + delta_window_size; // We should ignore WINDOW_UPDATEs received before or after this state, // since before means we've not written SYN_STREAM yet (i.e. it's too @@ -169,7 +169,7 @@ void SpdyStream::IncreaseSendWindowSize(int delta_window_size) { } } -void SpdyStream::DecreaseSendWindowSize(int delta_window_size) { +void SpdyStream::DecreaseSendWindowSize(int32 delta_window_size) { // we only call this method when sending a frame, therefore // |delta_window_size| should be within the valid frame size range. DCHECK_GE(delta_window_size, 1); @@ -187,12 +187,12 @@ void SpdyStream::DecreaseSendWindowSize(int delta_window_size) { stream_id_, -delta_window_size, send_window_size_))); } -void SpdyStream::IncreaseRecvWindowSize(int delta_window_size) { +void SpdyStream::IncreaseRecvWindowSize(int32 delta_window_size) { DCHECK_GE(delta_window_size, 1); // By the time a read is isued, stream may become inactive. if (!session_->IsStreamActive(stream_id_)) return; - int new_window_size = recv_window_size_ + delta_window_size; + int32 new_window_size = recv_window_size_ + delta_window_size; if (recv_window_size_ > 0) DCHECK(new_window_size > 0); @@ -204,7 +204,7 @@ void SpdyStream::IncreaseRecvWindowSize(int delta_window_size) { session_->SendWindowUpdate(stream_id_, delta_window_size); } -void SpdyStream::DecreaseRecvWindowSize(int delta_window_size) { +void SpdyStream::DecreaseRecvWindowSize(int32 delta_window_size) { DCHECK_GE(delta_window_size, 1); recv_window_size_ -= delta_window_size; diff --git a/net/spdy/spdy_stream.h b/net/spdy/spdy_stream.h index c36ccdc..fe4269f 100644 --- a/net/spdy/spdy_stream.h +++ b/net/spdy/spdy_stream.h @@ -125,13 +125,13 @@ class NET_EXPORT_PRIVATE SpdyStream int priority() const { return priority_; } void set_priority(int priority) { priority_ = priority; } - int send_window_size() const { return send_window_size_; } - void set_send_window_size(int window_size) { + int32 send_window_size() const { return send_window_size_; } + void set_send_window_size(int32 window_size) { send_window_size_ = window_size; } - int recv_window_size() const { return recv_window_size_; } - void set_recv_window_size(int window_size) { + int32 recv_window_size() const { return recv_window_size_; } + void set_recv_window_size(int32 window_size) { recv_window_size_ = window_size; } @@ -140,15 +140,15 @@ class NET_EXPORT_PRIVATE SpdyStream } // Adjust the |send_window_size_| by |delta_window_size|. - void AdjustSendWindowSize(int delta_window_size); + void AdjustSendWindowSize(int32 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. - void IncreaseSendWindowSize(int delta_window_size); + void IncreaseSendWindowSize(int32 delta_window_size); // Decreases |send_window_size_| by the given number of bytes. - void DecreaseSendWindowSize(int delta_window_size); + void DecreaseSendWindowSize(int32 delta_window_size); int GetPeerAddress(AddressList* address) const; int GetLocalAddress(IPEndPoint* address) const; @@ -159,13 +159,13 @@ class NET_EXPORT_PRIVATE SpdyStream // Increases |recv_window_size_| by the given number of bytes, also sends // a WINDOW_UPDATE frame. - void IncreaseRecvWindowSize(int delta_window_size); + void IncreaseRecvWindowSize(int32 delta_window_size); // Decreases |recv_window_size_| by the given number of bytes, called // whenever data is read. May also send a RST_STREAM and remove the // stream from the session if the resultant |recv_window_size_| is // negative, since that would be a flow control violation. - void DecreaseRecvWindowSize(int delta_window_size); + void DecreaseRecvWindowSize(int32 delta_window_size); const BoundNetLog& net_log() const { return net_log_; } @@ -302,8 +302,8 @@ class NET_EXPORT_PRIVATE SpdyStream // Flow control variables. bool stalled_by_flow_control_; - int send_window_size_; - int recv_window_size_; + int32 send_window_size_; + int32 recv_window_size_; const bool pushed_; ScopedBandwidthMetrics metrics_; |