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

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

Issue 683113005: Update from chromium https://crrev.com/302282 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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/quic_session.cc ('k') | net/quic/quic_unacked_packet_map.h » ('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/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"
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 SpdyHeaderBlock headers; 732 SpdyHeaderBlock headers;
733 while (!headers_stream->flow_controller()->IsBlocked() && stream_id < 2000) { 733 while (!headers_stream->flow_controller()->IsBlocked() && stream_id < 2000) {
734 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked()); 734 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
735 EXPECT_FALSE(session_.IsStreamFlowControlBlocked()); 735 EXPECT_FALSE(session_.IsStreamFlowControlBlocked());
736 headers["header"] = base::Uint64ToString(base::RandUint64()) + 736 headers["header"] = base::Uint64ToString(base::RandUint64()) +
737 base::Uint64ToString(base::RandUint64()) + 737 base::Uint64ToString(base::RandUint64()) +
738 base::Uint64ToString(base::RandUint64()); 738 base::Uint64ToString(base::RandUint64());
739 headers_stream->WriteHeaders(stream_id, headers, true, nullptr); 739 headers_stream->WriteHeaders(stream_id, headers, true, nullptr);
740 stream_id += 2; 740 stream_id += 2;
741 } 741 }
742 // Write one more to ensure that the headers stream has buffered data. The 742 // Write once more to ensure that the headers stream has buffered data. The
743 // random headers may have exactly filled the flow control window. 743 // random headers may have exactly filled the flow control window.
744 headers_stream->WriteHeaders(stream_id, headers, true, nullptr); 744 headers_stream->WriteHeaders(stream_id, headers, true, nullptr);
745 EXPECT_TRUE(headers_stream->HasBufferedData()); 745 EXPECT_TRUE(headers_stream->HasBufferedData());
746 746
747 EXPECT_TRUE(headers_stream->flow_controller()->IsBlocked()); 747 EXPECT_TRUE(headers_stream->flow_controller()->IsBlocked());
748 EXPECT_FALSE(crypto_stream->flow_controller()->IsBlocked()); 748 EXPECT_FALSE(crypto_stream->flow_controller()->IsBlocked());
749 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked()); 749 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
750 EXPECT_TRUE(session_.IsStreamFlowControlBlocked()); 750 EXPECT_TRUE(session_.IsStreamFlowControlBlocked());
751 EXPECT_FALSE(session_.HasDataToWrite()); 751 EXPECT_FALSE(session_.HasDataToWrite());
752 752
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 frames.push_back(window_update_frame); 991 frames.push_back(window_update_frame);
992 session_.OnWindowUpdateFrames(frames); 992 session_.OnWindowUpdateFrames(frames);
993 EXPECT_FALSE(headers_stream->flow_controller()->IsBlocked()); 993 EXPECT_FALSE(headers_stream->flow_controller()->IsBlocked());
994 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked()); 994 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
995 EXPECT_FALSE(session_.IsStreamFlowControlBlocked()); 995 EXPECT_FALSE(session_.IsStreamFlowControlBlocked());
996 } 996 }
997 997
998 TEST_P(QuicSessionTest, TooManyUnfinishedStreamsCauseConnectionClose) { 998 TEST_P(QuicSessionTest, TooManyUnfinishedStreamsCauseConnectionClose) {
999 // If a buggy/malicious peer creates too many streams that are not ended with 999 // If a buggy/malicious peer creates too many streams that are not ended with
1000 // a FIN or RST then we send a connection close. 1000 // a FIN or RST then we send a connection close.
1001 ValueRestore<bool> old_flag(&FLAGS_close_quic_connection_unfinished_streams_2,
1002 true);
1003
1004 EXPECT_CALL(*connection_, 1001 EXPECT_CALL(*connection_,
1005 SendConnectionClose(QUIC_TOO_MANY_UNFINISHED_STREAMS)).Times(1); 1002 SendConnectionClose(QUIC_TOO_MANY_UNFINISHED_STREAMS)).Times(1);
1006 1003
1007 const int kMaxStreams = 5; 1004 const int kMaxStreams = 5;
1008 QuicSessionPeer::SetMaxOpenStreams(&session_, kMaxStreams); 1005 QuicSessionPeer::SetMaxOpenStreams(&session_, kMaxStreams);
1009 1006
1010 // Create kMaxStreams + 1 data streams, and close them all without receiving a 1007 // Create kMaxStreams + 1 data streams, and close them all without receiving a
1011 // FIN or a RST from the client. 1008 // FIN or a RST from the client.
1012 const int kFirstStreamId = kClientDataStreamId1; 1009 const int kFirstStreamId = kClientDataStreamId1;
1013 const int kFinalStreamId = kClientDataStreamId1 + 2 * kMaxStreams + 1; 1010 const int kFinalStreamId = kClientDataStreamId1 + 2 * kMaxStreams + 1;
1014 for (int i = kFirstStreamId; i < kFinalStreamId; i += 2) { 1011 for (int i = kFirstStreamId; i < kFinalStreamId; i += 2) {
1015 QuicStreamFrame data1(i, false, 0, MakeIOVector("HT")); 1012 QuicStreamFrame data1(i, false, 0, MakeIOVector("HT"));
1016 vector<QuicStreamFrame> frames; 1013 vector<QuicStreamFrame> frames;
1017 frames.push_back(data1); 1014 frames.push_back(data1);
1018 session_.OnStreamFrames(frames); 1015 session_.OnStreamFrames(frames);
1019 EXPECT_EQ(1u, session_.GetNumOpenStreams()); 1016 EXPECT_EQ(1u, session_.GetNumOpenStreams());
1020 session_.CloseStream(i); 1017 session_.CloseStream(i);
1021 } 1018 }
1022 1019
1023 // Called after any new data is received by the session, and triggers the call 1020 // Called after any new data is received by the session, and triggers the call
1024 // to close the connection. 1021 // to close the connection.
1025 session_.PostProcessAfterData(); 1022 session_.PostProcessAfterData();
1026 } 1023 }
1027 1024
1028 } // namespace 1025 } // namespace
1029 } // namespace test 1026 } // namespace test
1030 } // namespace net 1027 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_session.cc ('k') | net/quic/quic_unacked_packet_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698