| OLD | NEW |
| 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/quic/reliable_quic_stream.h" | 5 #include "net/quic/reliable_quic_stream.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "net/quic/iovector.h" | 8 #include "net/quic/iovector.h" |
| 9 #include "net/quic/quic_session.h" | 9 #include "net/quic/quic_session.h" |
| 10 #include "net/quic/quic_write_blocked_list.h" | 10 #include "net/quic/quic_write_blocked_list.h" |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 | 344 |
| 345 // How much data we are allowed to write from flow control. | 345 // How much data we are allowed to write from flow control. |
| 346 size_t send_window = SendWindowSize(); | 346 size_t send_window = SendWindowSize(); |
| 347 | 347 |
| 348 // A FIN with zero data payload should not be flow control blocked. | 348 // A FIN with zero data payload should not be flow control blocked. |
| 349 bool fin_with_zero_data = (fin && write_length == 0); | 349 bool fin_with_zero_data = (fin && write_length == 0); |
| 350 | 350 |
| 351 if (IsFlowControlEnabled()) { | 351 if (IsFlowControlEnabled()) { |
| 352 if (send_window == 0 && !fin_with_zero_data) { | 352 if (send_window == 0 && !fin_with_zero_data) { |
| 353 // Quick return if we can't send anything. | 353 // Quick return if we can't send anything. |
| 354 session_->MarkFlowControlBlocked(id(), EffectivePriority()); | 354 session()->connection()->SendBlocked(id()); |
| 355 return QuicConsumedData(0, false); | 355 return QuicConsumedData(0, false); |
| 356 } | 356 } |
| 357 | 357 |
| 358 if (write_length > send_window) { | 358 if (write_length > send_window) { |
| 359 // Don't send the FIN if we aren't going to send all the data. | 359 // Don't send the FIN if we aren't going to send all the data. |
| 360 fin = false; | 360 fin = false; |
| 361 | 361 |
| 362 // Writing more data would be a violation of flow control. | 362 // Writing more data would be a violation of flow control. |
| 363 write_length = send_window; | 363 write_length = send_window; |
| 364 } | 364 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 376 if (IsFlowControlEnabled() && write_length == send_window && | 376 if (IsFlowControlEnabled() && write_length == send_window && |
| 377 !fin_with_zero_data) { | 377 !fin_with_zero_data) { |
| 378 DVLOG(1) << ENDPOINT << "Stream " << id() | 378 DVLOG(1) << ENDPOINT << "Stream " << id() |
| 379 << " is flow control blocked. " | 379 << " is flow control blocked. " |
| 380 << "Send window: " << send_window | 380 << "Send window: " << send_window |
| 381 << ", stream_bytes_written: " << stream_bytes_written_ | 381 << ", stream_bytes_written: " << stream_bytes_written_ |
| 382 << ", flow_control_send_limit: " | 382 << ", flow_control_send_limit: " |
| 383 << flow_control_send_limit_; | 383 << flow_control_send_limit_; |
| 384 // The entire send_window has been consumed, we are now flow control | 384 // The entire send_window has been consumed, we are now flow control |
| 385 // blocked. | 385 // blocked. |
| 386 session_->MarkFlowControlBlocked(id(), EffectivePriority()); | 386 session()->connection()->SendBlocked(id()); |
| 387 } | 387 } |
| 388 if (fin && consumed_data.fin_consumed) { | 388 if (fin && consumed_data.fin_consumed) { |
| 389 fin_sent_ = true; | 389 fin_sent_ = true; |
| 390 CloseWriteSide(); | 390 CloseWriteSide(); |
| 391 } else if (fin && !consumed_data.fin_consumed) { | 391 } else if (fin && !consumed_data.fin_consumed) { |
| 392 session_->MarkWriteBlocked(id(), EffectivePriority()); | 392 session_->MarkWriteBlocked(id(), EffectivePriority()); |
| 393 } | 393 } |
| 394 } else { | 394 } else { |
| 395 session_->MarkWriteBlocked(id(), EffectivePriority()); | 395 session_->MarkWriteBlocked(id(), EffectivePriority()); |
| 396 } | 396 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 | 484 |
| 485 uint64 ReliableQuicStream::SendWindowSize() const { | 485 uint64 ReliableQuicStream::SendWindowSize() const { |
| 486 return flow_control_send_limit_ - stream_bytes_written(); | 486 return flow_control_send_limit_ - stream_bytes_written(); |
| 487 } | 487 } |
| 488 | 488 |
| 489 uint64 ReliableQuicStream::TotalReceivedBytes() const { | 489 uint64 ReliableQuicStream::TotalReceivedBytes() const { |
| 490 return sequencer_.num_bytes_consumed() + sequencer_.num_bytes_buffered(); | 490 return sequencer_.num_bytes_consumed() + sequencer_.num_bytes_buffered(); |
| 491 } | 491 } |
| 492 | 492 |
| 493 } // namespace net | 493 } // namespace net |
| OLD | NEW |