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/quic_session.h" | 5 #include "net/quic/quic_session.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
12 #include "net/quic/crypto/crypto_protocol.h" | 12 #include "net/quic/crypto/crypto_protocol.h" |
13 #include "net/quic/quic_crypto_stream.h" | 13 #include "net/quic/quic_crypto_stream.h" |
14 #include "net/quic/quic_flags.h" | 14 #include "net/quic/quic_flags.h" |
15 #include "net/quic/quic_protocol.h" | 15 #include "net/quic/quic_protocol.h" |
16 #include "net/quic/quic_utils.h" | 16 #include "net/quic/quic_utils.h" |
17 #include "net/quic/reliable_quic_stream.h" | 17 #include "net/quic/reliable_quic_stream.h" |
18 #include "net/quic/test_tools/quic_config_peer.h" | |
18 #include "net/quic/test_tools/quic_connection_peer.h" | 19 #include "net/quic/test_tools/quic_connection_peer.h" |
19 #include "net/quic/test_tools/quic_data_stream_peer.h" | 20 #include "net/quic/test_tools/quic_data_stream_peer.h" |
20 #include "net/quic/test_tools/quic_flow_controller_peer.h" | 21 #include "net/quic/test_tools/quic_flow_controller_peer.h" |
21 #include "net/quic/test_tools/quic_session_peer.h" | 22 #include "net/quic/test_tools/quic_session_peer.h" |
22 #include "net/quic/test_tools/quic_test_utils.h" | 23 #include "net/quic/test_tools/quic_test_utils.h" |
23 #include "net/quic/test_tools/reliable_quic_stream_peer.h" | 24 #include "net/quic/test_tools/reliable_quic_stream_peer.h" |
24 #include "net/spdy/spdy_framer.h" | 25 #include "net/spdy/spdy_framer.h" |
25 #include "net/test/gtest_util.h" | 26 #include "net/test/gtest_util.h" |
26 #include "testing/gmock/include/gmock/gmock.h" | 27 #include "testing/gmock/include/gmock/gmock.h" |
27 #include "testing/gmock_mutant.h" | 28 #include "testing/gmock_mutant.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 session_->MarkWriteBlocked(stream_id_, kSomeMiddlePriority); | 110 session_->MarkWriteBlocked(stream_id_, kSomeMiddlePriority); |
110 } | 111 } |
111 | 112 |
112 private: | 113 private: |
113 QuicSession* const session_; | 114 QuicSession* const session_; |
114 const QuicStreamId stream_id_; | 115 const QuicStreamId stream_id_; |
115 }; | 116 }; |
116 | 117 |
117 class TestSession : public QuicSession { | 118 class TestSession : public QuicSession { |
118 public: | 119 public: |
119 TestSession(QuicConnection* connection, | 120 explicit TestSession(QuicConnection* connection) |
120 uint32 max_initial_flow_control_window) | 121 : QuicSession(connection, |
121 : QuicSession(connection, max_initial_flow_control_window, | |
122 DefaultQuicConfig()), | 122 DefaultQuicConfig()), |
wtc
2014/06/16 19:35:56
Nit: this should fit on the previous line.
ramant (doing other things)
2014/06/16 21:13:53
Done.
wtc
2014/06/16 22:05:53
You didn't make this change. (It's fine to ignore
| |
123 crypto_stream_(this), | 123 crypto_stream_(this), |
124 writev_consumes_all_data_(false) {} | 124 writev_consumes_all_data_(false) {} |
125 | 125 |
126 virtual TestCryptoStream* GetCryptoStream() OVERRIDE { | 126 virtual TestCryptoStream* GetCryptoStream() OVERRIDE { |
127 return &crypto_stream_; | 127 return &crypto_stream_; |
128 } | 128 } |
129 | 129 |
130 virtual TestStream* CreateOutgoingDataStream() OVERRIDE { | 130 virtual TestStream* CreateOutgoingDataStream() OVERRIDE { |
131 TestStream* stream = new TestStream(GetNextStreamId(), this); | 131 TestStream* stream = new TestStream(GetNextStreamId(), this); |
132 ActivateStream(stream); | 132 ActivateStream(stream); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 private: | 174 private: |
175 StrictMock<TestCryptoStream> crypto_stream_; | 175 StrictMock<TestCryptoStream> crypto_stream_; |
176 | 176 |
177 bool writev_consumes_all_data_; | 177 bool writev_consumes_all_data_; |
178 }; | 178 }; |
179 | 179 |
180 class QuicSessionTest : public ::testing::TestWithParam<QuicVersion> { | 180 class QuicSessionTest : public ::testing::TestWithParam<QuicVersion> { |
181 protected: | 181 protected: |
182 QuicSessionTest() | 182 QuicSessionTest() |
183 : connection_(new MockConnection(true, SupportedVersions(GetParam()))), | 183 : connection_(new MockConnection(true, SupportedVersions(GetParam()))), |
184 session_(connection_, kInitialFlowControlWindowForTest) { | 184 session_(connection_) { |
185 session_.config()->SetInitialFlowControlWindowToSend( | |
186 kInitialFlowControlWindowForTest); | |
185 headers_[":host"] = "www.google.com"; | 187 headers_[":host"] = "www.google.com"; |
186 headers_[":path"] = "/index.hml"; | 188 headers_[":path"] = "/index.hml"; |
187 headers_[":scheme"] = "http"; | 189 headers_[":scheme"] = "http"; |
188 headers_["cookie"] = | 190 headers_["cookie"] = |
189 "__utma=208381060.1228362404.1372200928.1372200928.1372200928.1; " | 191 "__utma=208381060.1228362404.1372200928.1372200928.1372200928.1; " |
190 "__utmc=160408618; " | 192 "__utmc=160408618; " |
191 "GX=DQAAAOEAAACWJYdewdE9rIrW6qw3PtVi2-d729qaa-74KqOsM1NVQblK4VhX" | 193 "GX=DQAAAOEAAACWJYdewdE9rIrW6qw3PtVi2-d729qaa-74KqOsM1NVQblK4VhX" |
192 "hoALMsy6HOdDad2Sz0flUByv7etmo3mLMidGrBoljqO9hSVA40SLqpG_iuKKSHX" | 194 "hoALMsy6HOdDad2Sz0flUByv7etmo3mLMidGrBoljqO9hSVA40SLqpG_iuKKSHX" |
193 "RW3Np4bq0F0SDGDNsW0DSmTS9ufMRrlpARJDS7qAI6M3bghqJp4eABKZiRqebHT" | 195 "RW3Np4bq0F0SDGDNsW0DSmTS9ufMRrlpARJDS7qAI6M3bghqJp4eABKZiRqebHT" |
194 "pMU-RXvTI5D5oCF1vYxYofH_l1Kviuiy3oQ1kS1enqWgbhJ2t61_SNdv-1XJIS0" | 196 "pMU-RXvTI5D5oCF1vYxYofH_l1Kviuiy3oQ1kS1enqWgbhJ2t61_SNdv-1XJIS0" |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
508 CloseStream(stream6->id()); | 510 CloseStream(stream6->id()); |
509 | 511 |
510 InSequence s; | 512 InSequence s; |
511 EXPECT_CALL(*stream2, OnCanWrite()); | 513 EXPECT_CALL(*stream2, OnCanWrite()); |
512 EXPECT_CALL(*stream4, OnCanWrite()); | 514 EXPECT_CALL(*stream4, OnCanWrite()); |
513 session_.OnCanWrite(); | 515 session_.OnCanWrite(); |
514 EXPECT_FALSE(session_.WillingAndAbleToWrite()); | 516 EXPECT_FALSE(session_.WillingAndAbleToWrite()); |
515 } | 517 } |
516 | 518 |
517 TEST_P(QuicSessionTest, OnCanWriteLimitsNumWritesIfFlowControlBlocked) { | 519 TEST_P(QuicSessionTest, OnCanWriteLimitsNumWritesIfFlowControlBlocked) { |
518 ValueRestore<bool> old_flag(&FLAGS_enable_quic_connection_flow_control, true); | |
519 if (version() < QUIC_VERSION_19) { | 520 if (version() < QUIC_VERSION_19) { |
520 return; | 521 return; |
521 } | 522 } |
522 | 523 |
524 ValueRestore<bool> old_flag(&FLAGS_enable_quic_connection_flow_control, true); | |
523 // Ensure connection level flow control blockage. | 525 // Ensure connection level flow control blockage. |
524 QuicFlowControllerPeer::SetSendWindowOffset(session_.flow_controller(), 0); | 526 QuicFlowControllerPeer::SetSendWindowOffset(session_.flow_controller(), 0); |
525 EXPECT_TRUE(session_.flow_controller()->IsBlocked()); | 527 EXPECT_TRUE(session_.flow_controller()->IsBlocked()); |
526 | 528 |
527 // Mark the crypto and headers streams as write blocked, we expect them to be | 529 // Mark the crypto and headers streams as write blocked, we expect them to be |
528 // allowed to write later. | 530 // allowed to write later. |
529 session_.MarkWriteBlocked(kCryptoStreamId, kHighestPriority); | 531 session_.MarkWriteBlocked(kCryptoStreamId, kHighestPriority); |
530 session_.MarkWriteBlocked(kHeadersStreamId, kHighestPriority); | 532 session_.MarkWriteBlocked(kHeadersStreamId, kHighestPriority); |
531 | 533 |
532 // Create a data stream, and although it is write blocked we never expect it | 534 // Create a data stream, and although it is write blocked we never expect it |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
647 | 649 |
648 TEST_P(QuicSessionTest, InvalidFlowControlWindowInHandshake) { | 650 TEST_P(QuicSessionTest, InvalidFlowControlWindowInHandshake) { |
649 // Test that receipt of an invalid (< default) flow control window from peer | 651 // Test that receipt of an invalid (< default) flow control window from peer |
650 // results in the connection being torn down. | 652 // results in the connection being torn down. |
651 if (version() < QUIC_VERSION_17) { | 653 if (version() < QUIC_VERSION_17) { |
652 return; | 654 return; |
653 } | 655 } |
654 ValueRestore<bool> old_flag(&FLAGS_enable_quic_stream_flow_control_2, true); | 656 ValueRestore<bool> old_flag(&FLAGS_enable_quic_stream_flow_control_2, true); |
655 | 657 |
656 uint32 kInvalidWindow = kDefaultFlowControlSendWindow - 1; | 658 uint32 kInvalidWindow = kDefaultFlowControlSendWindow - 1; |
657 | 659 QuicConfigPeer::SetReceivedInitialFlowControlWindow(session_.config(), |
658 CryptoHandshakeMessage msg; | 660 kInvalidWindow); |
659 string error_details; | |
660 session_.config()->SetInitialFlowControlWindowToSend(kInvalidWindow); | |
661 session_.config()->ToHandshakeMessage(&msg); | |
662 const QuicErrorCode error = | |
663 session_.config()->ProcessPeerHello(msg, CLIENT, &error_details); | |
664 EXPECT_EQ(QUIC_NO_ERROR, error); | |
665 | 661 |
666 EXPECT_CALL(*connection_, | 662 EXPECT_CALL(*connection_, |
667 SendConnectionClose(QUIC_FLOW_CONTROL_INVALID_WINDOW)); | 663 SendConnectionClose(QUIC_FLOW_CONTROL_INVALID_WINDOW)).Times(2); |
668 session_.OnConfigNegotiated(); | 664 session_.OnConfigNegotiated(); |
669 } | 665 } |
670 | 666 |
671 | |
672 TEST_P(QuicSessionTest, InvalidFlowControlWindow) { | |
673 // Test that an attempt to create a QuicSession with an invalid (< default) | |
674 // flow control window results in a QuicSession using the default. | |
675 QuicConnection* connection = | |
676 new MockConnection(true, SupportedVersions(GetParam())); | |
677 | |
678 const uint32 kSmallerFlowControlWindow = kDefaultFlowControlSendWindow - 1; | |
679 TestSession session(connection, kSmallerFlowControlWindow); | |
680 | |
681 EXPECT_EQ(kDefaultFlowControlSendWindow, | |
682 session.max_flow_control_receive_window_bytes()); | |
683 } | |
684 | |
685 TEST_P(QuicSessionTest, ConnectionFlowControlAccountingRstOutOfOrder) { | 667 TEST_P(QuicSessionTest, ConnectionFlowControlAccountingRstOutOfOrder) { |
686 FLAGS_enable_quic_stream_flow_control_2 = true; | |
687 FLAGS_enable_quic_connection_flow_control = true; | |
688 if (version() < QUIC_VERSION_19) { | 668 if (version() < QUIC_VERSION_19) { |
689 return; | 669 return; |
690 } | 670 } |
691 | 671 |
672 ValueRestore<bool> old_flag2(&FLAGS_enable_quic_stream_flow_control_2, true); | |
673 ValueRestore<bool> old_flag(&FLAGS_enable_quic_connection_flow_control, true); | |
692 // Test that when we receive an out of order stream RST we correctly adjust | 674 // Test that when we receive an out of order stream RST we correctly adjust |
693 // our connection level flow control receive window. | 675 // our connection level flow control receive window. |
694 // On close, the stream should mark as consumed all bytes between the highest | 676 // On close, the stream should mark as consumed all bytes between the highest |
695 // byte consumed so far and the final byte offset from the RST frame. | 677 // byte consumed so far and the final byte offset from the RST frame. |
696 TestStream* stream = session_.CreateOutgoingDataStream(); | 678 TestStream* stream = session_.CreateOutgoingDataStream(); |
697 | 679 |
698 const QuicStreamOffset kByteOffset = 1 + kInitialFlowControlWindowForTest / 2; | 680 const QuicStreamOffset kByteOffset = 1 + kInitialFlowControlWindowForTest / 2; |
699 // Expect no stream WINDOW_UPDATE frames, as stream read side closed. | 681 // Expect no stream WINDOW_UPDATE frames, as stream read side closed. |
700 EXPECT_CALL(*connection_, SendWindowUpdate(stream->id(), _)).Times(0); | 682 EXPECT_CALL(*connection_, SendWindowUpdate(stream->id(), _)).Times(0); |
701 // We do expect a connection level WINDOW_UPDATE when the stream is reset. | 683 // We do expect a connection level WINDOW_UPDATE when the stream is reset. |
702 EXPECT_CALL(*connection_, | 684 EXPECT_CALL(*connection_, |
703 SendWindowUpdate( | 685 SendWindowUpdate( |
704 0, kInitialFlowControlWindowForTest + kByteOffset)).Times(1); | 686 0, kInitialFlowControlWindowForTest + kByteOffset)).Times(1); |
705 | 687 |
706 QuicRstStreamFrame rst_frame(stream->id(), QUIC_STREAM_CANCELLED, | 688 QuicRstStreamFrame rst_frame(stream->id(), QUIC_STREAM_CANCELLED, |
707 kByteOffset); | 689 kByteOffset); |
708 session_.OnRstStream(rst_frame); | 690 session_.OnRstStream(rst_frame); |
709 session_.PostProcessAfterData(); | 691 session_.PostProcessAfterData(); |
710 EXPECT_EQ(kByteOffset, session_.flow_controller()->bytes_consumed()); | 692 EXPECT_EQ(kByteOffset, session_.flow_controller()->bytes_consumed()); |
711 } | 693 } |
712 | 694 |
713 TEST_P(QuicSessionTest, ConnectionFlowControlAccountingFinAndLocalReset) { | 695 TEST_P(QuicSessionTest, ConnectionFlowControlAccountingFinAndLocalReset) { |
714 FLAGS_enable_quic_stream_flow_control_2 = true; | |
715 FLAGS_enable_quic_connection_flow_control = true; | |
716 if (version() < QUIC_VERSION_19) { | 696 if (version() < QUIC_VERSION_19) { |
717 return; | 697 return; |
718 } | 698 } |
719 | 699 |
700 ValueRestore<bool> old_flag2(&FLAGS_enable_quic_stream_flow_control_2, true); | |
701 ValueRestore<bool> old_flag(&FLAGS_enable_quic_connection_flow_control, true); | |
720 // Test the situation where we receive a FIN on a stream, and before we fully | 702 // Test the situation where we receive a FIN on a stream, and before we fully |
721 // consume all the data from the sequencer buffer we locally RST the stream. | 703 // consume all the data from the sequencer buffer we locally RST the stream. |
722 // The bytes between highest consumed byte, and the final byte offset that we | 704 // The bytes between highest consumed byte, and the final byte offset that we |
723 // determined when the FIN arrived, should be marked as consumed at the | 705 // determined when the FIN arrived, should be marked as consumed at the |
724 // connection level flow controller when the stream is reset. | 706 // connection level flow controller when the stream is reset. |
725 TestStream* stream = session_.CreateOutgoingDataStream(); | 707 TestStream* stream = session_.CreateOutgoingDataStream(); |
726 | 708 |
727 const QuicStreamOffset kByteOffset = 1 + kInitialFlowControlWindowForTest / 2; | 709 const QuicStreamOffset kByteOffset = 1 + kInitialFlowControlWindowForTest / 2; |
728 QuicStreamFrame frame(stream->id(), true, kByteOffset, IOVector()); | 710 QuicStreamFrame frame(stream->id(), true, kByteOffset, IOVector()); |
729 vector<QuicStreamFrame> frames; | 711 vector<QuicStreamFrame> frames; |
(...skipping 15 matching lines...) Expand all Loading... | |
745 // Reset stream locally. | 727 // Reset stream locally. |
746 stream->Reset(QUIC_STREAM_CANCELLED); | 728 stream->Reset(QUIC_STREAM_CANCELLED); |
747 | 729 |
748 EXPECT_EQ(kByteOffset, session_.flow_controller()->bytes_consumed()); | 730 EXPECT_EQ(kByteOffset, session_.flow_controller()->bytes_consumed()); |
749 } | 731 } |
750 | 732 |
751 TEST_P(QuicSessionTest, ConnectionFlowControlAccountingFinAfterRst) { | 733 TEST_P(QuicSessionTest, ConnectionFlowControlAccountingFinAfterRst) { |
752 // Test that when we RST the stream (and tear down stream state), and then | 734 // Test that when we RST the stream (and tear down stream state), and then |
753 // receive a FIN from the peer, we correctly adjust our connection level flow | 735 // receive a FIN from the peer, we correctly adjust our connection level flow |
754 // control receive window. | 736 // control receive window. |
755 FLAGS_enable_quic_connection_flow_control = true; | |
756 if (version() < QUIC_VERSION_19) { | 737 if (version() < QUIC_VERSION_19) { |
757 return; | 738 return; |
758 } | 739 } |
759 | 740 |
741 ValueRestore<bool> old_flag2(&FLAGS_enable_quic_stream_flow_control_2, true); | |
742 ValueRestore<bool> old_flag(&FLAGS_enable_quic_connection_flow_control, true); | |
760 // Connection starts with some non-zero highest received byte offset, | 743 // Connection starts with some non-zero highest received byte offset, |
761 // due to other active streams. | 744 // due to other active streams. |
762 const uint64 kInitialConnectionBytesConsumed = 567; | 745 const uint64 kInitialConnectionBytesConsumed = 567; |
763 const uint64 kInitialConnectionHighestReceivedOffset = 1234; | 746 const uint64 kInitialConnectionHighestReceivedOffset = 1234; |
764 EXPECT_LT(kInitialConnectionBytesConsumed, | 747 EXPECT_LT(kInitialConnectionBytesConsumed, |
765 kInitialConnectionHighestReceivedOffset); | 748 kInitialConnectionHighestReceivedOffset); |
766 session_.flow_controller()->UpdateHighestReceivedOffset( | 749 session_.flow_controller()->UpdateHighestReceivedOffset( |
767 kInitialConnectionHighestReceivedOffset); | 750 kInitialConnectionHighestReceivedOffset); |
768 session_.flow_controller()->AddBytesConsumed(kInitialConnectionBytesConsumed); | 751 session_.flow_controller()->AddBytesConsumed(kInitialConnectionBytesConsumed); |
769 | 752 |
(...skipping 18 matching lines...) Expand all Loading... | |
788 session_.flow_controller()->bytes_consumed()); | 771 session_.flow_controller()->bytes_consumed()); |
789 EXPECT_EQ( | 772 EXPECT_EQ( |
790 kInitialConnectionHighestReceivedOffset + total_stream_bytes_sent_by_peer, | 773 kInitialConnectionHighestReceivedOffset + total_stream_bytes_sent_by_peer, |
791 session_.flow_controller()->highest_received_byte_offset()); | 774 session_.flow_controller()->highest_received_byte_offset()); |
792 } | 775 } |
793 | 776 |
794 TEST_P(QuicSessionTest, ConnectionFlowControlAccountingRstAfterRst) { | 777 TEST_P(QuicSessionTest, ConnectionFlowControlAccountingRstAfterRst) { |
795 // Test that when we RST the stream (and tear down stream state), and then | 778 // Test that when we RST the stream (and tear down stream state), and then |
796 // receive a RST from the peer, we correctly adjust our connection level flow | 779 // receive a RST from the peer, we correctly adjust our connection level flow |
797 // control receive window. | 780 // control receive window. |
798 FLAGS_enable_quic_connection_flow_control = true; | |
799 if (version() < QUIC_VERSION_19) { | 781 if (version() < QUIC_VERSION_19) { |
800 return; | 782 return; |
801 } | 783 } |
802 | 784 |
785 ValueRestore<bool> old_flag2(&FLAGS_enable_quic_stream_flow_control_2, true); | |
786 ValueRestore<bool> old_flag(&FLAGS_enable_quic_connection_flow_control, true); | |
803 // Connection starts with some non-zero highest received byte offset, | 787 // Connection starts with some non-zero highest received byte offset, |
804 // due to other active streams. | 788 // due to other active streams. |
805 const uint64 kInitialConnectionBytesConsumed = 567; | 789 const uint64 kInitialConnectionBytesConsumed = 567; |
806 const uint64 kInitialConnectionHighestReceivedOffset = 1234; | 790 const uint64 kInitialConnectionHighestReceivedOffset = 1234; |
807 EXPECT_LT(kInitialConnectionBytesConsumed, | 791 EXPECT_LT(kInitialConnectionBytesConsumed, |
808 kInitialConnectionHighestReceivedOffset); | 792 kInitialConnectionHighestReceivedOffset); |
809 session_.flow_controller()->UpdateHighestReceivedOffset( | 793 session_.flow_controller()->UpdateHighestReceivedOffset( |
810 kInitialConnectionHighestReceivedOffset); | 794 kInitialConnectionHighestReceivedOffset); |
811 session_.flow_controller()->AddBytesConsumed(kInitialConnectionBytesConsumed); | 795 session_.flow_controller()->AddBytesConsumed(kInitialConnectionBytesConsumed); |
812 | 796 |
(...skipping 14 matching lines...) Expand all Loading... | |
827 EXPECT_EQ(kInitialConnectionHighestReceivedOffset + kByteOffset, | 811 EXPECT_EQ(kInitialConnectionHighestReceivedOffset + kByteOffset, |
828 session_.flow_controller()->highest_received_byte_offset()); | 812 session_.flow_controller()->highest_received_byte_offset()); |
829 } | 813 } |
830 | 814 |
831 TEST_P(QuicSessionTest, FlowControlWithInvalidFinalOffset) { | 815 TEST_P(QuicSessionTest, FlowControlWithInvalidFinalOffset) { |
832 // Test that if we receive a stream RST with a highest byte offset that | 816 // Test that if we receive a stream RST with a highest byte offset that |
833 // violates flow control, that we close the connection. | 817 // violates flow control, that we close the connection. |
834 if (version() < QUIC_VERSION_17) { | 818 if (version() < QUIC_VERSION_17) { |
835 return; | 819 return; |
836 } | 820 } |
837 FLAGS_enable_quic_stream_flow_control_2 = true; | 821 ValueRestore<bool> old_flag2(&FLAGS_enable_quic_stream_flow_control_2, true); |
838 FLAGS_enable_quic_connection_flow_control = true; | 822 ValueRestore<bool> old_flag(&FLAGS_enable_quic_connection_flow_control, true); |
839 | 823 |
840 const uint64 kLargeOffset = kInitialFlowControlWindowForTest + 1; | 824 const uint64 kLargeOffset = kInitialFlowControlWindowForTest + 1; |
841 EXPECT_CALL(*connection_, | 825 EXPECT_CALL(*connection_, |
842 SendConnectionClose(QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA)) | 826 SendConnectionClose(QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA)) |
843 .Times(2); | 827 .Times(2); |
844 | 828 |
845 // Check that stream frame + FIN results in connection close. | 829 // Check that stream frame + FIN results in connection close. |
846 TestStream* stream = session_.CreateOutgoingDataStream(); | 830 TestStream* stream = session_.CreateOutgoingDataStream(); |
847 stream->Reset(QUIC_STREAM_CANCELLED); | 831 stream->Reset(QUIC_STREAM_CANCELLED); |
848 QuicStreamFrame frame(stream->id(), true, kLargeOffset, IOVector()); | 832 QuicStreamFrame frame(stream->id(), true, kLargeOffset, IOVector()); |
849 vector<QuicStreamFrame> frames; | 833 vector<QuicStreamFrame> frames; |
850 frames.push_back(frame); | 834 frames.push_back(frame); |
851 session_.OnStreamFrames(frames); | 835 session_.OnStreamFrames(frames); |
852 | 836 |
853 // Check that RST results in connection close. | 837 // Check that RST results in connection close. |
854 QuicRstStreamFrame rst_frame(stream->id(), QUIC_STREAM_CANCELLED, | 838 QuicRstStreamFrame rst_frame(stream->id(), QUIC_STREAM_CANCELLED, |
855 kLargeOffset); | 839 kLargeOffset); |
856 session_.OnRstStream(rst_frame); | 840 session_.OnRstStream(rst_frame); |
857 } | 841 } |
858 | 842 |
859 TEST_P(QuicSessionTest, VersionNegotiationDisablesFlowControl) { | 843 TEST_P(QuicSessionTest, VersionNegotiationDisablesFlowControl) { |
860 ValueRestore<bool> old_stream_flag( | |
861 &FLAGS_enable_quic_stream_flow_control_2, true); | |
862 ValueRestore<bool> old_connection_flag( | |
863 &FLAGS_enable_quic_connection_flow_control, true); | |
864 if (version() < QUIC_VERSION_19) { | 844 if (version() < QUIC_VERSION_19) { |
865 return; | 845 return; |
866 } | 846 } |
867 | 847 |
848 ValueRestore<bool> old_flag2(&FLAGS_enable_quic_stream_flow_control_2, true); | |
849 ValueRestore<bool> old_flag(&FLAGS_enable_quic_connection_flow_control, true); | |
868 // Test that after successful version negotiation, flow control is disabled | 850 // Test that after successful version negotiation, flow control is disabled |
869 // appropriately at both the connection and stream level. | 851 // appropriately at both the connection and stream level. |
870 | 852 |
871 // Initially both stream and connection flow control are enabled. | 853 // Initially both stream and connection flow control are enabled. |
872 TestStream* stream = session_.CreateOutgoingDataStream(); | 854 TestStream* stream = session_.CreateOutgoingDataStream(); |
873 EXPECT_TRUE(stream->flow_controller()->IsEnabled()); | 855 EXPECT_TRUE(stream->flow_controller()->IsEnabled()); |
874 EXPECT_TRUE(session_.flow_controller()->IsEnabled()); | 856 EXPECT_TRUE(session_.flow_controller()->IsEnabled()); |
875 | 857 |
876 // Version 17 implies that stream flow control is enabled, but connection | 858 // Version 17 implies that stream flow control is enabled, but connection |
877 // level is disabled. | 859 // level is disabled. |
878 session_.OnSuccessfulVersionNegotiation(QUIC_VERSION_17); | 860 session_.OnSuccessfulVersionNegotiation(QUIC_VERSION_17); |
879 EXPECT_FALSE(session_.flow_controller()->IsEnabled()); | 861 EXPECT_FALSE(session_.flow_controller()->IsEnabled()); |
880 EXPECT_TRUE(stream->flow_controller()->IsEnabled()); | 862 EXPECT_TRUE(stream->flow_controller()->IsEnabled()); |
881 | 863 |
882 // Version 16 means all flow control is disabled. | 864 // Version 16 means all flow control is disabled. |
883 session_.OnSuccessfulVersionNegotiation(QUIC_VERSION_16); | 865 session_.OnSuccessfulVersionNegotiation(QUIC_VERSION_16); |
884 EXPECT_FALSE(session_.flow_controller()->IsEnabled()); | 866 EXPECT_FALSE(session_.flow_controller()->IsEnabled()); |
885 EXPECT_FALSE(stream->flow_controller()->IsEnabled()); | 867 EXPECT_FALSE(stream->flow_controller()->IsEnabled()); |
886 } | 868 } |
887 | 869 |
888 } // namespace | 870 } // namespace |
889 } // namespace test | 871 } // namespace test |
890 } // namespace net | 872 } // namespace net |
OLD | NEW |