| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 QuicWriteBlockedList* write_blocked_list_; | 155 QuicWriteBlockedList* write_blocked_list_; |
| 156 uint32_t initial_flow_control_window_bytes_; | 156 uint32_t initial_flow_control_window_bytes_; |
| 157 QuicTime::Delta zero_; | 157 QuicTime::Delta zero_; |
| 158 QuicVersionVector supported_versions_; | 158 QuicVersionVector supported_versions_; |
| 159 const QuicStreamId kTestStreamId = 5u; | 159 const QuicStreamId kTestStreamId = 5u; |
| 160 }; | 160 }; |
| 161 | 161 |
| 162 TEST_F(ReliableQuicStreamTest, WriteAllData) { | 162 TEST_F(ReliableQuicStreamTest, WriteAllData) { |
| 163 Initialize(kShouldProcessData); | 163 Initialize(kShouldProcessData); |
| 164 | 164 |
| 165 size_t length = | 165 size_t length = 1 + QuicPacketCreator::StreamFramePacketOverhead( |
| 166 1 + QuicPacketCreator::StreamFramePacketOverhead( | 166 PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
| 167 PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, !kIncludePathId, | 167 !kIncludePathId, PACKET_6BYTE_PACKET_NUMBER, 0u); |
| 168 PACKET_6BYTE_PACKET_NUMBER, 0u, NOT_IN_FEC_GROUP); | |
| 169 connection_->SetMaxPacketLength(length); | 168 connection_->SetMaxPacketLength(length); |
| 170 | 169 |
| 171 EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _)) | 170 EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _)) |
| 172 .WillOnce(Return(QuicConsumedData(kDataLen, true))); | 171 .WillOnce(Return(QuicConsumedData(kDataLen, true))); |
| 173 stream_->WriteOrBufferData(kData1, false, nullptr); | 172 stream_->WriteOrBufferData(kData1, false, nullptr); |
| 174 EXPECT_FALSE(HasWriteBlockedStreams()); | 173 EXPECT_FALSE(HasWriteBlockedStreams()); |
| 175 } | 174 } |
| 176 | 175 |
| 177 TEST_F(ReliableQuicStreamTest, NoBlockingIfNoDataOrFin) { | 176 TEST_F(ReliableQuicStreamTest, NoBlockingIfNoDataOrFin) { |
| 178 Initialize(kShouldProcessData); | 177 Initialize(kShouldProcessData); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _)) | 227 EXPECT_CALL(*session_, WritevData(kTestStreamId, _, _, _, _)) |
| 229 .WillOnce(Invoke(this, &ReliableQuicStreamTest::CloseStreamOnWriteError)); | 228 .WillOnce(Invoke(this, &ReliableQuicStreamTest::CloseStreamOnWriteError)); |
| 230 stream_->WriteOrBufferData(StringPiece(kData1, 2), false, nullptr); | 229 stream_->WriteOrBufferData(StringPiece(kData1, 2), false, nullptr); |
| 231 ASSERT_EQ(0u, write_blocked_list_->NumBlockedStreams()); | 230 ASSERT_EQ(0u, write_blocked_list_->NumBlockedStreams()); |
| 232 } | 231 } |
| 233 | 232 |
| 234 TEST_F(ReliableQuicStreamTest, WriteOrBufferData) { | 233 TEST_F(ReliableQuicStreamTest, WriteOrBufferData) { |
| 235 Initialize(kShouldProcessData); | 234 Initialize(kShouldProcessData); |
| 236 | 235 |
| 237 EXPECT_FALSE(HasWriteBlockedStreams()); | 236 EXPECT_FALSE(HasWriteBlockedStreams()); |
| 238 size_t length = | 237 size_t length = 1 + QuicPacketCreator::StreamFramePacketOverhead( |
| 239 1 + QuicPacketCreator::StreamFramePacketOverhead( | 238 PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
| 240 PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, !kIncludePathId, | 239 !kIncludePathId, PACKET_6BYTE_PACKET_NUMBER, 0u); |
| 241 PACKET_6BYTE_PACKET_NUMBER, 0u, NOT_IN_FEC_GROUP); | |
| 242 connection_->SetMaxPacketLength(length); | 240 connection_->SetMaxPacketLength(length); |
| 243 | 241 |
| 244 EXPECT_CALL(*session_, WritevData(_, _, _, _, _)) | 242 EXPECT_CALL(*session_, WritevData(_, _, _, _, _)) |
| 245 .WillOnce(Return(QuicConsumedData(kDataLen - 1, false))); | 243 .WillOnce(Return(QuicConsumedData(kDataLen - 1, false))); |
| 246 stream_->WriteOrBufferData(kData1, false, nullptr); | 244 stream_->WriteOrBufferData(kData1, false, nullptr); |
| 247 EXPECT_TRUE(HasWriteBlockedStreams()); | 245 EXPECT_TRUE(HasWriteBlockedStreams()); |
| 248 | 246 |
| 249 // Queue a bytes_consumed write. | 247 // Queue a bytes_consumed write. |
| 250 stream_->WriteOrBufferData(kData2, false, nullptr); | 248 stream_->WriteOrBufferData(kData2, false, nullptr); |
| 251 | 249 |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 // Receive remaining data and FIN for the request. | 657 // Receive remaining data and FIN for the request. |
| 660 QuicStreamFrame frame2(stream_->id(), true, 0, StringPiece("End")); | 658 QuicStreamFrame frame2(stream_->id(), true, 0, StringPiece("End")); |
| 661 stream_->OnStreamFrame(frame2); | 659 stream_->OnStreamFrame(frame2); |
| 662 EXPECT_TRUE(stream_->fin_received()); | 660 EXPECT_TRUE(stream_->fin_received()); |
| 663 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); | 661 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); |
| 664 } | 662 } |
| 665 | 663 |
| 666 } // namespace | 664 } // namespace |
| 667 } // namespace test | 665 } // namespace test |
| 668 } // namespace net | 666 } // namespace net |
| OLD | NEW |