| 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/quic_session.h" | 5 #include "net/quic/quic_session.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "net/quic/crypto/proof_verifier.h" | 10 #include "net/quic/crypto/proof_verifier.h" |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 connection_->ProcessUdpPacket(self_address, peer_address, packet); | 234 connection_->ProcessUdpPacket(self_address, peer_address, packet); |
| 235 } | 235 } |
| 236 | 236 |
| 237 QuicConsumedData QuicSession::WritevData( | 237 QuicConsumedData QuicSession::WritevData( |
| 238 QuicStreamId id, | 238 QuicStreamId id, |
| 239 QuicIOVector iov, | 239 QuicIOVector iov, |
| 240 QuicStreamOffset offset, | 240 QuicStreamOffset offset, |
| 241 bool fin, | 241 bool fin, |
| 242 FecProtection fec_protection, | 242 FecProtection fec_protection, |
| 243 QuicAckListenerInterface* ack_notifier_delegate) { | 243 QuicAckListenerInterface* ack_notifier_delegate) { |
| 244 if (FLAGS_quic_block_unencrypted_writes && !IsEncryptionEstablished() && | 244 if (!IsEncryptionEstablished() && id != kCryptoStreamId) { |
| 245 id != kCryptoStreamId) { | |
| 246 // Do not let streams write without encryption. The calling stream will end | 245 // Do not let streams write without encryption. The calling stream will end |
| 247 // up write blocked until OnCanWrite is next called. | 246 // up write blocked until OnCanWrite is next called. |
| 248 return QuicConsumedData(0, false); | 247 return QuicConsumedData(0, false); |
| 249 } | 248 } |
| 250 QuicConsumedData data = connection_->SendStreamData( | 249 QuicConsumedData data = connection_->SendStreamData( |
| 251 id, iov, offset, fin, fec_protection, ack_notifier_delegate); | 250 id, iov, offset, fin, fec_protection, ack_notifier_delegate); |
| 252 write_blocked_streams_.UpdateBytesForStream(id, data.bytes_consumed); | 251 write_blocked_streams_.UpdateBytesForStream(id, data.bytes_consumed); |
| 253 return data; | 252 return data; |
| 254 } | 253 } |
| 255 | 254 |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 | 522 |
| 524 flow_controller_.UpdateSendWindowOffset(new_window); | 523 flow_controller_.UpdateSendWindowOffset(new_window); |
| 525 } | 524 } |
| 526 | 525 |
| 527 void QuicSession::OnCryptoHandshakeEvent(CryptoHandshakeEvent event) { | 526 void QuicSession::OnCryptoHandshakeEvent(CryptoHandshakeEvent event) { |
| 528 switch (event) { | 527 switch (event) { |
| 529 // TODO(satyamshekhar): Move the logic of setting the encrypter/decrypter | 528 // TODO(satyamshekhar): Move the logic of setting the encrypter/decrypter |
| 530 // to QuicSession since it is the glue. | 529 // to QuicSession since it is the glue. |
| 531 case ENCRYPTION_FIRST_ESTABLISHED: | 530 case ENCRYPTION_FIRST_ESTABLISHED: |
| 532 // Given any streams blocked by encryption a chance to write. | 531 // Given any streams blocked by encryption a chance to write. |
| 533 if (FLAGS_quic_block_unencrypted_writes) { | 532 OnCanWrite(); |
| 534 OnCanWrite(); | |
| 535 } | |
| 536 break; | 533 break; |
| 537 | 534 |
| 538 case ENCRYPTION_REESTABLISHED: | 535 case ENCRYPTION_REESTABLISHED: |
| 539 // Retransmit originally packets that were sent, since they can't be | 536 // Retransmit originally packets that were sent, since they can't be |
| 540 // decrypted by the peer. | 537 // decrypted by the peer. |
| 541 connection_->RetransmitUnackedPackets(ALL_INITIAL_RETRANSMISSION); | 538 connection_->RetransmitUnackedPackets(ALL_INITIAL_RETRANSMISSION); |
| 542 // Given any streams blocked by encryption a chance to write. | 539 // Given any streams blocked by encryption a chance to write. |
| 543 if (FLAGS_quic_block_unencrypted_writes) { | 540 OnCanWrite(); |
| 544 OnCanWrite(); | |
| 545 } | |
| 546 break; | 541 break; |
| 547 | 542 |
| 548 case HANDSHAKE_CONFIRMED: | 543 case HANDSHAKE_CONFIRMED: |
| 549 QUIC_BUG_IF(!config_.negotiated()) | 544 QUIC_BUG_IF(!config_.negotiated()) |
| 550 << ENDPOINT << "Handshake confirmed without parameter negotiation."; | 545 << ENDPOINT << "Handshake confirmed without parameter negotiation."; |
| 551 // Discard originally encrypted packets, since they can't be decrypted by | 546 // Discard originally encrypted packets, since they can't be decrypted by |
| 552 // the peer. | 547 // the peer. |
| 553 connection_->NeuterUnencryptedPackets(); | 548 connection_->NeuterUnencryptedPackets(); |
| 554 break; | 549 break; |
| 555 | 550 |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 | 802 |
| 808 size_t QuicSession::MaxAvailableStreams() const { | 803 size_t QuicSession::MaxAvailableStreams() const { |
| 809 return max_open_incoming_streams_ * kMaxAvailableStreamsMultiplier; | 804 return max_open_incoming_streams_ * kMaxAvailableStreamsMultiplier; |
| 810 } | 805 } |
| 811 | 806 |
| 812 bool QuicSession::IsIncomingStream(QuicStreamId id) const { | 807 bool QuicSession::IsIncomingStream(QuicStreamId id) const { |
| 813 return id % 2 != next_outgoing_stream_id_ % 2; | 808 return id % 2 != next_outgoing_stream_id_ % 2; |
| 814 } | 809 } |
| 815 | 810 |
| 816 } // namespace net | 811 } // namespace net |
| OLD | NEW |