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 <utility> | 8 #include <utility> |
9 | 9 |
10 #include "net/quic/core/quic_connection.h" | 10 #include "net/quic/core/quic_connection.h" |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 const QuicSocketAddress& peer_address, | 281 const QuicSocketAddress& peer_address, |
282 const QuicReceivedPacket& packet) { | 282 const QuicReceivedPacket& packet) { |
283 connection_->ProcessUdpPacket(self_address, peer_address, packet); | 283 connection_->ProcessUdpPacket(self_address, peer_address, packet); |
284 } | 284 } |
285 | 285 |
286 QuicConsumedData QuicSession::WritevData( | 286 QuicConsumedData QuicSession::WritevData( |
287 QuicStream* stream, | 287 QuicStream* stream, |
288 QuicStreamId id, | 288 QuicStreamId id, |
289 QuicIOVector iov, | 289 QuicIOVector iov, |
290 QuicStreamOffset offset, | 290 QuicStreamOffset offset, |
291 bool fin, | 291 StreamSendingState state, |
292 QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener) { | 292 QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener) { |
293 // This check is an attempt to deal with potential memory corruption | 293 // This check is an attempt to deal with potential memory corruption |
294 // in which |id| ends up set to 1 (the crypto stream id). If this happen | 294 // in which |id| ends up set to 1 (the crypto stream id). If this happen |
295 // it might end up resulting in unencrypted stream data being sent. | 295 // it might end up resulting in unencrypted stream data being sent. |
296 // While this is impossible to avoid given sufficient corruption, this | 296 // While this is impossible to avoid given sufficient corruption, this |
297 // seems like a reasonable mitigation. | 297 // seems like a reasonable mitigation. |
298 if (id == kCryptoStreamId && stream != GetMutableCryptoStream()) { | 298 if (id == kCryptoStreamId && stream != GetMutableCryptoStream()) { |
299 QUIC_BUG << "Stream id mismatch"; | 299 QUIC_BUG << "Stream id mismatch"; |
300 connection_->CloseConnection( | 300 connection_->CloseConnection( |
301 QUIC_INTERNAL_ERROR, | 301 QUIC_INTERNAL_ERROR, |
302 "Non-crypto stream attempted to write data as crypto stream.", | 302 "Non-crypto stream attempted to write data as crypto stream.", |
303 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); | 303 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); |
304 return QuicConsumedData(0, false); | 304 return QuicConsumedData(0, false); |
305 } | 305 } |
306 if (!IsEncryptionEstablished() && id != kCryptoStreamId) { | 306 if (!IsEncryptionEstablished() && id != kCryptoStreamId) { |
307 // Do not let streams write without encryption. The calling stream will end | 307 // Do not let streams write without encryption. The calling stream will end |
308 // up write blocked until OnCanWrite is next called. | 308 // up write blocked until OnCanWrite is next called. |
309 return QuicConsumedData(0, false); | 309 return QuicConsumedData(0, false); |
310 } | 310 } |
311 QuicConsumedData data = connection_->SendStreamData(id, iov, offset, fin, | 311 QuicConsumedData data = connection_->SendStreamData(id, iov, offset, state, |
312 std::move(ack_listener)); | 312 std::move(ack_listener)); |
313 write_blocked_streams_.UpdateBytesForStream(id, data.bytes_consumed); | 313 write_blocked_streams_.UpdateBytesForStream(id, data.bytes_consumed); |
314 return data; | 314 return data; |
315 } | 315 } |
316 | 316 |
317 void QuicSession::SendRstStream(QuicStreamId id, | 317 void QuicSession::SendRstStream(QuicStreamId id, |
318 QuicRstStreamErrorCode error, | 318 QuicRstStreamErrorCode error, |
319 QuicStreamOffset bytes_written) { | 319 QuicStreamOffset bytes_written) { |
320 if (QuicContainsKey(static_stream_map_, id)) { | 320 if (QuicContainsKey(static_stream_map_, id)) { |
321 QUIC_BUG << "Cannot send RST for a static stream with ID " << id; | 321 QUIC_BUG << "Cannot send RST for a static stream with ID " << id; |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 | 857 |
858 size_t QuicSession::MaxAvailableStreams() const { | 858 size_t QuicSession::MaxAvailableStreams() const { |
859 return max_open_incoming_streams_ * kMaxAvailableStreamsMultiplier; | 859 return max_open_incoming_streams_ * kMaxAvailableStreamsMultiplier; |
860 } | 860 } |
861 | 861 |
862 bool QuicSession::IsIncomingStream(QuicStreamId id) const { | 862 bool QuicSession::IsIncomingStream(QuicStreamId id) const { |
863 return id % 2 != next_outgoing_stream_id_ % 2; | 863 return id % 2 != next_outgoing_stream_id_ % 2; |
864 } | 864 } |
865 | 865 |
866 } // namespace net | 866 } // namespace net |
OLD | NEW |