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" | |
10 #include "net/quic/quic_utils.h" | 9 #include "net/quic/quic_utils.h" |
11 #include "net/quic/quic_write_blocked_list.h" | 10 #include "net/quic/quic_write_blocked_list.h" |
12 #include "net/quic/spdy_utils.h" | 11 #include "net/quic/spdy_utils.h" |
13 #include "net/quic/test_tools/quic_config_peer.h" | 12 #include "net/quic/test_tools/quic_config_peer.h" |
14 #include "net/quic/test_tools/quic_connection_peer.h" | 13 #include "net/quic/test_tools/quic_connection_peer.h" |
15 #include "net/quic/test_tools/quic_flow_controller_peer.h" | 14 #include "net/quic/test_tools/quic_flow_controller_peer.h" |
16 #include "net/quic/test_tools/quic_session_peer.h" | 15 #include "net/quic/test_tools/quic_session_peer.h" |
17 #include "net/quic/test_tools/quic_test_utils.h" | 16 #include "net/quic/test_tools/quic_test_utils.h" |
18 #include "net/quic/test_tools/reliable_quic_stream_peer.h" | 17 #include "net/quic/test_tools/reliable_quic_stream_peer.h" |
19 #include "net/test/gtest_util.h" | 18 #include "net/test/gtest_util.h" |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 | 463 |
465 const int kDataSize = 16 * 1024; | 464 const int kDataSize = 16 * 1024; |
466 const string kData(kDataSize, 'a'); | 465 const string kData(kDataSize, 'a'); |
467 | 466 |
468 const int kFirstWriteSize = 100; | 467 const int kFirstWriteSize = 100; |
469 const int kSecondWriteSize = 50; | 468 const int kSecondWriteSize = 50; |
470 const int kLastWriteSize = kDataSize - kFirstWriteSize - kSecondWriteSize; | 469 const int kLastWriteSize = kDataSize - kFirstWriteSize - kSecondWriteSize; |
471 | 470 |
472 // Set a large flow control send window so this doesn't interfere with test. | 471 // Set a large flow control send window so this doesn't interfere with test. |
473 stream_->flow_controller()->UpdateSendWindowOffset(kDataSize + 1); | 472 stream_->flow_controller()->UpdateSendWindowOffset(kDataSize + 1); |
474 if (FLAGS_enable_quic_connection_flow_control_2) { | 473 session_->flow_controller()->UpdateSendWindowOffset(kDataSize + 1); |
475 session_->flow_controller()->UpdateSendWindowOffset(kDataSize + 1); | |
476 } | |
477 | 474 |
478 scoped_refptr<QuicAckNotifier::DelegateInterface> proxy_delegate; | 475 scoped_refptr<QuicAckNotifier::DelegateInterface> proxy_delegate; |
479 | 476 |
480 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)) | 477 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)) |
481 .WillOnce(DoAll(WithArgs<5>(Invoke(CreateFunctor( | 478 .WillOnce(DoAll(WithArgs<5>(Invoke(CreateFunctor( |
482 &SaveProxyAckNotifierDelegate, &proxy_delegate))), | 479 &SaveProxyAckNotifierDelegate, &proxy_delegate))), |
483 Return(QuicConsumedData(kFirstWriteSize, false)))); | 480 Return(QuicConsumedData(kFirstWriteSize, false)))); |
484 stream_->WriteOrBufferData(kData, false, delegate.get()); | 481 stream_->WriteOrBufferData(kData, false, delegate.get()); |
485 EXPECT_TRUE(HasWriteBlockedStreams()); | 482 EXPECT_TRUE(HasWriteBlockedStreams()); |
486 | 483 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 scoped_refptr<MockAckNotifierDelegate> delegate( | 516 scoped_refptr<MockAckNotifierDelegate> delegate( |
520 new StrictMock<MockAckNotifierDelegate>); | 517 new StrictMock<MockAckNotifierDelegate>); |
521 | 518 |
522 const int kDataSize = 16 * 1024; | 519 const int kDataSize = 16 * 1024; |
523 const string kData(kDataSize, 'a'); | 520 const string kData(kDataSize, 'a'); |
524 | 521 |
525 const int kInitialWriteSize = 100; | 522 const int kInitialWriteSize = 100; |
526 | 523 |
527 // Set a large flow control send window so this doesn't interfere with test. | 524 // Set a large flow control send window so this doesn't interfere with test. |
528 stream_->flow_controller()->UpdateSendWindowOffset(kDataSize + 1); | 525 stream_->flow_controller()->UpdateSendWindowOffset(kDataSize + 1); |
529 if (FLAGS_enable_quic_connection_flow_control_2) { | 526 session_->flow_controller()->UpdateSendWindowOffset(kDataSize + 1); |
530 session_->flow_controller()->UpdateSendWindowOffset(kDataSize + 1); | |
531 } | |
532 | 527 |
533 scoped_refptr<QuicAckNotifier::DelegateInterface> proxy_delegate; | 528 scoped_refptr<QuicAckNotifier::DelegateInterface> proxy_delegate; |
534 | 529 |
535 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)) | 530 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _, _)) |
536 .WillOnce(DoAll(WithArgs<5>(Invoke(CreateFunctor( | 531 .WillOnce(DoAll(WithArgs<5>(Invoke(CreateFunctor( |
537 &SaveProxyAckNotifierDelegate, &proxy_delegate))), | 532 &SaveProxyAckNotifierDelegate, &proxy_delegate))), |
538 Return(QuicConsumedData(kInitialWriteSize, false)))); | 533 Return(QuicConsumedData(kInitialWriteSize, false)))); |
539 stream_->WriteOrBufferData(kData, false, delegate.get()); | 534 stream_->WriteOrBufferData(kData, false, delegate.get()); |
540 EXPECT_TRUE(HasWriteBlockedStreams()); | 535 EXPECT_TRUE(HasWriteBlockedStreams()); |
541 | 536 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 proxy_delegate->OnAckNotification(1, 2, 3, 4, zero_); | 622 proxy_delegate->OnAckNotification(1, 2, 3, 4, zero_); |
628 EXPECT_CALL(*delegate, OnAckNotification(11, 22, 33, 44, zero_)); | 623 EXPECT_CALL(*delegate, OnAckNotification(11, 22, 33, 44, zero_)); |
629 proxy_delegate->OnAckNotification(10, 20, 30, 40, zero_); | 624 proxy_delegate->OnAckNotification(10, 20, 30, 40, zero_); |
630 } | 625 } |
631 | 626 |
632 // Verify that when we receive a packet which violates flow control (i.e. sends | 627 // 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, | 628 // 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. | 629 // as we check for violation and close the connection early. |
635 TEST_F(ReliableQuicStreamTest, | 630 TEST_F(ReliableQuicStreamTest, |
636 StreamSequencerNeverSeesPacketsViolatingFlowControl) { | 631 StreamSequencerNeverSeesPacketsViolatingFlowControl) { |
637 ValueRestore<bool> old_connection_flag( | |
638 &FLAGS_enable_quic_connection_flow_control_2, true); | |
639 | |
640 Initialize(kShouldProcessData); | 632 Initialize(kShouldProcessData); |
641 | 633 |
642 // Receive a stream frame that violates flow control: the byte offset is | 634 // Receive a stream frame that violates flow control: the byte offset is |
643 // higher than the receive window offset. | 635 // higher than the receive window offset. |
644 QuicStreamFrame frame(stream_->id(), false, | 636 QuicStreamFrame frame(stream_->id(), false, |
645 kInitialSessionFlowControlWindowForTest + 1, | 637 kInitialSessionFlowControlWindowForTest + 1, |
646 MakeIOVector(".")); | 638 MakeIOVector(".")); |
647 EXPECT_GT(frame.offset, QuicFlowControllerPeer::ReceiveWindowOffset( | 639 EXPECT_GT(frame.offset, QuicFlowControllerPeer::ReceiveWindowOffset( |
648 stream_->flow_controller())); | 640 stream_->flow_controller())); |
649 | 641 |
(...skipping 24 matching lines...) Expand all Loading... |
674 | 666 |
675 EXPECT_FALSE(stream_->HasFinalReceivedByteOffset()); | 667 EXPECT_FALSE(stream_->HasFinalReceivedByteOffset()); |
676 QuicRstStreamFrame rst_frame(stream_->id(), QUIC_STREAM_CANCELLED, 1234); | 668 QuicRstStreamFrame rst_frame(stream_->id(), QUIC_STREAM_CANCELLED, 1234); |
677 stream_->OnStreamReset(rst_frame); | 669 stream_->OnStreamReset(rst_frame); |
678 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); | 670 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); |
679 } | 671 } |
680 | 672 |
681 } // namespace | 673 } // namespace |
682 } // namespace test | 674 } // namespace test |
683 } // namespace net | 675 } // namespace net |
OLD | NEW |