| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 const bool kShouldNotProcessData = false; | 44 const bool kShouldNotProcessData = false; |
| 45 | 45 |
| 46 class TestStream : public ReliableQuicStream { | 46 class TestStream : public ReliableQuicStream { |
| 47 public: | 47 public: |
| 48 TestStream(QuicStreamId id, QuicSession* session, bool should_process_data) | 48 TestStream(QuicStreamId id, QuicSession* session, bool should_process_data) |
| 49 : ReliableQuicStream(id, session), | 49 : ReliableQuicStream(id, session), |
| 50 should_process_data_(should_process_data) {} | 50 should_process_data_(should_process_data) {} |
| 51 | 51 |
| 52 void OnDataAvailable() override {} | 52 void OnDataAvailable() override {} |
| 53 | 53 |
| 54 uint32 ProcessRawData(const char* data, uint32 data_len) { | 54 uint32_t ProcessRawData(const char* data, uint32_t data_len) { |
| 55 EXPECT_NE(0u, data_len); | 55 EXPECT_NE(0u, data_len); |
| 56 DVLOG(1) << "ProcessData data_len: " << data_len; | 56 DVLOG(1) << "ProcessData data_len: " << data_len; |
| 57 data_ += string(data, data_len); | 57 data_ += string(data, data_len); |
| 58 return should_process_data_ ? data_len : 0; | 58 return should_process_data_ ? data_len : 0; |
| 59 } | 59 } |
| 60 | 60 |
| 61 SpdyPriority Priority() const override { return net::kV3HighestPriority; } | 61 SpdyPriority Priority() const override { return net::kV3HighestPriority; } |
| 62 | 62 |
| 63 using ReliableQuicStream::WriteOrBufferData; | 63 using ReliableQuicStream::WriteOrBufferData; |
| 64 using ReliableQuicStream::CloseWriteSide; | 64 using ReliableQuicStream::CloseWriteSide; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 EXPECT_CALL(*session_, SendRstStream(kTestStreamId, _, _)) | 122 EXPECT_CALL(*session_, SendRstStream(kTestStreamId, _, _)) |
| 123 .Times(AnyNumber()); | 123 .Times(AnyNumber()); |
| 124 write_blocked_list_ = | 124 write_blocked_list_ = |
| 125 QuicSessionPeer::GetWriteBlockedStreams(session_.get()); | 125 QuicSessionPeer::GetWriteBlockedStreams(session_.get()); |
| 126 write_blocked_list_->RegisterStream(kTestStreamId, kV3HighestPriority); | 126 write_blocked_list_->RegisterStream(kTestStreamId, kV3HighestPriority); |
| 127 } | 127 } |
| 128 | 128 |
| 129 bool fin_sent() { return ReliableQuicStreamPeer::FinSent(stream_); } | 129 bool fin_sent() { return ReliableQuicStreamPeer::FinSent(stream_); } |
| 130 bool rst_sent() { return ReliableQuicStreamPeer::RstSent(stream_); } | 130 bool rst_sent() { return ReliableQuicStreamPeer::RstSent(stream_); } |
| 131 | 131 |
| 132 void set_initial_flow_control_window_bytes(uint32 val) { | 132 void set_initial_flow_control_window_bytes(uint32_t val) { |
| 133 initial_flow_control_window_bytes_ = val; | 133 initial_flow_control_window_bytes_ = val; |
| 134 } | 134 } |
| 135 | 135 |
| 136 bool HasWriteBlockedStreams() { | 136 bool HasWriteBlockedStreams() { |
| 137 return write_blocked_list_->HasWriteBlockedCryptoOrHeadersStream() || | 137 return write_blocked_list_->HasWriteBlockedCryptoOrHeadersStream() || |
| 138 write_blocked_list_->HasWriteBlockedDataStreams(); | 138 write_blocked_list_->HasWriteBlockedDataStreams(); |
| 139 } | 139 } |
| 140 | 140 |
| 141 QuicConsumedData CloseStreamOnWriteError( | 141 QuicConsumedData CloseStreamOnWriteError( |
| 142 QuicStreamId id, | 142 QuicStreamId id, |
| 143 QuicIOVector /*iov*/, | 143 QuicIOVector /*iov*/, |
| 144 QuicStreamOffset /*offset*/, | 144 QuicStreamOffset /*offset*/, |
| 145 bool /*fin*/, | 145 bool /*fin*/, |
| 146 FecProtection /*fec_protection*/, | 146 FecProtection /*fec_protection*/, |
| 147 QuicAckListenerInterface* /*ack_notifier_delegate*/) { | 147 QuicAckListenerInterface* /*ack_notifier_delegate*/) { |
| 148 session_->CloseStream(id); | 148 session_->CloseStream(id); |
| 149 return QuicConsumedData(1, false); | 149 return QuicConsumedData(1, false); |
| 150 } | 150 } |
| 151 | 151 |
| 152 protected: | 152 protected: |
| 153 MockConnectionHelper helper_; | 153 MockConnectionHelper helper_; |
| 154 MockConnection* connection_; | 154 MockConnection* connection_; |
| 155 scoped_ptr<MockQuicSpdySession> session_; | 155 scoped_ptr<MockQuicSpdySession> 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 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) { |
| 166 Initialize(kShouldProcessData); | 166 Initialize(kShouldProcessData); |
| 167 | 167 |
| 168 size_t length = 1 + QuicPacketCreator::StreamFramePacketOverhead( | 168 size_t length = 1 + QuicPacketCreator::StreamFramePacketOverhead( |
| 169 PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, | 169 PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 // Receive remaining data and FIN for the request. | 745 // Receive remaining data and FIN for the request. |
| 746 QuicStreamFrame frame2(stream_->id(), true, 0, StringPiece("End")); | 746 QuicStreamFrame frame2(stream_->id(), true, 0, StringPiece("End")); |
| 747 stream_->OnStreamFrame(frame2); | 747 stream_->OnStreamFrame(frame2); |
| 748 EXPECT_TRUE(stream_->fin_received()); | 748 EXPECT_TRUE(stream_->fin_received()); |
| 749 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); | 749 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); |
| 750 } | 750 } |
| 751 | 751 |
| 752 } // namespace | 752 } // namespace |
| 753 } // namespace test | 753 } // namespace test |
| 754 } // namespace net | 754 } // namespace net |
| OLD | NEW |