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

Side by Side Diff: net/spdy/spdy_stream.cc

Issue 9392030: SPDY Proxy - Bug fix to handle flow control (spdy/2.1) (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 10 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
« no previous file with comments | « net/spdy/spdy_proxy_client_socket.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/spdy/spdy_stream.h" 5 #include "net/spdy/spdy_stream.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 NetLog::TYPE_SPDY_STREAM_UPDATE_SEND_WINDOW, 185 NetLog::TYPE_SPDY_STREAM_UPDATE_SEND_WINDOW,
186 make_scoped_refptr(new NetLogSpdyStreamWindowUpdateParameter( 186 make_scoped_refptr(new NetLogSpdyStreamWindowUpdateParameter(
187 stream_id_, -delta_window_size, send_window_size_))); 187 stream_id_, -delta_window_size, send_window_size_)));
188 } 188 }
189 189
190 void SpdyStream::IncreaseRecvWindowSize(int32 delta_window_size) { 190 void SpdyStream::IncreaseRecvWindowSize(int32 delta_window_size) {
191 DCHECK_GE(delta_window_size, 1); 191 DCHECK_GE(delta_window_size, 1);
192 // By the time a read is isued, stream may become inactive. 192 // By the time a read is isued, stream may become inactive.
193 if (!session_->IsStreamActive(stream_id_)) 193 if (!session_->IsStreamActive(stream_id_))
194 return; 194 return;
195
196 if (!session_->is_flow_control_enabled())
197 return;
198
195 int32 new_window_size = recv_window_size_ + delta_window_size; 199 int32 new_window_size = recv_window_size_ + delta_window_size;
196 if (recv_window_size_ > 0) 200 if (recv_window_size_ > 0)
197 DCHECK(new_window_size > 0); 201 DCHECK(new_window_size > 0);
198 202
199 recv_window_size_ = new_window_size; 203 recv_window_size_ = new_window_size;
200 net_log_.AddEvent( 204 net_log_.AddEvent(
201 NetLog::TYPE_SPDY_STREAM_UPDATE_RECV_WINDOW, 205 NetLog::TYPE_SPDY_STREAM_UPDATE_RECV_WINDOW,
202 make_scoped_refptr(new NetLogSpdyStreamWindowUpdateParameter( 206 make_scoped_refptr(new NetLogSpdyStreamWindowUpdateParameter(
203 stream_id_, delta_window_size, recv_window_size_))); 207 stream_id_, delta_window_size, recv_window_size_)));
204 session_->SendWindowUpdate(stream_id_, delta_window_size); 208 session_->SendWindowUpdate(stream_id_, delta_window_size);
205 } 209 }
206 210
207 void SpdyStream::DecreaseRecvWindowSize(int32 delta_window_size) { 211 void SpdyStream::DecreaseRecvWindowSize(int32 delta_window_size) {
208 DCHECK_GE(delta_window_size, 1); 212 DCHECK_GE(delta_window_size, 1);
209 213
214 if (!session_->is_flow_control_enabled())
215 return;
216
210 recv_window_size_ -= delta_window_size; 217 recv_window_size_ -= delta_window_size;
211 net_log_.AddEvent( 218 net_log_.AddEvent(
212 NetLog::TYPE_SPDY_STREAM_UPDATE_RECV_WINDOW, 219 NetLog::TYPE_SPDY_STREAM_UPDATE_RECV_WINDOW,
213 make_scoped_refptr(new NetLogSpdyStreamWindowUpdateParameter( 220 make_scoped_refptr(new NetLogSpdyStreamWindowUpdateParameter(
214 stream_id_, -delta_window_size, recv_window_size_))); 221 stream_id_, -delta_window_size, recv_window_size_)));
215 222
216 // Since we never decrease the initial window size, we should never hit 223 // Since we never decrease the initial window size, we should never hit
217 // a negative |recv_window_size_|, if we do, it's a client side bug, so we use 224 // a negative |recv_window_size_|, if we do, it's a client side bug, so we use
218 // PROTOCOL_ERROR for lack of a better error code. 225 // PROTOCOL_ERROR for lack of a better error code.
219 if (recv_window_size_ < 0) { 226 if (recv_window_size_ < 0) {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 CHECK(!closed()); 333 CHECK(!closed());
327 334
328 // A zero-length read means that the stream is being closed. 335 // A zero-length read means that the stream is being closed.
329 if (!length) { 336 if (!length) {
330 metrics_.StopStream(); 337 metrics_.StopStream();
331 session_->CloseStream(stream_id_, net::OK); 338 session_->CloseStream(stream_id_, net::OK);
332 // Note: |this| may be deleted after calling CloseStream. 339 // Note: |this| may be deleted after calling CloseStream.
333 return; 340 return;
334 } 341 }
335 342
336 if (session_->is_flow_control_enabled()) 343 DecreaseRecvWindowSize(length);
337 DecreaseRecvWindowSize(length);
338 344
339 // Track our bandwidth. 345 // Track our bandwidth.
340 metrics_.RecordBytes(length); 346 metrics_.RecordBytes(length);
341 recv_bytes_ += length; 347 recv_bytes_ += length;
342 recv_last_byte_time_ = base::TimeTicks::Now(); 348 recv_last_byte_time_ = base::TimeTicks::Now();
343 349
344 if (!delegate_) { 350 if (!delegate_) {
345 // It should be valid for this to happen in the server push case. 351 // It should be valid for this to happen in the server push case.
346 // We'll return received data when delegate gets attached to the stream. 352 // We'll return received data when delegate gets attached to the stream.
347 IOBufferWithSize* buf = new IOBufferWithSize(length); 353 IOBufferWithSize* buf = new IOBufferWithSize(length);
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 UMA_HISTOGRAM_TIMES("Net.SpdyStreamDownloadTime", 686 UMA_HISTOGRAM_TIMES("Net.SpdyStreamDownloadTime",
681 recv_last_byte_time_ - recv_first_byte_time_); 687 recv_last_byte_time_ - recv_first_byte_time_);
682 UMA_HISTOGRAM_TIMES("Net.SpdyStreamTime", 688 UMA_HISTOGRAM_TIMES("Net.SpdyStreamTime",
683 recv_last_byte_time_ - send_time_); 689 recv_last_byte_time_ - send_time_);
684 690
685 UMA_HISTOGRAM_COUNTS("Net.SpdySendBytes", send_bytes_); 691 UMA_HISTOGRAM_COUNTS("Net.SpdySendBytes", send_bytes_);
686 UMA_HISTOGRAM_COUNTS("Net.SpdyRecvBytes", recv_bytes_); 692 UMA_HISTOGRAM_COUNTS("Net.SpdyRecvBytes", recv_bytes_);
687 } 693 }
688 694
689 } // namespace net 695 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_proxy_client_socket.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698