| 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/reliable_quic_stream.h" | 5 #include "net/quic/reliable_quic_stream.h" |
| 6 | 6 |
| 7 #include "net/quic/quic_connection.h" | 7 #include "net/quic/quic_connection.h" |
| 8 #include "net/quic/quic_flags.h" | 8 #include "net/quic/quic_flags.h" |
| 9 #include "net/quic/quic_utils.h" | 9 #include "net/quic/quic_utils.h" |
| 10 #include "net/quic/quic_write_blocked_list.h" | 10 #include "net/quic/quic_write_blocked_list.h" |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 // Test ReceivedConnectionOptions. | 718 // Test ReceivedConnectionOptions. |
| 719 QuicConfig* config = session_->config(); | 719 QuicConfig* config = session_->config(); |
| 720 QuicTagVector copt; | 720 QuicTagVector copt; |
| 721 copt.push_back(kFSTR); | 721 copt.push_back(kFSTR); |
| 722 QuicConfigPeer::SetReceivedConnectionOptions(config, copt); | 722 QuicConfigPeer::SetReceivedConnectionOptions(config, copt); |
| 723 EXPECT_EQ(FEC_PROTECT_OPTIONAL, stream_->fec_policy()); | 723 EXPECT_EQ(FEC_PROTECT_OPTIONAL, stream_->fec_policy()); |
| 724 stream_->SetFromConfig(); | 724 stream_->SetFromConfig(); |
| 725 EXPECT_EQ(FEC_PROTECT_ALWAYS, stream_->fec_policy()); | 725 EXPECT_EQ(FEC_PROTECT_ALWAYS, stream_->fec_policy()); |
| 726 } | 726 } |
| 727 | 727 |
| 728 static QuicConsumedData ConsumeAllData( | |
| 729 QuicStreamId id, | |
| 730 const QuicIOVector& data, | |
| 731 QuicStreamOffset offset, | |
| 732 bool fin, | |
| 733 FecProtection fec_protection, | |
| 734 QuicAckListenerInterface* ack_notifier_delegate) { | |
| 735 return QuicConsumedData(data.total_length, fin); | |
| 736 } | |
| 737 | |
| 738 TEST_F(ReliableQuicStreamTest, EarlyResponseFinHandling) { | 728 TEST_F(ReliableQuicStreamTest, EarlyResponseFinHandling) { |
| 739 // Verify that if the server completes the response before reading the end of | 729 // Verify that if the server completes the response before reading the end of |
| 740 // the request, the received FIN is recorded. | 730 // the request, the received FIN is recorded. |
| 741 | 731 |
| 742 Initialize(kShouldProcessData); | 732 Initialize(kShouldProcessData); |
| 743 EXPECT_CALL(*connection_, SendConnectionClose(_)).Times(0); | 733 EXPECT_CALL(*connection_, SendConnectionClose(_)).Times(0); |
| 744 EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)) | 734 EXPECT_CALL(*session_, WritevData(_, _, _, _, _, _)) |
| 745 .WillRepeatedly(Invoke(ConsumeAllData)); | 735 .WillRepeatedly(Invoke(MockQuicSpdySession::ConsumeAllData)); |
| 746 | 736 |
| 747 // Receive data for the request. | 737 // Receive data for the request. |
| 748 QuicStreamFrame frame1(stream_->id(), false, 0, StringPiece("Start")); | 738 QuicStreamFrame frame1(stream_->id(), false, 0, StringPiece("Start")); |
| 749 stream_->OnStreamFrame(frame1); | 739 stream_->OnStreamFrame(frame1); |
| 750 // When QuicSpdyServerStream sends the response, it calls | 740 // When QuicSpdyServerStream sends the response, it calls |
| 751 // ReliableQuicStream::CloseReadSide() first. | 741 // ReliableQuicStream::CloseReadSide() first. |
| 752 ReliableQuicStreamPeer::CloseReadSide(stream_); | 742 ReliableQuicStreamPeer::CloseReadSide(stream_); |
| 753 // Send data and FIN for the response. | 743 // Send data and FIN for the response. |
| 754 stream_->WriteOrBufferData(kData1, false, nullptr); | 744 stream_->WriteOrBufferData(kData1, false, nullptr); |
| 755 EXPECT_TRUE(ReliableQuicStreamPeer::read_side_closed(stream_)); | 745 EXPECT_TRUE(ReliableQuicStreamPeer::read_side_closed(stream_)); |
| 756 // Receive remaining data and FIN for the request. | 746 // Receive remaining data and FIN for the request. |
| 757 QuicStreamFrame frame2(stream_->id(), true, 0, StringPiece("End")); | 747 QuicStreamFrame frame2(stream_->id(), true, 0, StringPiece("End")); |
| 758 stream_->OnStreamFrame(frame2); | 748 stream_->OnStreamFrame(frame2); |
| 759 EXPECT_TRUE(stream_->fin_received()); | 749 EXPECT_TRUE(stream_->fin_received()); |
| 760 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); | 750 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); |
| 761 } | 751 } |
| 762 | 752 |
| 763 } // namespace | 753 } // namespace |
| 764 } // namespace test | 754 } // namespace test |
| 765 } // namespace net | 755 } // namespace net |
| OLD | NEW |