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

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

Issue 1784903003: Remove FEC from send path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@114770052
Patch Set: Restore accidentally removed OnRttChanged call Created 4 years, 9 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/quic_session_test.cc ('k') | net/quic/reliable_quic_stream.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_spdy_stream.h" 5 #include "net/quic/quic_spdy_stream.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 8
9 #include "net/quic/quic_connection.h" 9 #include "net/quic/quic_connection.h"
10 #include "net/quic/quic_utils.h" 10 #include "net/quic/quic_utils.h"
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 EXPECT_EQ(kWindow, QuicFlowControllerPeer::SendWindowOffset( 356 EXPECT_EQ(kWindow, QuicFlowControllerPeer::SendWindowOffset(
357 stream_->flow_controller())); 357 stream_->flow_controller()));
358 358
359 // Try to send more data than the flow control limit allows. 359 // Try to send more data than the flow control limit allows.
360 string headers = SpdyUtils::SerializeUncompressedHeaders(headers_); 360 string headers = SpdyUtils::SerializeUncompressedHeaders(headers_);
361 string body; 361 string body;
362 const uint64_t kOverflow = 15; 362 const uint64_t kOverflow = 15;
363 GenerateBody(&body, kWindow + kOverflow); 363 GenerateBody(&body, kWindow + kOverflow);
364 364
365 EXPECT_CALL(*connection_, SendBlocked(kClientDataStreamId1)); 365 EXPECT_CALL(*connection_, SendBlocked(kClientDataStreamId1));
366 EXPECT_CALL(*session_, WritevData(kClientDataStreamId1, _, _, _, _, _)) 366 EXPECT_CALL(*session_, WritevData(kClientDataStreamId1, _, _, _, _))
367 .WillOnce(Return(QuicConsumedData(kWindow, true))); 367 .WillOnce(Return(QuicConsumedData(kWindow, true)));
368 stream_->WriteOrBufferData(body, false, nullptr); 368 stream_->WriteOrBufferData(body, false, nullptr);
369 369
370 // Should have sent as much as possible, resulting in no send window left. 370 // Should have sent as much as possible, resulting in no send window left.
371 EXPECT_EQ(0u, 371 EXPECT_EQ(0u,
372 QuicFlowControllerPeer::SendWindowSize(stream_->flow_controller())); 372 QuicFlowControllerPeer::SendWindowSize(stream_->flow_controller()));
373 373
374 // And we should have queued the overflowed data. 374 // And we should have queued the overflowed data.
375 EXPECT_EQ(kOverflow, ReliableQuicStreamPeer::SizeOfQueuedData(stream_)); 375 EXPECT_EQ(kOverflow, ReliableQuicStreamPeer::SizeOfQueuedData(stream_));
376 } 376 }
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 // Set a flow control limit of zero. 602 // Set a flow control limit of zero.
603 QuicFlowControllerPeer::SetReceiveWindowOffset(stream_->flow_controller(), 0); 603 QuicFlowControllerPeer::SetReceiveWindowOffset(stream_->flow_controller(), 0);
604 EXPECT_EQ(0u, QuicFlowControllerPeer::ReceiveWindowOffset( 604 EXPECT_EQ(0u, QuicFlowControllerPeer::ReceiveWindowOffset(
605 stream_->flow_controller())); 605 stream_->flow_controller()));
606 606
607 // Send a frame with a FIN but no data. This should not be blocked. 607 // Send a frame with a FIN but no data. This should not be blocked.
608 string body = ""; 608 string body = "";
609 bool fin = true; 609 bool fin = true;
610 610
611 EXPECT_CALL(*connection_, SendBlocked(kClientDataStreamId1)).Times(0); 611 EXPECT_CALL(*connection_, SendBlocked(kClientDataStreamId1)).Times(0);
612 EXPECT_CALL(*session_, WritevData(kClientDataStreamId1, _, _, _, _, _)) 612 EXPECT_CALL(*session_, WritevData(kClientDataStreamId1, _, _, _, _))
613 .WillOnce(Return(QuicConsumedData(0, fin))); 613 .WillOnce(Return(QuicConsumedData(0, fin)));
614 614
615 stream_->WriteOrBufferData(body, fin, nullptr); 615 stream_->WriteOrBufferData(body, fin, nullptr);
616 } 616 }
617 617
618 TEST_P(QuicSpdyStreamTest, ReceivingTrailers) { 618 TEST_P(QuicSpdyStreamTest, ReceivingTrailers) {
619 // Test that receiving trailing headers from the peer works, and can be read 619 // Test that receiving trailing headers from the peer works, and can be read
620 // from the stream and consumed. 620 // from the stream and consumed.
621 Initialize(kShouldProcessData); 621 Initialize(kShouldProcessData);
622 622
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 QuicStreamFrame frame(kClientDataStreamId1, /*fin=*/true, 0, kBody); 725 QuicStreamFrame frame(kClientDataStreamId1, /*fin=*/true, 0, kBody);
726 stream_->OnStreamFrame(frame); 726 stream_->OnStreamFrame(frame);
727 727
728 EXPECT_TRUE(stream_->IsDoneReading()); 728 EXPECT_TRUE(stream_->IsDoneReading());
729 } 729 }
730 730
731 TEST_P(QuicSpdyStreamTest, WritingTrailersSendsAFin) { 731 TEST_P(QuicSpdyStreamTest, WritingTrailersSendsAFin) {
732 // Test that writing trailers will send a FIN, as Trailers are the last thing 732 // Test that writing trailers will send a FIN, as Trailers are the last thing
733 // to be sent on a stream. 733 // to be sent on a stream.
734 Initialize(kShouldProcessData); 734 Initialize(kShouldProcessData);
735 EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)) 735 EXPECT_CALL(*session_, WritevData(_, _, _, _, _))
736 .Times(AnyNumber()) 736 .Times(AnyNumber())
737 .WillRepeatedly(Invoke(MockQuicSpdySession::ConsumeAllData)); 737 .WillRepeatedly(Invoke(MockQuicSpdySession::ConsumeAllData));
738 738
739 // Write the initial headers, without a FIN. 739 // Write the initial headers, without a FIN.
740 EXPECT_CALL(*session_, WriteHeaders(_, _, _, _, _)); 740 EXPECT_CALL(*session_, WriteHeaders(_, _, _, _, _));
741 stream_->WriteHeaders(SpdyHeaderBlock(), /*fin=*/false, nullptr); 741 stream_->WriteHeaders(SpdyHeaderBlock(), /*fin=*/false, nullptr);
742 742
743 // Writing trailers implicitly sends a FIN. 743 // Writing trailers implicitly sends a FIN.
744 SpdyHeaderBlock trailers; 744 SpdyHeaderBlock trailers;
745 trailers["trailer key"] = "trailer value"; 745 trailers["trailer key"] = "trailer value";
746 EXPECT_CALL(*session_, WriteHeaders(_, _, 746 EXPECT_CALL(*session_, WriteHeaders(_, _,
747 /*fin=*/true, _, _)); 747 /*fin=*/true, _, _));
748 stream_->WriteTrailers(trailers, nullptr); 748 stream_->WriteTrailers(trailers, nullptr);
749 EXPECT_TRUE(stream_->fin_sent()); 749 EXPECT_TRUE(stream_->fin_sent());
750 } 750 }
751 751
752 TEST_P(QuicSpdyStreamTest, WritingTrailersFinalOffset) { 752 TEST_P(QuicSpdyStreamTest, WritingTrailersFinalOffset) {
753 // Test that when writing trailers, the trailers that are actually sent to the 753 // Test that when writing trailers, the trailers that are actually sent to the
754 // peer contain the final offset field indicating last byte of data. 754 // peer contain the final offset field indicating last byte of data.
755 Initialize(kShouldProcessData); 755 Initialize(kShouldProcessData);
756 EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)) 756 EXPECT_CALL(*session_, WritevData(_, _, _, _, _))
757 .Times(AnyNumber()) 757 .Times(AnyNumber())
758 .WillRepeatedly(Invoke(MockQuicSpdySession::ConsumeAllData)); 758 .WillRepeatedly(Invoke(MockQuicSpdySession::ConsumeAllData));
759 759
760 // Write the initial headers. 760 // Write the initial headers.
761 EXPECT_CALL(*session_, WriteHeaders(_, _, _, _, _)); 761 EXPECT_CALL(*session_, WriteHeaders(_, _, _, _, _));
762 stream_->WriteHeaders(SpdyHeaderBlock(), /*fin=*/false, nullptr); 762 stream_->WriteHeaders(SpdyHeaderBlock(), /*fin=*/false, nullptr);
763 763
764 // Write non-zero body data to force a non-zero final offset. 764 // Write non-zero body data to force a non-zero final offset.
765 const int kBodySize = 1 * 1024; // 1 MB 765 const int kBodySize = 1 * 1024; // 1 MB
766 stream_->WriteOrBufferData(string(kBodySize, 'x'), false, nullptr); 766 stream_->WriteOrBufferData(string(kBodySize, 'x'), false, nullptr);
767 767
768 // The final offset field in the trailing headers is populated with the 768 // The final offset field in the trailing headers is populated with the
769 // number of body bytes written (including queued bytes). 769 // number of body bytes written (including queued bytes).
770 SpdyHeaderBlock trailers; 770 SpdyHeaderBlock trailers;
771 trailers["trailer key"] = "trailer value"; 771 trailers["trailer key"] = "trailer value";
772 SpdyHeaderBlock trailers_with_offset = trailers; 772 SpdyHeaderBlock trailers_with_offset = trailers;
773 trailers_with_offset[kFinalOffsetHeaderKey] = base::IntToString(kBodySize); 773 trailers_with_offset[kFinalOffsetHeaderKey] = base::IntToString(kBodySize);
774 EXPECT_CALL(*session_, WriteHeaders(_, testing::Eq(trailers_with_offset), 774 EXPECT_CALL(*session_, WriteHeaders(_, testing::Eq(trailers_with_offset),
775 /*fin=*/true, _, _)); 775 /*fin=*/true, _, _));
776 stream_->WriteTrailers(trailers, nullptr); 776 stream_->WriteTrailers(trailers, nullptr);
777 } 777 }
778 778
779 TEST_P(QuicSpdyStreamTest, WritingTrailersClosesWriteSide) { 779 TEST_P(QuicSpdyStreamTest, WritingTrailersClosesWriteSide) {
780 // Test that if trailers are written after all other data has been written 780 // Test that if trailers are written after all other data has been written
781 // (headers and body), that this closes the stream for writing. 781 // (headers and body), that this closes the stream for writing.
782 Initialize(kShouldProcessData); 782 Initialize(kShouldProcessData);
783 EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)) 783 EXPECT_CALL(*session_, WritevData(_, _, _, _, _))
784 .Times(AnyNumber()) 784 .Times(AnyNumber())
785 .WillRepeatedly(Invoke(MockQuicSpdySession::ConsumeAllData)); 785 .WillRepeatedly(Invoke(MockQuicSpdySession::ConsumeAllData));
786 786
787 // Write the initial headers. 787 // Write the initial headers.
788 EXPECT_CALL(*session_, WriteHeaders(_, _, _, _, _)); 788 EXPECT_CALL(*session_, WriteHeaders(_, _, _, _, _));
789 stream_->WriteHeaders(SpdyHeaderBlock(), /*fin=*/false, nullptr); 789 stream_->WriteHeaders(SpdyHeaderBlock(), /*fin=*/false, nullptr);
790 790
791 // Write non-zero body data. 791 // Write non-zero body data.
792 const int kBodySize = 1 * 1024; // 1 MB 792 const int kBodySize = 1 * 1024; // 1 MB
793 stream_->WriteOrBufferData(string(kBodySize, 'x'), false, nullptr); 793 stream_->WriteOrBufferData(string(kBodySize, 'x'), false, nullptr);
794 EXPECT_EQ(0u, stream_->queued_data_bytes()); 794 EXPECT_EQ(0u, stream_->queued_data_bytes());
795 795
796 // Headers and body have been fully written, there is no queued data. Writing 796 // Headers and body have been fully written, there is no queued data. Writing
797 // trailers marks the end of this stream, and thus the write side is closed. 797 // trailers marks the end of this stream, and thus the write side is closed.
798 EXPECT_CALL(*session_, WriteHeaders(_, _, 798 EXPECT_CALL(*session_, WriteHeaders(_, _,
799 /*fin=*/true, _, _)); 799 /*fin=*/true, _, _));
800 stream_->WriteTrailers(SpdyHeaderBlock(), nullptr); 800 stream_->WriteTrailers(SpdyHeaderBlock(), nullptr);
801 EXPECT_TRUE(stream_->write_side_closed()); 801 EXPECT_TRUE(stream_->write_side_closed());
802 } 802 }
803 803
804 TEST_P(QuicSpdyStreamTest, WritingTrailersWithQueuedBytes) { 804 TEST_P(QuicSpdyStreamTest, WritingTrailersWithQueuedBytes) {
805 // Test that the stream is not closed for writing when trailers are sent 805 // Test that the stream is not closed for writing when trailers are sent
806 // while there are still body bytes queued. 806 // while there are still body bytes queued.
807 Initialize(kShouldProcessData); 807 Initialize(kShouldProcessData);
808 EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)) 808 EXPECT_CALL(*session_, WritevData(_, _, _, _, _))
809 .Times(AnyNumber()) 809 .Times(AnyNumber())
810 .WillRepeatedly(Invoke(MockQuicSpdySession::ConsumeAllData)); 810 .WillRepeatedly(Invoke(MockQuicSpdySession::ConsumeAllData));
811 811
812 // Write the initial headers. 812 // Write the initial headers.
813 EXPECT_CALL(*session_, WriteHeaders(_, _, _, _, _)); 813 EXPECT_CALL(*session_, WriteHeaders(_, _, _, _, _));
814 stream_->WriteHeaders(SpdyHeaderBlock(), /*fin=*/false, nullptr); 814 stream_->WriteHeaders(SpdyHeaderBlock(), /*fin=*/false, nullptr);
815 815
816 // Write non-zero body data, but only consume partially, ensuring queueing. 816 // Write non-zero body data, but only consume partially, ensuring queueing.
817 const int kBodySize = 1 * 1024; // 1 MB 817 const int kBodySize = 1 * 1024; // 1 MB
818 EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)) 818 EXPECT_CALL(*session_, WritevData(_, _, _, _, _))
819 .WillOnce(Return(QuicConsumedData(kBodySize - 1, false))); 819 .WillOnce(Return(QuicConsumedData(kBodySize - 1, false)));
820 stream_->WriteOrBufferData(string(kBodySize, 'x'), false, nullptr); 820 stream_->WriteOrBufferData(string(kBodySize, 'x'), false, nullptr);
821 EXPECT_EQ(1u, stream_->queued_data_bytes()); 821 EXPECT_EQ(1u, stream_->queued_data_bytes());
822 822
823 // Writing trailers will send a FIN, but not close the write side of the 823 // Writing trailers will send a FIN, but not close the write side of the
824 // stream as there are queued bytes. 824 // stream as there are queued bytes.
825 EXPECT_CALL(*session_, WriteHeaders(_, _, 825 EXPECT_CALL(*session_, WriteHeaders(_, _,
826 /*fin=*/true, _, _)); 826 /*fin=*/true, _, _));
827 stream_->WriteTrailers(SpdyHeaderBlock(), nullptr); 827 stream_->WriteTrailers(SpdyHeaderBlock(), nullptr);
828 EXPECT_TRUE(stream_->fin_sent()); 828 EXPECT_TRUE(stream_->fin_sent());
829 EXPECT_FALSE(stream_->write_side_closed()); 829 EXPECT_FALSE(stream_->write_side_closed());
830 } 830 }
831 831
832 TEST_P(QuicSpdyStreamTest, WritingTrailersAfterFIN) { 832 TEST_P(QuicSpdyStreamTest, WritingTrailersAfterFIN) {
833 // Test that it is not possible to write Trailers after a FIN has been sent. 833 // Test that it is not possible to write Trailers after a FIN has been sent.
834 Initialize(kShouldProcessData); 834 Initialize(kShouldProcessData);
835 EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)) 835 EXPECT_CALL(*session_, WritevData(_, _, _, _, _))
836 .Times(AnyNumber()) 836 .Times(AnyNumber())
837 .WillRepeatedly(Invoke(MockQuicSpdySession::ConsumeAllData)); 837 .WillRepeatedly(Invoke(MockQuicSpdySession::ConsumeAllData));
838 838
839 // Write the initial headers, with a FIN. 839 // Write the initial headers, with a FIN.
840 EXPECT_CALL(*session_, WriteHeaders(_, _, _, _, _)); 840 EXPECT_CALL(*session_, WriteHeaders(_, _, _, _, _));
841 stream_->WriteHeaders(SpdyHeaderBlock(), /*fin=*/true, nullptr); 841 stream_->WriteHeaders(SpdyHeaderBlock(), /*fin=*/true, nullptr);
842 EXPECT_TRUE(stream_->fin_sent()); 842 EXPECT_TRUE(stream_->fin_sent());
843 843
844 // Writing Trailers should fail, as the FIN has already been sent. 844 // Writing Trailers should fail, as the FIN has already been sent.
845 // populated with the number of body bytes written. 845 // populated with the number of body bytes written.
846 EXPECT_DFATAL(stream_->WriteTrailers(SpdyHeaderBlock(), nullptr), 846 EXPECT_DFATAL(stream_->WriteTrailers(SpdyHeaderBlock(), nullptr),
847 "Trailers cannot be sent after a FIN"); 847 "Trailers cannot be sent after a FIN");
848 } 848 }
849 849
850 } // namespace 850 } // namespace
851 } // namespace test 851 } // namespace test
852 } // namespace net 852 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_session_test.cc ('k') | net/quic/reliable_quic_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698