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 "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_flags.h" | 9 #include "net/quic/quic_flags.h" |
10 #include "net/quic/quic_utils.h" | 10 #include "net/quic/quic_utils.h" |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 | 464 |
465 const int kDataSize = 16 * 1024; | 465 const int kDataSize = 16 * 1024; |
466 const string kData(kDataSize, 'a'); | 466 const string kData(kDataSize, 'a'); |
467 | 467 |
468 const int kFirstWriteSize = 100; | 468 const int kFirstWriteSize = 100; |
469 const int kSecondWriteSize = 50; | 469 const int kSecondWriteSize = 50; |
470 const int kLastWriteSize = kDataSize - kFirstWriteSize - kSecondWriteSize; | 470 const int kLastWriteSize = kDataSize - kFirstWriteSize - kSecondWriteSize; |
471 | 471 |
472 // Set a large flow control send window so this doesn't interfere with test. | 472 // Set a large flow control send window so this doesn't interfere with test. |
473 stream_->flow_controller()->UpdateSendWindowOffset(kDataSize + 1); | 473 stream_->flow_controller()->UpdateSendWindowOffset(kDataSize + 1); |
474 if (FLAGS_enable_quic_connection_flow_control) { | 474 if (FLAGS_enable_quic_connection_flow_control_2) { |
475 session_->flow_controller()->UpdateSendWindowOffset(kDataSize + 1); | 475 session_->flow_controller()->UpdateSendWindowOffset(kDataSize + 1); |
476 } | 476 } |
477 | 477 |
478 scoped_refptr<QuicAckNotifier::DelegateInterface> proxy_delegate; | 478 scoped_refptr<QuicAckNotifier::DelegateInterface> proxy_delegate; |
479 | 479 |
480 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)) | 480 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)) |
481 .WillOnce(DoAll(WithArgs<5>(Invoke(CreateFunctor( | 481 .WillOnce(DoAll(WithArgs<5>(Invoke(CreateFunctor( |
482 &SaveProxyAckNotifierDelegate, &proxy_delegate))), | 482 &SaveProxyAckNotifierDelegate, &proxy_delegate))), |
483 Return(QuicConsumedData(kFirstWriteSize, false)))); | 483 Return(QuicConsumedData(kFirstWriteSize, false)))); |
484 stream_->WriteOrBufferData(kData, false, delegate.get()); | 484 stream_->WriteOrBufferData(kData, false, delegate.get()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 scoped_refptr<MockAckNotifierDelegate> delegate( | 519 scoped_refptr<MockAckNotifierDelegate> delegate( |
520 new StrictMock<MockAckNotifierDelegate>); | 520 new StrictMock<MockAckNotifierDelegate>); |
521 | 521 |
522 const int kDataSize = 16 * 1024; | 522 const int kDataSize = 16 * 1024; |
523 const string kData(kDataSize, 'a'); | 523 const string kData(kDataSize, 'a'); |
524 | 524 |
525 const int kInitialWriteSize = 100; | 525 const int kInitialWriteSize = 100; |
526 | 526 |
527 // Set a large flow control send window so this doesn't interfere with test. | 527 // Set a large flow control send window so this doesn't interfere with test. |
528 stream_->flow_controller()->UpdateSendWindowOffset(kDataSize + 1); | 528 stream_->flow_controller()->UpdateSendWindowOffset(kDataSize + 1); |
529 if (FLAGS_enable_quic_connection_flow_control) { | 529 if (FLAGS_enable_quic_connection_flow_control_2) { |
530 session_->flow_controller()->UpdateSendWindowOffset(kDataSize + 1); | 530 session_->flow_controller()->UpdateSendWindowOffset(kDataSize + 1); |
531 } | 531 } |
532 | 532 |
533 scoped_refptr<QuicAckNotifier::DelegateInterface> proxy_delegate; | 533 scoped_refptr<QuicAckNotifier::DelegateInterface> proxy_delegate; |
534 | 534 |
535 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)) | 535 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)) |
536 .WillOnce(DoAll(WithArgs<5>(Invoke(CreateFunctor( | 536 .WillOnce(DoAll(WithArgs<5>(Invoke(CreateFunctor( |
537 &SaveProxyAckNotifierDelegate, &proxy_delegate))), | 537 &SaveProxyAckNotifierDelegate, &proxy_delegate))), |
538 Return(QuicConsumedData(kInitialWriteSize, false)))); | 538 Return(QuicConsumedData(kInitialWriteSize, false)))); |
539 stream_->WriteOrBufferData(kData, false, delegate.get()); | 539 stream_->WriteOrBufferData(kData, false, delegate.get()); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 } | 630 } |
631 | 631 |
632 // Verify that when we receive a packet which violates flow control (i.e. sends | 632 // Verify that when we receive a packet which violates flow control (i.e. sends |
633 // too much data on the stream) that the stream sequencer never sees this frame, | 633 // too much data on the stream) that the stream sequencer never sees this frame, |
634 // as we check for violation and close the connection early. | 634 // as we check for violation and close the connection early. |
635 TEST_F(ReliableQuicStreamTest, | 635 TEST_F(ReliableQuicStreamTest, |
636 StreamSequencerNeverSeesPacketsViolatingFlowControl) { | 636 StreamSequencerNeverSeesPacketsViolatingFlowControl) { |
637 ValueRestore<bool> old_stream_flag( | 637 ValueRestore<bool> old_stream_flag( |
638 &FLAGS_enable_quic_stream_flow_control_2, true); | 638 &FLAGS_enable_quic_stream_flow_control_2, true); |
639 ValueRestore<bool> old_connection_flag( | 639 ValueRestore<bool> old_connection_flag( |
640 &FLAGS_enable_quic_connection_flow_control, true); | 640 &FLAGS_enable_quic_connection_flow_control_2, true); |
641 | 641 |
642 Initialize(kShouldProcessData); | 642 Initialize(kShouldProcessData); |
643 | 643 |
644 // Receive a stream frame that violates flow control: the byte offset is | 644 // Receive a stream frame that violates flow control: the byte offset is |
645 // higher than the receive window offset. | 645 // higher than the receive window offset. |
646 QuicStreamFrame frame(stream_->id(), false, | 646 QuicStreamFrame frame(stream_->id(), false, |
647 kInitialFlowControlWindowForTest + 1, | 647 kInitialFlowControlWindowForTest + 1, |
648 MakeIOVector(".")); | 648 MakeIOVector(".")); |
649 EXPECT_GT(frame.offset, QuicFlowControllerPeer::ReceiveWindowOffset( | 649 EXPECT_GT(frame.offset, QuicFlowControllerPeer::ReceiveWindowOffset( |
650 stream_->flow_controller())); | 650 stream_->flow_controller())); |
(...skipping 25 matching lines...) Expand all Loading... |
676 | 676 |
677 EXPECT_FALSE(stream_->HasFinalReceivedByteOffset()); | 677 EXPECT_FALSE(stream_->HasFinalReceivedByteOffset()); |
678 QuicRstStreamFrame rst_frame(stream_->id(), QUIC_STREAM_CANCELLED, 1234); | 678 QuicRstStreamFrame rst_frame(stream_->id(), QUIC_STREAM_CANCELLED, 1234); |
679 stream_->OnStreamReset(rst_frame); | 679 stream_->OnStreamReset(rst_frame); |
680 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); | 680 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); |
681 } | 681 } |
682 | 682 |
683 } // namespace | 683 } // namespace |
684 } // namespace test | 684 } // namespace test |
685 } // namespace net | 685 } // namespace net |
OLD | NEW |