| 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "net/quic/quic_connection.h" | 9 #include "net/quic/quic_connection.h" |
| 10 #include "net/quic/quic_flags.h" | 10 #include "net/quic/quic_flags.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 "QnyXHeGeK2UINUzJ-D30AFcpqYgH9_1BvYSpi7fc7_ydBU8TaD8ZRxvtnzXqj0RfG" | 100 "QnyXHeGeK2UINUzJ-D30AFcpqYgH9_1BvYSpi7fc7_ydBU8TaD8ZRxvtnzXqj0RfG" |
| 101 "tuHghmv3aD-uzSYJ75XDdzKdizZ86IG6Fbn1XFhYZM-fbHhm3mVEXnyRW4ZuNOLFk" | 101 "tuHghmv3aD-uzSYJ75XDdzKdizZ86IG6Fbn1XFhYZM-fbHhm3mVEXnyRW4ZuNOLFk" |
| 102 "Fas6LMcVC6Q8QLlHYbXBpdNFuGbuZGUnav5C-2I_-46lL0NGg3GewxGKGHvHEfoyn" | 102 "Fas6LMcVC6Q8QLlHYbXBpdNFuGbuZGUnav5C-2I_-46lL0NGg3GewxGKGHvHEfoyn" |
| 103 "EFFlEYHsBQ98rXImL8ySDycdLEFvBPdtctPmWCfTxwmoSMLHU2SCVDhbqMWU5b0yr" | 103 "EFFlEYHsBQ98rXImL8ySDycdLEFvBPdtctPmWCfTxwmoSMLHU2SCVDhbqMWU5b0yr" |
| 104 "JBCScs_ejbKaqBDoB7ZGxTvqlrB__2ZmnHHjCr8RgMRtKNtIeuZAo "; | 104 "JBCScs_ejbKaqBDoB7ZGxTvqlrB__2ZmnHHjCr8RgMRtKNtIeuZAo "; |
| 105 } | 105 } |
| 106 | 106 |
| 107 void Initialize(bool stream_should_process_data) { | 107 void Initialize(bool stream_should_process_data) { |
| 108 connection_ = new StrictMock<MockConnection>( | 108 connection_ = new StrictMock<MockConnection>( |
| 109 &helper_, &alarm_factory_, Perspective::IS_SERVER, supported_versions_); | 109 &helper_, &alarm_factory_, Perspective::IS_SERVER, supported_versions_); |
| 110 session_.reset(new StrictMock<MockQuicSpdySession>(connection_)); | 110 session_.reset(new StrictMock<MockQuicSession>(connection_)); |
| 111 | 111 |
| 112 // New streams rely on having the peer's flow control receive window | 112 // New streams rely on having the peer's flow control receive window |
| 113 // negotiated in the config. | 113 // negotiated in the config. |
| 114 QuicConfigPeer::SetReceivedInitialStreamFlowControlWindow( | 114 QuicConfigPeer::SetReceivedInitialStreamFlowControlWindow( |
| 115 session_->config(), initial_flow_control_window_bytes_); | 115 session_->config(), initial_flow_control_window_bytes_); |
| 116 | 116 |
| 117 stream_ = new TestStream(kTestStreamId, session_.get(), | 117 stream_ = new TestStream(kTestStreamId, session_.get(), |
| 118 stream_should_process_data); | 118 stream_should_process_data); |
| 119 // session_ now owns stream_. | 119 // session_ now owns stream_. |
| 120 session_->ActivateStream(stream_); | 120 session_->ActivateStream(stream_); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 145 bool /*fin*/, | 145 bool /*fin*/, |
| 146 QuicAckListenerInterface* /*ack_notifier_delegate*/) { | 146 QuicAckListenerInterface* /*ack_notifier_delegate*/) { |
| 147 session_->CloseStream(id); | 147 session_->CloseStream(id); |
| 148 return QuicConsumedData(1, false); | 148 return QuicConsumedData(1, false); |
| 149 } | 149 } |
| 150 | 150 |
| 151 protected: | 151 protected: |
| 152 MockConnectionHelper helper_; | 152 MockConnectionHelper helper_; |
| 153 MockAlarmFactory alarm_factory_; | 153 MockAlarmFactory alarm_factory_; |
| 154 MockConnection* connection_; | 154 MockConnection* connection_; |
| 155 std::unique_ptr<MockQuicSpdySession> session_; | 155 std::unique_ptr<MockQuicSession> session_; |
| 156 TestStream* stream_; | 156 TestStream* stream_; |
| 157 SpdyHeaderBlock headers_; | 157 SpdyHeaderBlock headers_; |
| 158 QuicWriteBlockedList* write_blocked_list_; | 158 QuicWriteBlockedList* write_blocked_list_; |
| 159 uint32_t initial_flow_control_window_bytes_; | 159 uint32_t initial_flow_control_window_bytes_; |
| 160 QuicTime::Delta zero_; | 160 QuicTime::Delta zero_; |
| 161 QuicVersionVector supported_versions_; | 161 QuicVersionVector supported_versions_; |
| 162 const QuicStreamId kTestStreamId = 5u; | 162 const QuicStreamId kTestStreamId = 5u; |
| 163 }; | 163 }; |
| 164 | 164 |
| 165 TEST_F(ReliableQuicStreamTest, WriteAllData) { | 165 TEST_F(ReliableQuicStreamTest, WriteAllData) { |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); | 641 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); |
| 642 } | 642 } |
| 643 | 643 |
| 644 TEST_F(ReliableQuicStreamTest, EarlyResponseFinHandling) { | 644 TEST_F(ReliableQuicStreamTest, EarlyResponseFinHandling) { |
| 645 // Verify that if the server completes the response before reading the end of | 645 // Verify that if the server completes the response before reading the end of |
| 646 // the request, the received FIN is recorded. | 646 // the request, the received FIN is recorded. |
| 647 | 647 |
| 648 Initialize(kShouldProcessData); | 648 Initialize(kShouldProcessData); |
| 649 EXPECT_CALL(*connection_, CloseConnection(_, _, _)).Times(0); | 649 EXPECT_CALL(*connection_, CloseConnection(_, _, _)).Times(0); |
| 650 EXPECT_CALL(*session_, WritevData(_, _, _, _, _)) | 650 EXPECT_CALL(*session_, WritevData(_, _, _, _, _)) |
| 651 .WillRepeatedly(Invoke(MockQuicSpdySession::ConsumeAllData)); | 651 .WillRepeatedly(Invoke(MockQuicSession::ConsumeAllData)); |
| 652 | 652 |
| 653 // Receive data for the request. | 653 // Receive data for the request. |
| 654 QuicStreamFrame frame1(stream_->id(), false, 0, StringPiece("Start")); | 654 QuicStreamFrame frame1(stream_->id(), false, 0, StringPiece("Start")); |
| 655 stream_->OnStreamFrame(frame1); | 655 stream_->OnStreamFrame(frame1); |
| 656 // When QuicSimpleServerStream sends the response, it calls | 656 // When QuicSimpleServerStream sends the response, it calls |
| 657 // ReliableQuicStream::CloseReadSide() first. | 657 // ReliableQuicStream::CloseReadSide() first. |
| 658 ReliableQuicStreamPeer::CloseReadSide(stream_); | 658 ReliableQuicStreamPeer::CloseReadSide(stream_); |
| 659 // Send data and FIN for the response. | 659 // Send data and FIN for the response. |
| 660 stream_->WriteOrBufferData(kData1, false, nullptr); | 660 stream_->WriteOrBufferData(kData1, false, nullptr); |
| 661 EXPECT_TRUE(ReliableQuicStreamPeer::read_side_closed(stream_)); | 661 EXPECT_TRUE(ReliableQuicStreamPeer::read_side_closed(stream_)); |
| 662 // Receive remaining data and FIN for the request. | 662 // Receive remaining data and FIN for the request. |
| 663 QuicStreamFrame frame2(stream_->id(), true, 0, StringPiece("End")); | 663 QuicStreamFrame frame2(stream_->id(), true, 0, StringPiece("End")); |
| 664 stream_->OnStreamFrame(frame2); | 664 stream_->OnStreamFrame(frame2); |
| 665 EXPECT_TRUE(stream_->fin_received()); | 665 EXPECT_TRUE(stream_->fin_received()); |
| 666 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); | 666 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); |
| 667 } | 667 } |
| 668 | 668 |
| 669 } // namespace | 669 } // namespace |
| 670 } // namespace test | 670 } // namespace test |
| 671 } // namespace net | 671 } // namespace net |
| OLD | NEW |