| 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/core/quic_session.h" | 5 #include "net/quic/core/quic_session.h" |
| 6 | 6 |
| 7 #include <cstdint> | 7 #include <cstdint> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 166 |
| 167 QuicStream* GetOrCreateDynamicStream(QuicStreamId stream_id) { | 167 QuicStream* GetOrCreateDynamicStream(QuicStreamId stream_id) { |
| 168 return QuicSpdySession::GetOrCreateDynamicStream(stream_id); | 168 return QuicSpdySession::GetOrCreateDynamicStream(stream_id); |
| 169 } | 169 } |
| 170 | 170 |
| 171 QuicConsumedData WritevData( | 171 QuicConsumedData WritevData( |
| 172 QuicStream* stream, | 172 QuicStream* stream, |
| 173 QuicStreamId id, | 173 QuicStreamId id, |
| 174 QuicIOVector data, | 174 QuicIOVector data, |
| 175 QuicStreamOffset offset, | 175 QuicStreamOffset offset, |
| 176 bool fin, | 176 StreamSendingState state, |
| 177 QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener) | 177 QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener) |
| 178 override { | 178 override { |
| 179 bool fin = state != NO_FIN; |
| 179 QuicConsumedData consumed(data.total_length, fin); | 180 QuicConsumedData consumed(data.total_length, fin); |
| 180 if (!writev_consumes_all_data_) { | 181 if (!writev_consumes_all_data_) { |
| 181 consumed = QuicSession::WritevData(stream, id, data, offset, fin, | 182 consumed = QuicSession::WritevData(stream, id, data, offset, state, |
| 182 std::move(ack_listener)); | 183 std::move(ack_listener)); |
| 183 } | 184 } |
| 184 stream->set_stream_bytes_written(stream->stream_bytes_written() + | 185 stream->set_stream_bytes_written(stream->stream_bytes_written() + |
| 185 consumed.bytes_consumed); | 186 consumed.bytes_consumed); |
| 186 if (fin && consumed.fin_consumed) { | 187 if (fin && consumed.fin_consumed) { |
| 187 stream->set_fin_sent(true); | 188 stream->set_fin_sent(true); |
| 188 } | 189 } |
| 189 QuicSessionPeer::GetWriteBlockedStreams(this)->UpdateBytesForStream( | 190 QuicSessionPeer::GetWriteBlockedStreams(this)->UpdateBytesForStream( |
| 190 id, consumed.bytes_consumed); | 191 id, consumed.bytes_consumed); |
| 191 return consumed; | 192 return consumed; |
| 192 } | 193 } |
| 193 | 194 |
| 194 void set_writev_consumes_all_data(bool val) { | 195 void set_writev_consumes_all_data(bool val) { |
| 195 writev_consumes_all_data_ = val; | 196 writev_consumes_all_data_ = val; |
| 196 } | 197 } |
| 197 | 198 |
| 198 QuicConsumedData SendStreamData(QuicStream* stream) { | 199 QuicConsumedData SendStreamData(QuicStream* stream) { |
| 199 struct iovec iov; | 200 struct iovec iov; |
| 200 if (stream->id() != kCryptoStreamId) { | 201 if (stream->id() != kCryptoStreamId) { |
| 201 this->connection()->SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); | 202 this->connection()->SetDefaultEncryptionLevel(ENCRYPTION_FORWARD_SECURE); |
| 202 } | 203 } |
| 203 QuicConsumedData consumed = | 204 QuicConsumedData consumed = WritevData( |
| 204 WritevData(stream, stream->id(), MakeIOVector("not empty", &iov), 0, | 205 stream, stream->id(), MakeIOVector("not empty", &iov), 0, FIN, nullptr); |
| 205 true, nullptr); | |
| 206 return consumed; | 206 return consumed; |
| 207 } | 207 } |
| 208 | 208 |
| 209 QuicConsumedData SendLargeFakeData(QuicStream* stream, int bytes) { | 209 QuicConsumedData SendLargeFakeData(QuicStream* stream, int bytes) { |
| 210 DCHECK(writev_consumes_all_data_); | 210 DCHECK(writev_consumes_all_data_); |
| 211 struct iovec iov; | 211 struct iovec iov; |
| 212 iov.iov_base = nullptr; // should not be read. | 212 iov.iov_base = nullptr; // should not be read. |
| 213 iov.iov_len = static_cast<size_t>(bytes); | 213 iov.iov_len = static_cast<size_t>(bytes); |
| 214 return WritevData(stream, stream->id(), QuicIOVector(&iov, 1, bytes), 0, | 214 return WritevData(stream, stream->id(), QuicIOVector(&iov, 1, bytes), 0, |
| 215 true, nullptr); | 215 FIN, nullptr); |
| 216 } | 216 } |
| 217 | 217 |
| 218 using QuicSession::PostProcessAfterData; | 218 using QuicSession::PostProcessAfterData; |
| 219 | 219 |
| 220 private: | 220 private: |
| 221 StrictMock<TestCryptoStream> crypto_stream_; | 221 StrictMock<TestCryptoStream> crypto_stream_; |
| 222 | 222 |
| 223 bool writev_consumes_all_data_; | 223 bool writev_consumes_all_data_; |
| 224 }; | 224 }; |
| 225 | 225 |
| (...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1314 if (version() != QUIC_VERSION_36) { | 1314 if (version() != QUIC_VERSION_36) { |
| 1315 EXPECT_FALSE(session_.force_hol_blocking()); | 1315 EXPECT_FALSE(session_.force_hol_blocking()); |
| 1316 } else { | 1316 } else { |
| 1317 EXPECT_TRUE(session_.force_hol_blocking()); | 1317 EXPECT_TRUE(session_.force_hol_blocking()); |
| 1318 } | 1318 } |
| 1319 } | 1319 } |
| 1320 | 1320 |
| 1321 } // namespace | 1321 } // namespace |
| 1322 } // namespace test | 1322 } // namespace test |
| 1323 } // namespace net | 1323 } // namespace net |
| OLD | NEW |