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

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

Issue 327393002: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile error Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_session.cc ('k') | net/quic/quic_stream_sequencer.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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 }; 79 };
80 80
81 class TestStream : public QuicDataStream { 81 class TestStream : public QuicDataStream {
82 public: 82 public:
83 TestStream(QuicStreamId id, QuicSession* session) 83 TestStream(QuicStreamId id, QuicSession* session)
84 : QuicDataStream(id, session) { 84 : QuicDataStream(id, session) {
85 } 85 }
86 86
87 using ReliableQuicStream::CloseWriteSide; 87 using ReliableQuicStream::CloseWriteSide;
88 88
89 virtual uint32 ProcessData(const char* data, uint32 data_len) { 89 virtual uint32 ProcessData(const char* data, uint32 data_len) OVERRIDE {
90 return data_len; 90 return data_len;
91 } 91 }
92 92
93 void SendBody(const string& data, bool fin) { 93 void SendBody(const string& data, bool fin) {
94 WriteOrBufferData(data, fin, NULL); 94 WriteOrBufferData(data, fin, NULL);
95 } 95 }
96 96
97 MOCK_METHOD0(OnCanWrite, void()); 97 MOCK_METHOD0(OnCanWrite, void());
98 }; 98 };
99 99
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 EXPECT_CALL(*connection_, 738 EXPECT_CALL(*connection_,
739 SendWindowUpdate( 739 SendWindowUpdate(
740 0, kInitialFlowControlWindowForTest + kByteOffset)).Times(1); 740 0, kInitialFlowControlWindowForTest + kByteOffset)).Times(1);
741 741
742 // Reset stream locally. 742 // Reset stream locally.
743 stream->Reset(QUIC_STREAM_CANCELLED); 743 stream->Reset(QUIC_STREAM_CANCELLED);
744 744
745 EXPECT_EQ(kByteOffset, session_.flow_controller()->bytes_consumed()); 745 EXPECT_EQ(kByteOffset, session_.flow_controller()->bytes_consumed());
746 } 746 }
747 747
748 TEST_P(QuicSessionTest, ConnectionFlowControlAccountingFinAfterRst) {
749 // Test that when we RST the stream (and tear down stream state), and then
750 // receive a FIN from the peer, we correctly adjust our connection level flow
751 // control receive window.
752 FLAGS_enable_quic_connection_flow_control = true;
753 if (version() < QUIC_VERSION_19) {
754 return;
755 }
756
757 // Connection starts with some non-zero highest received byte offset,
758 // due to other active streams.
759 const uint64 kInitialConnectionBytesConsumed = 567;
760 const uint64 kInitialConnectionHighestReceivedOffset = 1234;
761 EXPECT_LT(kInitialConnectionBytesConsumed,
762 kInitialConnectionHighestReceivedOffset);
763 session_.flow_controller()->UpdateHighestReceivedOffset(
764 kInitialConnectionHighestReceivedOffset);
765 session_.flow_controller()->AddBytesConsumed(kInitialConnectionBytesConsumed);
766
767 // Reset our stream: this results in the stream being closed locally.
768 TestStream* stream = session_.CreateOutgoingDataStream();
769 stream->Reset(QUIC_STREAM_CANCELLED);
770
771 // Now receive a response from the peer with a FIN. We should handle this by
772 // adjusting the connection level flow control receive window to take into
773 // account the total number of bytes sent by the peer.
774 const QuicStreamOffset kByteOffset = 5678;
775 string body = "hello";
776 IOVector data = MakeIOVector(body);
777 QuicStreamFrame frame(stream->id(), true, kByteOffset, data);
778 vector<QuicStreamFrame> frames;
779 frames.push_back(frame);
780 session_.OnStreamFrames(frames);
781
782 QuicStreamOffset total_stream_bytes_sent_by_peer =
783 kByteOffset + body.length();
784 EXPECT_EQ(kInitialConnectionBytesConsumed + total_stream_bytes_sent_by_peer,
785 session_.flow_controller()->bytes_consumed());
786 EXPECT_EQ(
787 kInitialConnectionHighestReceivedOffset + total_stream_bytes_sent_by_peer,
788 session_.flow_controller()->highest_received_byte_offset());
789 }
790
791 TEST_P(QuicSessionTest, ConnectionFlowControlAccountingRstAfterRst) {
792 // Test that when we RST the stream (and tear down stream state), and then
793 // receive a RST from the peer, we correctly adjust our connection level flow
794 // control receive window.
795 FLAGS_enable_quic_connection_flow_control = true;
796 if (version() < QUIC_VERSION_19) {
797 return;
798 }
799
800 // Connection starts with some non-zero highest received byte offset,
801 // due to other active streams.
802 const uint64 kInitialConnectionBytesConsumed = 567;
803 const uint64 kInitialConnectionHighestReceivedOffset = 1234;
804 EXPECT_LT(kInitialConnectionBytesConsumed,
805 kInitialConnectionHighestReceivedOffset);
806 session_.flow_controller()->UpdateHighestReceivedOffset(
807 kInitialConnectionHighestReceivedOffset);
808 session_.flow_controller()->AddBytesConsumed(kInitialConnectionBytesConsumed);
809
810 // Reset our stream: this results in the stream being closed locally.
811 TestStream* stream = session_.CreateOutgoingDataStream();
812 stream->Reset(QUIC_STREAM_CANCELLED);
813
814 // Now receive a RST from the peer. We should handle this by adjusting the
815 // connection level flow control receive window to take into account the total
816 // number of bytes sent by the peer.
817 const QuicStreamOffset kByteOffset = 5678;
818 QuicRstStreamFrame rst_frame(stream->id(), QUIC_STREAM_CANCELLED,
819 kByteOffset);
820 session_.OnRstStream(rst_frame);
821
822 EXPECT_EQ(kInitialConnectionBytesConsumed + kByteOffset,
823 session_.flow_controller()->bytes_consumed());
824 EXPECT_EQ(kInitialConnectionHighestReceivedOffset + kByteOffset,
825 session_.flow_controller()->highest_received_byte_offset());
826 }
827
748 TEST_P(QuicSessionTest, VersionNegotiationDisablesFlowControl) { 828 TEST_P(QuicSessionTest, VersionNegotiationDisablesFlowControl) {
749 ValueRestore<bool> old_stream_flag( 829 ValueRestore<bool> old_stream_flag(
750 &FLAGS_enable_quic_stream_flow_control_2, true); 830 &FLAGS_enable_quic_stream_flow_control_2, true);
751 ValueRestore<bool> old_connection_flag( 831 ValueRestore<bool> old_connection_flag(
752 &FLAGS_enable_quic_connection_flow_control, true); 832 &FLAGS_enable_quic_connection_flow_control, true);
753 if (version() < QUIC_VERSION_19) { 833 if (version() < QUIC_VERSION_19) {
754 return; 834 return;
755 } 835 }
756 836
757 // Test that after successful version negotiation, flow control is disabled 837 // Test that after successful version negotiation, flow control is disabled
(...skipping 12 matching lines...) Expand all
770 850
771 // Version 16 means all flow control is disabled. 851 // Version 16 means all flow control is disabled.
772 session_.OnSuccessfulVersionNegotiation(QUIC_VERSION_16); 852 session_.OnSuccessfulVersionNegotiation(QUIC_VERSION_16);
773 EXPECT_FALSE(session_.flow_controller()->IsEnabled()); 853 EXPECT_FALSE(session_.flow_controller()->IsEnabled());
774 EXPECT_FALSE(stream->flow_controller()->IsEnabled()); 854 EXPECT_FALSE(stream->flow_controller()->IsEnabled());
775 } 855 }
776 856
777 } // namespace 857 } // namespace
778 } // namespace test 858 } // namespace test
779 } // namespace net 859 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_session.cc ('k') | net/quic/quic_stream_sequencer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698