Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: net/quic/core/quic_session_test.cc

Issue 2825083003: Landing Recent QUIC changes until Mon Apr 17 2017 (Closed)
Patch Set: Format Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/core/quic_session.cc ('k') | net/quic/core/quic_spdy_session.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/core/quic_session.h" 5 #include "net/quic/core/quic_session.h"
6 6
7 #include <cstdint> 7 #include <cstdint>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/rand_util.h" 11 #include "base/rand_util.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "net/quic/core/crypto/crypto_protocol.h" 13 #include "net/quic/core/crypto/crypto_protocol.h"
14 #include "net/quic/core/crypto/null_encrypter.h" 14 #include "net/quic/core/crypto/null_encrypter.h"
15 #include "net/quic/core/quic_crypto_stream.h" 15 #include "net/quic/core/quic_crypto_stream.h"
16 #include "net/quic/core/quic_flags.h"
17 #include "net/quic/core/quic_packets.h" 16 #include "net/quic/core/quic_packets.h"
18 #include "net/quic/core/quic_stream.h" 17 #include "net/quic/core/quic_stream.h"
19 #include "net/quic/core/quic_utils.h" 18 #include "net/quic/core/quic_utils.h"
19 #include "net/quic/platform/api/quic_flags.h"
20 #include "net/quic/platform/api/quic_map_util.h" 20 #include "net/quic/platform/api/quic_map_util.h"
21 #include "net/quic/platform/api/quic_ptr_util.h" 21 #include "net/quic/platform/api/quic_ptr_util.h"
22 #include "net/quic/platform/api/quic_str_cat.h" 22 #include "net/quic/platform/api/quic_str_cat.h"
23 #include "net/quic/platform/api/quic_string_piece.h" 23 #include "net/quic/platform/api/quic_string_piece.h"
24 #include "net/quic/test_tools/quic_config_peer.h" 24 #include "net/quic/test_tools/quic_config_peer.h"
25 #include "net/quic/test_tools/quic_connection_peer.h" 25 #include "net/quic/test_tools/quic_connection_peer.h"
26 #include "net/quic/test_tools/quic_flow_controller_peer.h" 26 #include "net/quic/test_tools/quic_flow_controller_peer.h"
27 #include "net/quic/test_tools/quic_session_peer.h" 27 #include "net/quic/test_tools/quic_session_peer.h"
28 #include "net/quic/test_tools/quic_spdy_session_peer.h" 28 #include "net/quic/test_tools/quic_spdy_session_peer.h"
29 #include "net/quic/test_tools/quic_spdy_stream_peer.h" 29 #include "net/quic/test_tools/quic_spdy_stream_peer.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 crypto_stream_(this), 118 crypto_stream_(this),
119 writev_consumes_all_data_(false) { 119 writev_consumes_all_data_(false) {
120 Initialize(); 120 Initialize();
121 this->connection()->SetEncrypter( 121 this->connection()->SetEncrypter(
122 ENCRYPTION_FORWARD_SECURE, 122 ENCRYPTION_FORWARD_SECURE,
123 new NullEncrypter(connection->perspective())); 123 new NullEncrypter(connection->perspective()));
124 } 124 }
125 125
126 ~TestSession() override { delete connection(); } 126 ~TestSession() override { delete connection(); }
127 127
128 TestCryptoStream* GetCryptoStream() override { return &crypto_stream_; } 128 TestCryptoStream* GetMutableCryptoStream() override {
129 return &crypto_stream_;
130 }
131
132 const TestCryptoStream* GetCryptoStream() const override {
133 return &crypto_stream_;
134 }
129 135
130 TestStream* CreateOutgoingDynamicStream(SpdyPriority priority) override { 136 TestStream* CreateOutgoingDynamicStream(SpdyPriority priority) override {
131 TestStream* stream = new TestStream(GetNextOutgoingStreamId(), this); 137 TestStream* stream = new TestStream(GetNextOutgoingStreamId(), this);
132 stream->SetPriority(priority); 138 stream->SetPriority(priority);
133 ActivateStream(QuicWrapUnique(stream)); 139 ActivateStream(QuicWrapUnique(stream));
134 return stream; 140 return stream;
135 } 141 }
136 142
137 TestStream* CreateIncomingDynamicStream(QuicStreamId id) override { 143 TestStream* CreateIncomingDynamicStream(QuicStreamId id) override {
138 // Enforce the limit on the number of open streams. 144 // Enforce the limit on the number of open streams.
(...skipping 21 matching lines...) Expand all
160 166
161 QuicStream* GetOrCreateDynamicStream(QuicStreamId stream_id) { 167 QuicStream* GetOrCreateDynamicStream(QuicStreamId stream_id) {
162 return QuicSpdySession::GetOrCreateDynamicStream(stream_id); 168 return QuicSpdySession::GetOrCreateDynamicStream(stream_id);
163 } 169 }
164 170
165 QuicConsumedData WritevData( 171 QuicConsumedData WritevData(
166 QuicStream* stream, 172 QuicStream* stream,
167 QuicStreamId id, 173 QuicStreamId id,
168 QuicIOVector data, 174 QuicIOVector data,
169 QuicStreamOffset offset, 175 QuicStreamOffset offset,
170 bool fin, 176 StreamSendingState state,
171 QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener) 177 QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener)
172 override { 178 override {
179 bool fin = state != NO_FIN;
173 QuicConsumedData consumed(data.total_length, fin); 180 QuicConsumedData consumed(data.total_length, fin);
174 if (!writev_consumes_all_data_) { 181 if (!writev_consumes_all_data_) {
175 consumed = QuicSession::WritevData(stream, id, data, offset, fin, 182 consumed = QuicSession::WritevData(stream, id, data, offset, state,
176 std::move(ack_listener)); 183 std::move(ack_listener));
177 } 184 }
178 stream->set_stream_bytes_written(stream->stream_bytes_written() + 185 stream->set_stream_bytes_written(stream->stream_bytes_written() +
179 consumed.bytes_consumed); 186 consumed.bytes_consumed);
180 if (fin && consumed.fin_consumed) { 187 if (fin && consumed.fin_consumed) {
181 stream->set_fin_sent(true); 188 stream->set_fin_sent(true);
182 } 189 }
183 QuicSessionPeer::GetWriteBlockedStreams(this)->UpdateBytesForStream( 190 QuicSessionPeer::GetWriteBlockedStreams(this)->UpdateBytesForStream(
184 id, consumed.bytes_consumed); 191 id, consumed.bytes_consumed);
185 return consumed; 192 return consumed;
186 } 193 }
187 194
188 void set_writev_consumes_all_data(bool val) { 195 void set_writev_consumes_all_data(bool val) {
189 writev_consumes_all_data_ = val; 196 writev_consumes_all_data_ = val;
190 } 197 }
191 198
192 QuicConsumedData SendStreamData(QuicStream* stream) { 199 QuicConsumedData SendStreamData(QuicStream* stream) {
193 struct iovec iov; 200 struct iovec iov;
194 if (stream->id() != kCryptoStreamId) { 201 if (stream->id() != kCryptoStreamId) {
195 this->connection()->SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); 202 this->connection()->SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE);
196 } 203 }
197 QuicConsumedData consumed = 204 QuicConsumedData consumed = WritevData(
198 WritevData(stream, stream->id(), MakeIOVector("not empty", &iov), 0, 205 stream, stream->id(), MakeIOVector("not empty", &iov), 0, FIN, nullptr);
199 true, nullptr);
200 return consumed; 206 return consumed;
201 } 207 }
202 208
203 QuicConsumedData SendLargeFakeData(QuicStream* stream, int bytes) { 209 QuicConsumedData SendLargeFakeData(QuicStream* stream, int bytes) {
204 DCHECK(writev_consumes_all_data_); 210 DCHECK(writev_consumes_all_data_);
205 struct iovec iov; 211 struct iovec iov;
206 iov.iov_base = nullptr; // should not be read. 212 iov.iov_base = nullptr; // should not be read.
207 iov.iov_len = static_cast<size_t>(bytes); 213 iov.iov_len = static_cast<size_t>(bytes);
208 return WritevData(stream, stream->id(), QuicIOVector(&iov, 1, bytes), 0, 214 return WritevData(stream, stream->id(), QuicIOVector(&iov, 1, bytes), 0,
209 true, nullptr); 215 FIN, nullptr);
210 } 216 }
211 217
212 using QuicSession::PostProcessAfterData; 218 using QuicSession::PostProcessAfterData;
213 219
214 private: 220 private:
215 StrictMock<TestCryptoStream> crypto_stream_; 221 StrictMock<TestCryptoStream> crypto_stream_;
216 222
217 bool writev_consumes_all_data_; 223 bool writev_consumes_all_data_;
218 }; 224 };
219 225
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 ::testing::ValuesIn(AllSupportedVersions())); 303 ::testing::ValuesIn(AllSupportedVersions()));
298 304
299 TEST_P(QuicSessionTestServer, PeerAddress) { 305 TEST_P(QuicSessionTestServer, PeerAddress) {
300 EXPECT_EQ(QuicSocketAddress(QuicIpAddress::Loopback4(), kTestPort), 306 EXPECT_EQ(QuicSocketAddress(QuicIpAddress::Loopback4(), kTestPort),
301 session_.peer_address()); 307 session_.peer_address());
302 } 308 }
303 309
304 TEST_P(QuicSessionTestServer, IsCryptoHandshakeConfirmed) { 310 TEST_P(QuicSessionTestServer, IsCryptoHandshakeConfirmed) {
305 EXPECT_FALSE(session_.IsCryptoHandshakeConfirmed()); 311 EXPECT_FALSE(session_.IsCryptoHandshakeConfirmed());
306 CryptoHandshakeMessage message; 312 CryptoHandshakeMessage message;
307 session_.GetCryptoStream()->OnHandshakeMessage(message); 313 session_.GetMutableCryptoStream()->OnHandshakeMessage(message);
308 EXPECT_TRUE(session_.IsCryptoHandshakeConfirmed()); 314 EXPECT_TRUE(session_.IsCryptoHandshakeConfirmed());
309 } 315 }
310 316
311 TEST_P(QuicSessionTestServer, IsClosedStreamDefault) { 317 TEST_P(QuicSessionTestServer, IsClosedStreamDefault) {
312 // Ensure that no streams are initially closed. 318 // Ensure that no streams are initially closed.
313 for (QuicStreamId i = kCryptoStreamId; i < 100; i++) { 319 for (QuicStreamId i = kCryptoStreamId; i < 100; i++) {
314 EXPECT_FALSE(session_.IsClosedStream(i)) << "stream id: " << i; 320 EXPECT_FALSE(session_.IsClosedStream(i)) << "stream id: " << i;
315 } 321 }
316 } 322 }
317 323
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 524
519 TEST_P(QuicSessionTestServer, OnCanWriteBundlesStreams) { 525 TEST_P(QuicSessionTestServer, OnCanWriteBundlesStreams) {
520 // Encryption needs to be established before data can be sent. 526 // Encryption needs to be established before data can be sent.
521 CryptoHandshakeMessage msg; 527 CryptoHandshakeMessage msg;
522 MockPacketWriter* writer = static_cast<MockPacketWriter*>( 528 MockPacketWriter* writer = static_cast<MockPacketWriter*>(
523 QuicConnectionPeer::GetWriter(session_.connection())); 529 QuicConnectionPeer::GetWriter(session_.connection()));
524 if (FLAGS_quic_reloadable_flag_quic_send_max_header_list_size) { 530 if (FLAGS_quic_reloadable_flag_quic_send_max_header_list_size) {
525 EXPECT_CALL(*writer, WritePacket(_, _, _, _, _)) 531 EXPECT_CALL(*writer, WritePacket(_, _, _, _, _))
526 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 0))); 532 .WillOnce(Return(WriteResult(WRITE_STATUS_OK, 0)));
527 } 533 }
528 session_.GetCryptoStream()->OnHandshakeMessage(msg); 534 session_.GetMutableCryptoStream()->OnHandshakeMessage(msg);
529 535
530 // Drive congestion control manually. 536 // Drive congestion control manually.
531 MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>; 537 MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>;
532 QuicConnectionPeer::SetSendAlgorithm(session_.connection(), send_algorithm); 538 QuicConnectionPeer::SetSendAlgorithm(session_.connection(), send_algorithm);
533 539
534 TestStream* stream2 = session_.CreateOutgoingDynamicStream(kDefaultPriority); 540 TestStream* stream2 = session_.CreateOutgoingDynamicStream(kDefaultPriority);
535 TestStream* stream4 = session_.CreateOutgoingDynamicStream(kDefaultPriority); 541 TestStream* stream4 = session_.CreateOutgoingDynamicStream(kDefaultPriority);
536 TestStream* stream6 = session_.CreateOutgoingDynamicStream(kDefaultPriority); 542 TestStream* stream6 = session_.CreateOutgoingDynamicStream(kDefaultPriority);
537 543
538 session_.MarkConnectionLevelWriteBlocked(stream2->id()); 544 session_.MarkConnectionLevelWriteBlocked(stream2->id());
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 stream4_blocker.MarkConnectionLevelWriteBlocked(); 679 stream4_blocker.MarkConnectionLevelWriteBlocked();
674 EXPECT_TRUE(session_.HasPendingHandshake()); 680 EXPECT_TRUE(session_.HasPendingHandshake());
675 681
676 InSequence s; 682 InSequence s;
677 // Force most streams to re-register, which is common scenario when we block 683 // Force most streams to re-register, which is common scenario when we block
678 // the Crypto stream, and only the crypto stream can "really" write. 684 // the Crypto stream, and only the crypto stream can "really" write.
679 685
680 // Due to prioritization, we *should* be asked to write the crypto stream 686 // Due to prioritization, we *should* be asked to write the crypto stream
681 // first. 687 // first.
682 // Don't re-register the crypto stream (which signals complete writing). 688 // Don't re-register the crypto stream (which signals complete writing).
683 TestCryptoStream* crypto_stream = session_.GetCryptoStream(); 689 TestCryptoStream* crypto_stream = session_.GetMutableCryptoStream();
684 EXPECT_CALL(*crypto_stream, OnCanWrite()); 690 EXPECT_CALL(*crypto_stream, OnCanWrite());
685 691
686 EXPECT_CALL(*stream2, OnCanWrite()) 692 EXPECT_CALL(*stream2, OnCanWrite())
687 .WillOnce(testing::IgnoreResult( 693 .WillOnce(testing::IgnoreResult(
688 Invoke(CreateFunctor(&TestSession::SendStreamData, 694 Invoke(CreateFunctor(&TestSession::SendStreamData,
689 base::Unretained(&session_), stream2)))); 695 base::Unretained(&session_), stream2))));
690 EXPECT_CALL(*stream3, OnCanWrite()) 696 EXPECT_CALL(*stream3, OnCanWrite())
691 .WillOnce(testing::IgnoreResult( 697 .WillOnce(testing::IgnoreResult(
692 Invoke(CreateFunctor(&TestSession::SendStreamData, 698 Invoke(CreateFunctor(&TestSession::SendStreamData,
693 base::Unretained(&session_), stream3)))); 699 base::Unretained(&session_), stream3))));
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 session_.MarkConnectionLevelWriteBlocked(kHeadersStreamId); 753 session_.MarkConnectionLevelWriteBlocked(kHeadersStreamId);
748 754
749 // Create a data stream, and although it is write blocked we never expect it 755 // Create a data stream, and although it is write blocked we never expect it
750 // to be allowed to write as we are connection level flow control blocked. 756 // to be allowed to write as we are connection level flow control blocked.
751 TestStream* stream = session_.CreateOutgoingDynamicStream(kDefaultPriority); 757 TestStream* stream = session_.CreateOutgoingDynamicStream(kDefaultPriority);
752 session_.MarkConnectionLevelWriteBlocked(stream->id()); 758 session_.MarkConnectionLevelWriteBlocked(stream->id());
753 EXPECT_CALL(*stream, OnCanWrite()).Times(0); 759 EXPECT_CALL(*stream, OnCanWrite()).Times(0);
754 760
755 // The crypto and headers streams should be called even though we are 761 // The crypto and headers streams should be called even though we are
756 // connection flow control blocked. 762 // connection flow control blocked.
757 TestCryptoStream* crypto_stream = session_.GetCryptoStream(); 763 TestCryptoStream* crypto_stream = session_.GetMutableCryptoStream();
758 EXPECT_CALL(*crypto_stream, OnCanWrite()); 764 EXPECT_CALL(*crypto_stream, OnCanWrite());
759 TestHeadersStream* headers_stream = new TestHeadersStream(&session_); 765 TestHeadersStream* headers_stream = new TestHeadersStream(&session_);
760 QuicSpdySessionPeer::SetHeadersStream(&session_, headers_stream); 766 QuicSpdySessionPeer::SetHeadersStream(&session_, headers_stream);
761 EXPECT_CALL(*headers_stream, OnCanWrite()); 767 EXPECT_CALL(*headers_stream, OnCanWrite());
762 768
763 // After the crypto and header streams perform a write, the connection will be 769 // After the crypto and header streams perform a write, the connection will be
764 // blocked by the flow control, hence it should become application-limited. 770 // blocked by the flow control, hence it should become application-limited.
765 EXPECT_CALL(*send_algorithm, OnApplicationLimited(_)); 771 EXPECT_CALL(*send_algorithm, OnApplicationLimited(_));
766 772
767 session_.OnCanWrite(); 773 session_.OnCanWrite();
(...skipping 14 matching lines...) Expand all
782 EXPECT_CALL(*connection_, 788 EXPECT_CALL(*connection_,
783 SendRstStream(kTestStreamId, QUIC_STREAM_PEER_GOING_AWAY, 0)) 789 SendRstStream(kTestStreamId, QUIC_STREAM_PEER_GOING_AWAY, 0))
784 .Times(0); 790 .Times(0);
785 EXPECT_TRUE(session_.GetOrCreateDynamicStream(kTestStreamId)); 791 EXPECT_TRUE(session_.GetOrCreateDynamicStream(kTestStreamId));
786 } 792 }
787 793
788 TEST_P(QuicSessionTestServer, IncreasedTimeoutAfterCryptoHandshake) { 794 TEST_P(QuicSessionTestServer, IncreasedTimeoutAfterCryptoHandshake) {
789 EXPECT_EQ(kInitialIdleTimeoutSecs + 3, 795 EXPECT_EQ(kInitialIdleTimeoutSecs + 3,
790 QuicConnectionPeer::GetNetworkTimeout(connection_).ToSeconds()); 796 QuicConnectionPeer::GetNetworkTimeout(connection_).ToSeconds());
791 CryptoHandshakeMessage msg; 797 CryptoHandshakeMessage msg;
792 session_.GetCryptoStream()->OnHandshakeMessage(msg); 798 session_.GetMutableCryptoStream()->OnHandshakeMessage(msg);
793 EXPECT_EQ(kMaximumIdleTimeoutSecs + 3, 799 EXPECT_EQ(kMaximumIdleTimeoutSecs + 3,
794 QuicConnectionPeer::GetNetworkTimeout(connection_).ToSeconds()); 800 QuicConnectionPeer::GetNetworkTimeout(connection_).ToSeconds());
795 } 801 }
796 802
797 TEST_P(QuicSessionTestServer, RstStreamBeforeHeadersDecompressed) { 803 TEST_P(QuicSessionTestServer, RstStreamBeforeHeadersDecompressed) {
798 // Send two bytes of payload. 804 // Send two bytes of payload.
799 QuicStreamFrame data1(kClientDataStreamId1, false, 0, QuicStringPiece("HT")); 805 QuicStreamFrame data1(kClientDataStreamId1, false, 0, QuicStringPiece("HT"));
800 session_.OnStreamFrame(data1); 806 session_.OnStreamFrame(data1);
801 EXPECT_EQ(1u, session_.GetNumOpenIncomingStreams()); 807 EXPECT_EQ(1u, session_.GetNumOpenIncomingStreams());
802 808
(...skipping 26 matching lines...) Expand all
829 EXPECT_TRUE(stream2->flow_controller()->IsBlocked()); 835 EXPECT_TRUE(stream2->flow_controller()->IsBlocked());
830 EXPECT_TRUE(session_.IsConnectionFlowControlBlocked()); 836 EXPECT_TRUE(session_.IsConnectionFlowControlBlocked());
831 EXPECT_TRUE(session_.IsStreamFlowControlBlocked()); 837 EXPECT_TRUE(session_.IsStreamFlowControlBlocked());
832 838
833 // The handshake message will call OnCanWrite, so the stream can resume 839 // The handshake message will call OnCanWrite, so the stream can resume
834 // writing. 840 // writing.
835 EXPECT_CALL(*stream2, OnCanWrite()); 841 EXPECT_CALL(*stream2, OnCanWrite());
836 // Now complete the crypto handshake, resulting in an increased flow control 842 // Now complete the crypto handshake, resulting in an increased flow control
837 // send window. 843 // send window.
838 CryptoHandshakeMessage msg; 844 CryptoHandshakeMessage msg;
839 session_.GetCryptoStream()->OnHandshakeMessage(msg); 845 session_.GetMutableCryptoStream()->OnHandshakeMessage(msg);
840 846
841 // Stream is now unblocked. 847 // Stream is now unblocked.
842 EXPECT_FALSE(stream2->flow_controller()->IsBlocked()); 848 EXPECT_FALSE(stream2->flow_controller()->IsBlocked());
843 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked()); 849 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
844 EXPECT_FALSE(session_.IsStreamFlowControlBlocked()); 850 EXPECT_FALSE(session_.IsStreamFlowControlBlocked());
845 } 851 }
846 852
847 TEST_P(QuicSessionTestServer, HandshakeUnblocksFlowControlBlockedCryptoStream) { 853 TEST_P(QuicSessionTestServer, HandshakeUnblocksFlowControlBlockedCryptoStream) {
848 // Test that if the crypto stream is flow control blocked, then if the SHLO 854 // Test that if the crypto stream is flow control blocked, then if the SHLO
849 // contains a larger send window offset, the stream becomes unblocked. 855 // contains a larger send window offset, the stream becomes unblocked.
850 session_.set_writev_consumes_all_data(true); 856 session_.set_writev_consumes_all_data(true);
851 TestCryptoStream* crypto_stream = session_.GetCryptoStream(); 857 TestCryptoStream* crypto_stream = session_.GetMutableCryptoStream();
852 EXPECT_FALSE(crypto_stream->flow_controller()->IsBlocked()); 858 EXPECT_FALSE(crypto_stream->flow_controller()->IsBlocked());
853 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked()); 859 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
854 EXPECT_FALSE(session_.IsStreamFlowControlBlocked()); 860 EXPECT_FALSE(session_.IsStreamFlowControlBlocked());
855 QuicHeadersStream* headers_stream = 861 QuicHeadersStream* headers_stream =
856 QuicSpdySessionPeer::GetHeadersStream(&session_); 862 QuicSpdySessionPeer::GetHeadersStream(&session_);
857 EXPECT_FALSE(headers_stream->flow_controller()->IsBlocked()); 863 EXPECT_FALSE(headers_stream->flow_controller()->IsBlocked());
858 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked()); 864 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
859 EXPECT_FALSE(session_.IsStreamFlowControlBlocked()); 865 EXPECT_FALSE(session_.IsStreamFlowControlBlocked());
860 // Write until the crypto stream is flow control blocked. 866 // Write until the crypto stream is flow control blocked.
861 EXPECT_CALL(*connection_, SendBlocked(kCryptoStreamId)); 867 EXPECT_CALL(*connection_, SendBlocked(kCryptoStreamId));
(...skipping 12 matching lines...) Expand all
874 EXPECT_TRUE(session_.IsStreamFlowControlBlocked()); 880 EXPECT_TRUE(session_.IsStreamFlowControlBlocked());
875 EXPECT_FALSE(session_.HasDataToWrite()); 881 EXPECT_FALSE(session_.HasDataToWrite());
876 EXPECT_TRUE(crypto_stream->HasBufferedData()); 882 EXPECT_TRUE(crypto_stream->HasBufferedData());
877 883
878 // The handshake message will call OnCanWrite, so the stream can 884 // The handshake message will call OnCanWrite, so the stream can
879 // resume writing. 885 // resume writing.
880 EXPECT_CALL(*crypto_stream, OnCanWrite()); 886 EXPECT_CALL(*crypto_stream, OnCanWrite());
881 // Now complete the crypto handshake, resulting in an increased flow control 887 // Now complete the crypto handshake, resulting in an increased flow control
882 // send window. 888 // send window.
883 CryptoHandshakeMessage msg; 889 CryptoHandshakeMessage msg;
884 session_.GetCryptoStream()->OnHandshakeMessage(msg); 890 session_.GetMutableCryptoStream()->OnHandshakeMessage(msg);
885 891
886 // Stream is now unblocked and will no longer have buffered data. 892 // Stream is now unblocked and will no longer have buffered data.
887 EXPECT_FALSE(crypto_stream->flow_controller()->IsBlocked()); 893 EXPECT_FALSE(crypto_stream->flow_controller()->IsBlocked());
888 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked()); 894 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
889 EXPECT_FALSE(session_.IsStreamFlowControlBlocked()); 895 EXPECT_FALSE(session_.IsStreamFlowControlBlocked());
890 } 896 }
891 897
892 #if !defined(OS_IOS) 898 #if !defined(OS_IOS)
893 // This test is failing flakily for iOS bots. 899 // This test is failing flakily for iOS bots.
894 // http://crbug.com/425050 900 // http://crbug.com/425050
895 // NOTE: It's not possible to use the standard MAYBE_ convention to disable 901 // NOTE: It's not possible to use the standard MAYBE_ convention to disable
896 // this test on iOS because when this test gets instantiated it ends up with 902 // this test on iOS because when this test gets instantiated it ends up with
897 // various names that are dependent on the parameters passed. 903 // various names that are dependent on the parameters passed.
898 TEST_P(QuicSessionTestServer, 904 TEST_P(QuicSessionTestServer,
899 HandshakeUnblocksFlowControlBlockedHeadersStream) { 905 HandshakeUnblocksFlowControlBlockedHeadersStream) {
900 // Test that if the header stream is flow control blocked, then if the SHLO 906 // Test that if the header stream is flow control blocked, then if the SHLO
901 // contains a larger send window offset, the stream becomes unblocked. 907 // contains a larger send window offset, the stream becomes unblocked.
902 session_.set_writev_consumes_all_data(true); 908 session_.set_writev_consumes_all_data(true);
903 TestCryptoStream* crypto_stream = session_.GetCryptoStream(); 909 TestCryptoStream* crypto_stream = session_.GetMutableCryptoStream();
904 EXPECT_FALSE(crypto_stream->flow_controller()->IsBlocked()); 910 EXPECT_FALSE(crypto_stream->flow_controller()->IsBlocked());
905 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked()); 911 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
906 EXPECT_FALSE(session_.IsStreamFlowControlBlocked()); 912 EXPECT_FALSE(session_.IsStreamFlowControlBlocked());
907 QuicHeadersStream* headers_stream = 913 QuicHeadersStream* headers_stream =
908 QuicSpdySessionPeer::GetHeadersStream(&session_); 914 QuicSpdySessionPeer::GetHeadersStream(&session_);
909 EXPECT_FALSE(headers_stream->flow_controller()->IsBlocked()); 915 EXPECT_FALSE(headers_stream->flow_controller()->IsBlocked());
910 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked()); 916 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
911 EXPECT_FALSE(session_.IsStreamFlowControlBlocked()); 917 EXPECT_FALSE(session_.IsStreamFlowControlBlocked());
912 QuicStreamId stream_id = 5; 918 QuicStreamId stream_id = 5;
913 // Write until the header stream is flow control blocked. 919 // Write until the header stream is flow control blocked.
(...skipping 14 matching lines...) Expand all
928 934
929 EXPECT_TRUE(headers_stream->flow_controller()->IsBlocked()); 935 EXPECT_TRUE(headers_stream->flow_controller()->IsBlocked());
930 EXPECT_FALSE(crypto_stream->flow_controller()->IsBlocked()); 936 EXPECT_FALSE(crypto_stream->flow_controller()->IsBlocked());
931 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked()); 937 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
932 EXPECT_TRUE(session_.IsStreamFlowControlBlocked()); 938 EXPECT_TRUE(session_.IsStreamFlowControlBlocked());
933 EXPECT_FALSE(session_.HasDataToWrite()); 939 EXPECT_FALSE(session_.HasDataToWrite());
934 940
935 // Now complete the crypto handshake, resulting in an increased flow control 941 // Now complete the crypto handshake, resulting in an increased flow control
936 // send window. 942 // send window.
937 CryptoHandshakeMessage msg; 943 CryptoHandshakeMessage msg;
938 session_.GetCryptoStream()->OnHandshakeMessage(msg); 944 session_.GetMutableCryptoStream()->OnHandshakeMessage(msg);
939 945
940 // Stream is now unblocked and will no longer have buffered data. 946 // Stream is now unblocked and will no longer have buffered data.
941 EXPECT_FALSE(headers_stream->flow_controller()->IsBlocked()); 947 EXPECT_FALSE(headers_stream->flow_controller()->IsBlocked());
942 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked()); 948 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
943 EXPECT_FALSE(session_.IsStreamFlowControlBlocked()); 949 EXPECT_FALSE(session_.IsStreamFlowControlBlocked());
944 EXPECT_FALSE(headers_stream->HasBufferedData()); 950 EXPECT_FALSE(headers_stream->HasBufferedData());
945 } 951 }
946 #endif // !defined(OS_IOS) 952 #endif // !defined(OS_IOS)
947 953
948 TEST_P(QuicSessionTestServer, ConnectionFlowControlAccountingRstOutOfOrder) { 954 TEST_P(QuicSessionTestServer, ConnectionFlowControlAccountingRstOutOfOrder) {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 QuicConfigPeer::SetReceivedInitialSessionFlowControlWindow(session_.config(), 1093 QuicConfigPeer::SetReceivedInitialSessionFlowControlWindow(session_.config(),
1088 kInvalidWindow); 1094 kInvalidWindow);
1089 1095
1090 EXPECT_CALL(*connection_, 1096 EXPECT_CALL(*connection_,
1091 CloseConnection(QUIC_FLOW_CONTROL_INVALID_WINDOW, _, _)); 1097 CloseConnection(QUIC_FLOW_CONTROL_INVALID_WINDOW, _, _));
1092 session_.OnConfigNegotiated(); 1098 session_.OnConfigNegotiated();
1093 } 1099 }
1094 1100
1095 // Test negotiation of custom server initial flow control window. 1101 // Test negotiation of custom server initial flow control window.
1096 TEST_P(QuicSessionTestServer, CustomFlowControlWindow) { 1102 TEST_P(QuicSessionTestServer, CustomFlowControlWindow) {
1097 FLAGS_quic_reloadable_flag_quic_large_ifw_options = true;
1098 QuicTagVector copt; 1103 QuicTagVector copt;
1099 copt.push_back(kIFW7); 1104 copt.push_back(kIFW7);
1100 QuicConfigPeer::SetReceivedConnectionOptions(session_.config(), copt); 1105 QuicConfigPeer::SetReceivedConnectionOptions(session_.config(), copt);
1101 1106
1102 session_.OnConfigNegotiated(); 1107 session_.OnConfigNegotiated();
1103 EXPECT_EQ(192 * 1024u, QuicFlowControllerPeer::ReceiveWindowSize( 1108 EXPECT_EQ(192 * 1024u, QuicFlowControllerPeer::ReceiveWindowSize(
1104 session_.flow_controller())); 1109 session_.flow_controller()));
1105 } 1110 }
1106 1111
1107 TEST_P(QuicSessionTestServer, FlowControlWithInvalidFinalOffset) { 1112 TEST_P(QuicSessionTestServer, FlowControlWithInvalidFinalOffset) {
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1309 if (version() != QUIC_VERSION_36) { 1314 if (version() != QUIC_VERSION_36) {
1310 EXPECT_FALSE(session_.force_hol_blocking()); 1315 EXPECT_FALSE(session_.force_hol_blocking());
1311 } else { 1316 } else {
1312 EXPECT_TRUE(session_.force_hol_blocking()); 1317 EXPECT_TRUE(session_.force_hol_blocking());
1313 } 1318 }
1314 } 1319 }
1315 1320
1316 } // namespace 1321 } // namespace
1317 } // namespace test 1322 } // namespace test
1318 } // namespace net 1323 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_session.cc ('k') | net/quic/core/quic_spdy_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698