| 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_flow_controller.h" | 9 #include "net/quic/quic_flow_controller.h" |
| 10 #include "net/quic/quic_session.h" | 10 #include "net/quic/quic_session.h" |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 delegate->WroteData(false); | 326 delegate->WroteData(false); |
| 327 } | 327 } |
| 328 } | 328 } |
| 329 break; | 329 break; |
| 330 } | 330 } |
| 331 } | 331 } |
| 332 } | 332 } |
| 333 | 333 |
| 334 void ReliableQuicStream::MaybeSendBlocked() { | 334 void ReliableQuicStream::MaybeSendBlocked() { |
| 335 flow_controller_.MaybeSendBlocked(); | 335 flow_controller_.MaybeSendBlocked(); |
| 336 if (stream_contributes_to_connection_flow_control_) { | 336 if (!stream_contributes_to_connection_flow_control_) { |
| 337 connection_flow_controller_->MaybeSendBlocked(); | 337 return; |
| 338 } | 338 } |
| 339 connection_flow_controller_->MaybeSendBlocked(); |
| 339 // If we are connection level flow control blocked, then add the stream | 340 // If we are connection level flow control blocked, then add the stream |
| 340 // to the write blocked list. It will be given a chance to write when a | 341 // to the write blocked list. It will be given a chance to write when a |
| 341 // connection level WINDOW_UPDATE arrives. | 342 // connection level WINDOW_UPDATE arrives. |
| 342 if (stream_contributes_to_connection_flow_control_ && | 343 if (connection_flow_controller_->IsBlocked() && |
| 343 connection_flow_controller_->IsBlocked() && | |
| 344 !flow_controller_.IsBlocked()) { | 344 !flow_controller_.IsBlocked()) { |
| 345 session_->MarkWriteBlocked(id(), EffectivePriority()); | 345 session_->MarkWriteBlocked(id(), EffectivePriority()); |
| 346 } | 346 } |
| 347 } | 347 } |
| 348 | 348 |
| 349 QuicConsumedData ReliableQuicStream::WritevData( | 349 QuicConsumedData ReliableQuicStream::WritevData( |
| 350 const struct iovec* iov, | 350 const struct iovec* iov, |
| 351 int iov_count, | 351 int iov_count, |
| 352 bool fin, | 352 bool fin, |
| 353 QuicAckNotifier::DelegateInterface* ack_notifier_delegate) { | 353 QuicAckNotifier::DelegateInterface* ack_notifier_delegate) { |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 // We can write again! | 483 // We can write again! |
| 484 // TODO(rjshade): This does not respect priorities (e.g. multiple | 484 // TODO(rjshade): This does not respect priorities (e.g. multiple |
| 485 // outstanding POSTs are unblocked on arrival of | 485 // outstanding POSTs are unblocked on arrival of |
| 486 // SHLO with initial window). | 486 // SHLO with initial window). |
| 487 // As long as the connection is not flow control blocked, we can write! | 487 // As long as the connection is not flow control blocked, we can write! |
| 488 OnCanWrite(); | 488 OnCanWrite(); |
| 489 } | 489 } |
| 490 } | 490 } |
| 491 | 491 |
| 492 bool ReliableQuicStream::MaybeIncreaseHighestReceivedOffset(uint64 new_offset) { | 492 bool ReliableQuicStream::MaybeIncreaseHighestReceivedOffset(uint64 new_offset) { |
| 493 if (flow_controller_.IsEnabled()) { | 493 if (!flow_controller_.IsEnabled()) { |
| 494 uint64 increment = | 494 return false; |
| 495 new_offset - flow_controller_.highest_received_byte_offset(); | |
| 496 if (flow_controller_.UpdateHighestReceivedOffset(new_offset)) { | |
| 497 // If |new_offset| increased the stream flow controller's highest received | |
| 498 // offset, then we need to increase the connection flow controller's value | |
| 499 // by the incremental difference. | |
| 500 if (stream_contributes_to_connection_flow_control_) { | |
| 501 connection_flow_controller_->UpdateHighestReceivedOffset( | |
| 502 connection_flow_controller_->highest_received_byte_offset() + | |
| 503 increment); | |
| 504 } | |
| 505 return true; | |
| 506 } | |
| 507 } | 495 } |
| 508 return false; | 496 uint64 increment = |
| 497 new_offset - flow_controller_.highest_received_byte_offset(); |
| 498 if (!flow_controller_.UpdateHighestReceivedOffset(new_offset)) { |
| 499 return false; |
| 500 } |
| 501 |
| 502 // If |new_offset| increased the stream flow controller's highest received |
| 503 // offset, then we need to increase the connection flow controller's value |
| 504 // by the incremental difference. |
| 505 if (stream_contributes_to_connection_flow_control_) { |
| 506 connection_flow_controller_->UpdateHighestReceivedOffset( |
| 507 connection_flow_controller_->highest_received_byte_offset() + |
| 508 increment); |
| 509 } |
| 510 return true; |
| 509 } | 511 } |
| 510 | 512 |
| 511 void ReliableQuicStream::AddBytesSent(uint64 bytes) { | 513 void ReliableQuicStream::AddBytesSent(uint64 bytes) { |
| 512 if (flow_controller_.IsEnabled()) { | 514 if (flow_controller_.IsEnabled()) { |
| 513 flow_controller_.AddBytesSent(bytes); | 515 flow_controller_.AddBytesSent(bytes); |
| 514 if (stream_contributes_to_connection_flow_control_) { | 516 if (stream_contributes_to_connection_flow_control_) { |
| 515 connection_flow_controller_->AddBytesSent(bytes); | 517 connection_flow_controller_->AddBytesSent(bytes); |
| 516 } | 518 } |
| 517 } | 519 } |
| 518 } | 520 } |
| 519 | 521 |
| 520 void ReliableQuicStream::AddBytesConsumed(uint64 bytes) { | 522 void ReliableQuicStream::AddBytesConsumed(uint64 bytes) { |
| 521 if (flow_controller_.IsEnabled()) { | 523 if (flow_controller_.IsEnabled()) { |
| 522 // Only adjust stream level flow controller if we are still reading. | 524 // Only adjust stream level flow controller if we are still reading. |
| 523 if (!read_side_closed_) { | 525 if (!read_side_closed_) { |
| 524 flow_controller_.AddBytesConsumed(bytes); | 526 flow_controller_.AddBytesConsumed(bytes); |
| 525 } | 527 } |
| 526 | 528 |
| 527 if (stream_contributes_to_connection_flow_control_) { | 529 if (stream_contributes_to_connection_flow_control_) { |
| 528 connection_flow_controller_->AddBytesConsumed(bytes); | 530 connection_flow_controller_->AddBytesConsumed(bytes); |
| 529 } | 531 } |
| 530 } | 532 } |
| 531 } | 533 } |
| 532 | 534 |
| 533 bool ReliableQuicStream::IsFlowControlBlocked() { | 535 bool ReliableQuicStream::IsFlowControlBlocked() { |
| 534 bool stream_flow_control_blocked = flow_controller_.IsBlocked(); | 536 if (flow_controller_.IsBlocked()) { |
| 535 bool connecton_flow_control_blocked = | 537 return true; |
| 536 stream_contributes_to_connection_flow_control_ && | 538 } |
| 539 return stream_contributes_to_connection_flow_control_ && |
| 537 connection_flow_controller_->IsBlocked(); | 540 connection_flow_controller_->IsBlocked(); |
| 538 return stream_flow_control_blocked || connecton_flow_control_blocked; | |
| 539 } | 541 } |
| 540 | 542 |
| 541 } // namespace net | 543 } // namespace net |
| OLD | NEW |