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

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

Issue 934823005: Rename SPDY netlog strings to HTTP2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename SOURCE_SPDY_SESSION. Created 5 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
« no previous file with comments | « net/spdy/spdy_session_unittest.cc ('k') | net/spdy/spdy_stream_unittest.cc » ('j') | 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/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 "send_window_size_ [current: %d]", delta_window_size, stream_id_, 266 "send_window_size_ [current: %d]", delta_window_size, stream_id_,
267 send_window_size_); 267 send_window_size_);
268 session_->ResetStream(stream_id_, RST_STREAM_FLOW_CONTROL_ERROR, desc); 268 session_->ResetStream(stream_id_, RST_STREAM_FLOW_CONTROL_ERROR, desc);
269 return; 269 return;
270 } 270 }
271 } 271 }
272 272
273 send_window_size_ += delta_window_size; 273 send_window_size_ += delta_window_size;
274 274
275 net_log_.AddEvent( 275 net_log_.AddEvent(
276 NetLog::TYPE_SPDY_STREAM_UPDATE_SEND_WINDOW, 276 NetLog::TYPE_HTTP2_STREAM_UPDATE_SEND_WINDOW,
277 base::Bind(&NetLogSpdyStreamWindowUpdateCallback, 277 base::Bind(&NetLogSpdyStreamWindowUpdateCallback, stream_id_,
278 stream_id_, delta_window_size, send_window_size_)); 278 delta_window_size, send_window_size_));
279 279
280 PossiblyResumeIfSendStalled(); 280 PossiblyResumeIfSendStalled();
281 } 281 }
282 282
283 void SpdyStream::DecreaseSendWindowSize(int32 delta_window_size) { 283 void SpdyStream::DecreaseSendWindowSize(int32 delta_window_size) {
284 DCHECK_GE(session_->flow_control_state(), SpdySession::FLOW_CONTROL_STREAM); 284 DCHECK_GE(session_->flow_control_state(), SpdySession::FLOW_CONTROL_STREAM);
285 285
286 if (IsClosed()) 286 if (IsClosed())
287 return; 287 return;
288 288
289 // We only call this method when sending a frame. Therefore, 289 // We only call this method when sending a frame. Therefore,
290 // |delta_window_size| should be within the valid frame size range. 290 // |delta_window_size| should be within the valid frame size range.
291 DCHECK_GE(delta_window_size, 1); 291 DCHECK_GE(delta_window_size, 1);
292 DCHECK_LE(delta_window_size, kMaxSpdyFrameChunkSize); 292 DCHECK_LE(delta_window_size, kMaxSpdyFrameChunkSize);
293 293
294 // |send_window_size_| should have been at least |delta_window_size| for 294 // |send_window_size_| should have been at least |delta_window_size| for
295 // this call to happen. 295 // this call to happen.
296 DCHECK_GE(send_window_size_, delta_window_size); 296 DCHECK_GE(send_window_size_, delta_window_size);
297 297
298 send_window_size_ -= delta_window_size; 298 send_window_size_ -= delta_window_size;
299 299
300 net_log_.AddEvent( 300 net_log_.AddEvent(
301 NetLog::TYPE_SPDY_STREAM_UPDATE_SEND_WINDOW, 301 NetLog::TYPE_HTTP2_STREAM_UPDATE_SEND_WINDOW,
302 base::Bind(&NetLogSpdyStreamWindowUpdateCallback, 302 base::Bind(&NetLogSpdyStreamWindowUpdateCallback, stream_id_,
303 stream_id_, -delta_window_size, send_window_size_)); 303 -delta_window_size, send_window_size_));
304 } 304 }
305 305
306 void SpdyStream::OnReadBufferConsumed( 306 void SpdyStream::OnReadBufferConsumed(
307 size_t consume_size, 307 size_t consume_size,
308 SpdyBuffer::ConsumeSource consume_source) { 308 SpdyBuffer::ConsumeSource consume_source) {
309 DCHECK_GE(session_->flow_control_state(), SpdySession::FLOW_CONTROL_STREAM); 309 DCHECK_GE(session_->flow_control_state(), SpdySession::FLOW_CONTROL_STREAM);
310 DCHECK_GE(consume_size, 1u); 310 DCHECK_GE(consume_size, 1u);
311 DCHECK_LE(consume_size, static_cast<size_t>(kint32max)); 311 DCHECK_LE(consume_size, static_cast<size_t>(kint32max));
312 IncreaseRecvWindowSize(static_cast<int32>(consume_size)); 312 IncreaseRecvWindowSize(static_cast<int32>(consume_size));
313 } 313 }
314 314
315 void SpdyStream::IncreaseRecvWindowSize(int32 delta_window_size) { 315 void SpdyStream::IncreaseRecvWindowSize(int32 delta_window_size) {
316 DCHECK_GE(session_->flow_control_state(), SpdySession::FLOW_CONTROL_STREAM); 316 DCHECK_GE(session_->flow_control_state(), SpdySession::FLOW_CONTROL_STREAM);
317 317
318 // By the time a read is processed by the delegate, this stream may 318 // By the time a read is processed by the delegate, this stream may
319 // already be inactive. 319 // already be inactive.
320 if (!session_->IsStreamActive(stream_id_)) 320 if (!session_->IsStreamActive(stream_id_))
321 return; 321 return;
322 322
323 DCHECK_GE(unacked_recv_window_bytes_, 0); 323 DCHECK_GE(unacked_recv_window_bytes_, 0);
324 DCHECK_GE(recv_window_size_, unacked_recv_window_bytes_); 324 DCHECK_GE(recv_window_size_, unacked_recv_window_bytes_);
325 DCHECK_GE(delta_window_size, 1); 325 DCHECK_GE(delta_window_size, 1);
326 // Check for overflow. 326 // Check for overflow.
327 DCHECK_LE(delta_window_size, kint32max - recv_window_size_); 327 DCHECK_LE(delta_window_size, kint32max - recv_window_size_);
328 328
329 recv_window_size_ += delta_window_size; 329 recv_window_size_ += delta_window_size;
330 net_log_.AddEvent( 330 net_log_.AddEvent(
331 NetLog::TYPE_SPDY_STREAM_UPDATE_RECV_WINDOW, 331 NetLog::TYPE_HTTP2_STREAM_UPDATE_RECV_WINDOW,
332 base::Bind(&NetLogSpdyStreamWindowUpdateCallback, 332 base::Bind(&NetLogSpdyStreamWindowUpdateCallback, stream_id_,
333 stream_id_, delta_window_size, recv_window_size_)); 333 delta_window_size, recv_window_size_));
334 334
335 unacked_recv_window_bytes_ += delta_window_size; 335 unacked_recv_window_bytes_ += delta_window_size;
336 if (unacked_recv_window_bytes_ > 336 if (unacked_recv_window_bytes_ >
337 session_->stream_initial_recv_window_size() / 2) { 337 session_->stream_initial_recv_window_size() / 2) {
338 session_->SendStreamWindowUpdate( 338 session_->SendStreamWindowUpdate(
339 stream_id_, static_cast<uint32>(unacked_recv_window_bytes_)); 339 stream_id_, static_cast<uint32>(unacked_recv_window_bytes_));
340 unacked_recv_window_bytes_ = 0; 340 unacked_recv_window_bytes_ = 0;
341 } 341 }
342 } 342 }
343 343
344 void SpdyStream::DecreaseRecvWindowSize(int32 delta_window_size) { 344 void SpdyStream::DecreaseRecvWindowSize(int32 delta_window_size) {
345 DCHECK(session_->IsStreamActive(stream_id_)); 345 DCHECK(session_->IsStreamActive(stream_id_));
346 DCHECK_GE(session_->flow_control_state(), SpdySession::FLOW_CONTROL_STREAM); 346 DCHECK_GE(session_->flow_control_state(), SpdySession::FLOW_CONTROL_STREAM);
347 DCHECK_GE(delta_window_size, 1); 347 DCHECK_GE(delta_window_size, 1);
348 348
349 // Since we never decrease the initial receive window size, 349 // Since we never decrease the initial receive window size,
350 // |delta_window_size| should never cause |recv_window_size_| to go 350 // |delta_window_size| should never cause |recv_window_size_| to go
351 // negative. If we do, the receive window isn't being respected. 351 // negative. If we do, the receive window isn't being respected.
352 if (delta_window_size > recv_window_size_) { 352 if (delta_window_size > recv_window_size_) {
353 session_->ResetStream( 353 session_->ResetStream(
354 stream_id_, RST_STREAM_PROTOCOL_ERROR, 354 stream_id_, RST_STREAM_PROTOCOL_ERROR,
355 "delta_window_size is " + base::IntToString(delta_window_size) + 355 "delta_window_size is " + base::IntToString(delta_window_size) +
356 " in DecreaseRecvWindowSize, which is larger than the receive " + 356 " in DecreaseRecvWindowSize, which is larger than the receive " +
357 "window size of " + base::IntToString(recv_window_size_)); 357 "window size of " + base::IntToString(recv_window_size_));
358 return; 358 return;
359 } 359 }
360 360
361 recv_window_size_ -= delta_window_size; 361 recv_window_size_ -= delta_window_size;
362 net_log_.AddEvent( 362 net_log_.AddEvent(
363 NetLog::TYPE_SPDY_STREAM_UPDATE_RECV_WINDOW, 363 NetLog::TYPE_HTTP2_STREAM_UPDATE_RECV_WINDOW,
364 base::Bind(&NetLogSpdyStreamWindowUpdateCallback, 364 base::Bind(&NetLogSpdyStreamWindowUpdateCallback, stream_id_,
365 stream_id_, -delta_window_size, recv_window_size_)); 365 -delta_window_size, recv_window_size_));
366 } 366 }
367 367
368 int SpdyStream::GetPeerAddress(IPEndPoint* address) const { 368 int SpdyStream::GetPeerAddress(IPEndPoint* address) const {
369 return session_->GetPeerAddress(address); 369 return session_->GetPeerAddress(address);
370 } 370 }
371 371
372 int SpdyStream::GetLocalAddress(IPEndPoint* address) const { 372 int SpdyStream::GetLocalAddress(IPEndPoint* address) const {
373 return session_->GetLocalAddress(address); 373 return session_->GetLocalAddress(address);
374 } 374 }
375 375
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 pending_send_data_ = NULL; 608 pending_send_data_ = NULL;
609 return OK; 609 return OK;
610 } 610 }
611 } 611 }
612 612
613 SpdyMajorVersion SpdyStream::GetProtocolVersion() const { 613 SpdyMajorVersion SpdyStream::GetProtocolVersion() const {
614 return session_->GetProtocolVersion(); 614 return session_->GetProtocolVersion();
615 } 615 }
616 616
617 void SpdyStream::LogStreamError(int status, const std::string& description) { 617 void SpdyStream::LogStreamError(int status, const std::string& description) {
618 net_log_.AddEvent(NetLog::TYPE_SPDY_STREAM_ERROR, 618 net_log_.AddEvent(NetLog::TYPE_HTTP2_STREAM_ERROR,
619 base::Bind(&NetLogSpdyStreamErrorCallback, 619 base::Bind(&NetLogSpdyStreamErrorCallback, stream_id_,
620 stream_id_, status, &description)); 620 status, &description));
621 } 621 }
622 622
623 void SpdyStream::OnClose(int status) { 623 void SpdyStream::OnClose(int status) {
624 // In most cases, the stream should already be CLOSED. The exception is when a 624 // In most cases, the stream should already be CLOSED. The exception is when a
625 // SpdySession is shutting down while the stream is in an intermediate state. 625 // SpdySession is shutting down while the stream is in an intermediate state.
626 io_state_ = STATE_CLOSED; 626 io_state_ = STATE_CLOSED;
627 response_status_ = status; 627 response_status_ = status;
628 Delegate* delegate = delegate_; 628 Delegate* delegate = delegate_;
629 delegate_ = NULL; 629 delegate_ = NULL;
630 if (delegate) 630 if (delegate)
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 bool SpdyStream::GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) { 702 bool SpdyStream::GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) {
703 return session_->GetSSLCertRequestInfo(cert_request_info); 703 return session_->GetSSLCertRequestInfo(cert_request_info);
704 } 704 }
705 705
706 void SpdyStream::PossiblyResumeIfSendStalled() { 706 void SpdyStream::PossiblyResumeIfSendStalled() {
707 if (IsLocallyClosed()) { 707 if (IsLocallyClosed()) {
708 return; 708 return;
709 } 709 }
710 if (send_stalled_by_flow_control_ && !session_->IsSendStalled() && 710 if (send_stalled_by_flow_control_ && !session_->IsSendStalled() &&
711 send_window_size_ > 0) { 711 send_window_size_ > 0) {
712 net_log_.AddEvent( 712 net_log_.AddEvent(NetLog::TYPE_HTTP2_STREAM_FLOW_CONTROL_UNSTALLED,
713 NetLog::TYPE_SPDY_STREAM_FLOW_CONTROL_UNSTALLED, 713 NetLog::IntegerCallback("stream_id", stream_id_));
714 NetLog::IntegerCallback("stream_id", stream_id_));
715 send_stalled_by_flow_control_ = false; 714 send_stalled_by_flow_control_ = false;
716 QueueNextDataFrame(); 715 QueueNextDataFrame();
717 } 716 }
718 } 717 }
719 718
720 bool SpdyStream::IsClosed() const { 719 bool SpdyStream::IsClosed() const {
721 return io_state_ == STATE_CLOSED; 720 return io_state_ == STATE_CLOSED;
722 } 721 }
723 722
724 bool SpdyStream::IsLocallyClosed() const { 723 bool SpdyStream::IsLocallyClosed() const {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, 917 description = base::StringPrintf("Unknown state 0x%08X (%u)", state,
919 state); 918 state);
920 break; 919 break;
921 } 920 }
922 return description; 921 return description;
923 } 922 }
924 923
925 #undef STATE_CASE 924 #undef STATE_CASE
926 925
927 } // namespace net 926 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_session_unittest.cc ('k') | net/spdy/spdy_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698