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_connection.h" | 5 #include "net/quic/quic_connection.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <iterator> | 10 #include <iterator> |
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 } | 982 } |
983 | 983 |
984 pending_version_negotiation_packet_ = false; | 984 pending_version_negotiation_packet_ = false; |
985 } | 985 } |
986 | 986 |
987 QuicConsumedData QuicConnection::SendStreamData( | 987 QuicConsumedData QuicConnection::SendStreamData( |
988 QuicStreamId id, | 988 QuicStreamId id, |
989 const IOVector& data, | 989 const IOVector& data, |
990 QuicStreamOffset offset, | 990 QuicStreamOffset offset, |
991 bool fin, | 991 bool fin, |
| 992 FecProtection fec_protection, |
992 QuicAckNotifier::DelegateInterface* delegate) { | 993 QuicAckNotifier::DelegateInterface* delegate) { |
993 if (!fin && data.Empty()) { | 994 if (!fin && data.Empty()) { |
994 LOG(DFATAL) << "Attempt to send empty stream frame"; | 995 LOG(DFATAL) << "Attempt to send empty stream frame"; |
995 } | 996 } |
996 | 997 |
997 // This notifier will be owned by the AckNotifierManager (or deleted below if | 998 // This notifier will be owned by the AckNotifierManager (or deleted below if |
998 // no data or FIN was consumed). | 999 // no data or FIN was consumed). |
999 QuicAckNotifier* notifier = NULL; | 1000 QuicAckNotifier* notifier = NULL; |
1000 if (delegate) { | 1001 if (delegate) { |
1001 notifier = new QuicAckNotifier(delegate); | 1002 notifier = new QuicAckNotifier(delegate); |
1002 } | 1003 } |
1003 | 1004 |
1004 // Opportunistically bundle an ack with every outgoing packet. | 1005 // Opportunistically bundle an ack with every outgoing packet. |
1005 // Particularly, we want to bundle with handshake packets since we don't know | 1006 // Particularly, we want to bundle with handshake packets since we don't know |
1006 // which decrypter will be used on an ack packet following a handshake | 1007 // which decrypter will be used on an ack packet following a handshake |
1007 // packet (a handshake packet from client to server could result in a REJ or a | 1008 // packet (a handshake packet from client to server could result in a REJ or a |
1008 // SHLO from the server, leading to two different decrypters at the server.) | 1009 // SHLO from the server, leading to two different decrypters at the server.) |
1009 // | 1010 // |
1010 // TODO(jri): Note that ConsumeData may cause a response packet to be sent. | 1011 // TODO(jri): Note that ConsumeData may cause a response packet to be sent. |
1011 // We may end up sending stale ack information if there are undecryptable | 1012 // We may end up sending stale ack information if there are undecryptable |
1012 // packets hanging around and/or there are revivable packets which may get | 1013 // packets hanging around and/or there are revivable packets which may get |
1013 // handled after this packet is sent. Change ScopedPacketBundler to do the | 1014 // handled after this packet is sent. Change ScopedPacketBundler to do the |
1014 // right thing: check ack_queued_, and then check undecryptable packets and | 1015 // right thing: check ack_queued_, and then check undecryptable packets and |
1015 // also if there is possibility of revival. Only bundle an ack if there's no | 1016 // also if there is possibility of revival. Only bundle an ack if there's no |
1016 // processing left that may cause received_info_ to change. | 1017 // processing left that may cause received_info_ to change. |
1017 ScopedPacketBundler ack_bundler(this, BUNDLE_PENDING_ACK); | 1018 ScopedPacketBundler ack_bundler(this, BUNDLE_PENDING_ACK); |
1018 QuicConsumedData consumed_data = | 1019 QuicConsumedData consumed_data = |
1019 packet_generator_.ConsumeData(id, data, offset, fin, notifier); | 1020 packet_generator_.ConsumeData(id, data, offset, fin, fec_protection, |
| 1021 notifier); |
1020 | 1022 |
1021 if (notifier && | 1023 if (notifier && |
1022 (consumed_data.bytes_consumed == 0 && !consumed_data.fin_consumed)) { | 1024 (consumed_data.bytes_consumed == 0 && !consumed_data.fin_consumed)) { |
1023 // No data was consumed, nor was a fin consumed, so delete the notifier. | 1025 // No data was consumed, nor was a fin consumed, so delete the notifier. |
1024 delete notifier; | 1026 delete notifier; |
1025 } | 1027 } |
1026 | 1028 |
1027 return consumed_data; | 1029 return consumed_data; |
1028 } | 1030 } |
1029 | 1031 |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1563 if (retransmission_alarm_->IsSet()) { | 1565 if (retransmission_alarm_->IsSet()) { |
1564 return; | 1566 return; |
1565 } | 1567 } |
1566 if (version() <= QUIC_VERSION_17) { | 1568 if (version() <= QUIC_VERSION_17) { |
1567 // TODO(rch): remove this when we remove version 17. | 1569 // TODO(rch): remove this when we remove version 17. |
1568 // This is a horrible hideous hack which we should not support. | 1570 // This is a horrible hideous hack which we should not support. |
1569 IOVector data; | 1571 IOVector data; |
1570 char c_data[] = "C"; | 1572 char c_data[] = "C"; |
1571 data.Append(c_data, 1); | 1573 data.Append(c_data, 1); |
1572 QuicConsumedData consumed_data = | 1574 QuicConsumedData consumed_data = |
1573 packet_generator_.ConsumeData(kCryptoStreamId, data, 0, false, NULL); | 1575 packet_generator_.ConsumeData(kCryptoStreamId, data, 0, false, |
| 1576 MAY_FEC_PROTECT, NULL); |
1574 if (consumed_data.bytes_consumed == 0) { | 1577 if (consumed_data.bytes_consumed == 0) { |
1575 DLOG(ERROR) << "Unable to send ping!?"; | 1578 DLOG(ERROR) << "Unable to send ping!?"; |
1576 } | 1579 } |
1577 } else { | 1580 } else { |
1578 packet_generator_.AddControlFrame(QuicFrame(new QuicPingFrame)); | 1581 packet_generator_.AddControlFrame(QuicFrame(new QuicPingFrame)); |
1579 } | 1582 } |
1580 } | 1583 } |
1581 | 1584 |
1582 void QuicConnection::SendAck() { | 1585 void QuicConnection::SendAck() { |
1583 ack_alarm_->Cancel(); | 1586 ack_alarm_->Cancel(); |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1962 // If we changed the generator's batch state, restore original batch state. | 1965 // If we changed the generator's batch state, restore original batch state. |
1963 if (!already_in_batch_mode_) { | 1966 if (!already_in_batch_mode_) { |
1964 DVLOG(1) << "Leaving Batch Mode."; | 1967 DVLOG(1) << "Leaving Batch Mode."; |
1965 connection_->packet_generator_.FinishBatchOperations(); | 1968 connection_->packet_generator_.FinishBatchOperations(); |
1966 } | 1969 } |
1967 DCHECK_EQ(already_in_batch_mode_, | 1970 DCHECK_EQ(already_in_batch_mode_, |
1968 connection_->packet_generator_.InBatchMode()); | 1971 connection_->packet_generator_.InBatchMode()); |
1969 } | 1972 } |
1970 | 1973 |
1971 } // namespace net | 1974 } // namespace net |
OLD | NEW |