OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/quic_data_stream.h" | 5 #include "net/quic/quic_data_stream.h" |
6 | 6 |
7 #include "net/quic/quic_ack_notifier.h" | 7 #include "net/quic/quic_ack_notifier.h" |
8 #include "net/quic/quic_connection.h" | 8 #include "net/quic/quic_connection.h" |
9 #include "net/quic/quic_utils.h" | 9 #include "net/quic/quic_utils.h" |
10 #include "net/quic/quic_write_blocked_list.h" | 10 #include "net/quic/quic_write_blocked_list.h" |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 2 * kWindow / 3)); | 396 2 * kWindow / 3)); |
397 stream_->OnStreamFrame(frame2); | 397 stream_->OnStreamFrame(frame2); |
398 EXPECT_EQ(kWindow, QuicFlowControllerPeer::ReceiveWindowSize( | 398 EXPECT_EQ(kWindow, QuicFlowControllerPeer::ReceiveWindowSize( |
399 stream_->flow_controller())); | 399 stream_->flow_controller())); |
400 } | 400 } |
401 | 401 |
402 TEST_P(QuicDataStreamTest, ConnectionFlowControlWindowUpdate) { | 402 TEST_P(QuicDataStreamTest, ConnectionFlowControlWindowUpdate) { |
403 // Tests that on receipt of data, the connection updates its receive window | 403 // Tests that on receipt of data, the connection updates its receive window |
404 // offset appropriately, and sends WINDOW_UPDATE frames when its receive | 404 // offset appropriately, and sends WINDOW_UPDATE frames when its receive |
405 // window drops too low. | 405 // window drops too low. |
406 if (GetParam() < QUIC_VERSION_19) { | |
407 return; | |
408 } | |
409 Initialize(kShouldProcessData); | 406 Initialize(kShouldProcessData); |
410 | 407 |
411 // Set a small flow control limit for streams and connection. | 408 // Set a small flow control limit for streams and connection. |
412 const uint64 kWindow = 36; | 409 const uint64 kWindow = 36; |
413 QuicFlowControllerPeer::SetReceiveWindowOffset(stream_->flow_controller(), | 410 QuicFlowControllerPeer::SetReceiveWindowOffset(stream_->flow_controller(), |
414 kWindow); | 411 kWindow); |
415 QuicFlowControllerPeer::SetMaxReceiveWindow(stream_->flow_controller(), | 412 QuicFlowControllerPeer::SetMaxReceiveWindow(stream_->flow_controller(), |
416 kWindow); | 413 kWindow); |
417 QuicFlowControllerPeer::SetReceiveWindowOffset(stream2_->flow_controller(), | 414 QuicFlowControllerPeer::SetReceiveWindowOffset(stream2_->flow_controller(), |
418 kWindow); | 415 kWindow); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 QuicStreamFrame frame(kClientDataStreamId1, false, 0, MakeIOVector(body)); | 474 QuicStreamFrame frame(kClientDataStreamId1, false, 0, MakeIOVector(body)); |
478 EXPECT_CALL(*connection_, | 475 EXPECT_CALL(*connection_, |
479 SendConnectionClose(QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA)); | 476 SendConnectionClose(QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA)); |
480 stream_->OnStreamFrame(frame); | 477 stream_->OnStreamFrame(frame); |
481 } | 478 } |
482 | 479 |
483 TEST_P(QuicDataStreamTest, ConnectionFlowControlViolation) { | 480 TEST_P(QuicDataStreamTest, ConnectionFlowControlViolation) { |
484 // Tests that on if the peer sends too much data (i.e. violates the flow | 481 // Tests that on if the peer sends too much data (i.e. violates the flow |
485 // control protocol), at the connection level (rather than the stream level) | 482 // control protocol), at the connection level (rather than the stream level) |
486 // then we terminate the connection. | 483 // then we terminate the connection. |
487 if (GetParam() < QUIC_VERSION_19) { | |
488 return; | |
489 } | |
490 | 484 |
491 // Stream should not process data, so that data gets buffered in the | 485 // Stream should not process data, so that data gets buffered in the |
492 // sequencer, triggering flow control limits. | 486 // sequencer, triggering flow control limits. |
493 Initialize(!kShouldProcessData); | 487 Initialize(!kShouldProcessData); |
494 | 488 |
495 // Set a small flow control window on streams, and connection. | 489 // Set a small flow control window on streams, and connection. |
496 const uint64 kStreamWindow = 50; | 490 const uint64 kStreamWindow = 50; |
497 const uint64 kConnectionWindow = 10; | 491 const uint64 kConnectionWindow = 10; |
498 QuicFlowControllerPeer::SetReceiveWindowOffset(stream_->flow_controller(), | 492 QuicFlowControllerPeer::SetReceiveWindowOffset(stream_->flow_controller(), |
499 kStreamWindow); | 493 kStreamWindow); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 EXPECT_CALL(*connection_, SendBlocked(kClientDataStreamId1)).Times(0); | 528 EXPECT_CALL(*connection_, SendBlocked(kClientDataStreamId1)).Times(0); |
535 EXPECT_CALL(*session_, WritevData(kClientDataStreamId1, _, _, _, _, _)) | 529 EXPECT_CALL(*session_, WritevData(kClientDataStreamId1, _, _, _, _, _)) |
536 .WillOnce(Return(QuicConsumedData(0, fin))); | 530 .WillOnce(Return(QuicConsumedData(0, fin))); |
537 | 531 |
538 stream_->WriteOrBufferData(body, fin, nullptr); | 532 stream_->WriteOrBufferData(body, fin, nullptr); |
539 } | 533 } |
540 | 534 |
541 } // namespace | 535 } // namespace |
542 } // namespace test | 536 } // namespace test |
543 } // namespace net | 537 } // namespace net |
OLD | NEW |