| 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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 2151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2162 PACKET_4BYTE_SEQUENCE_NUMBER, | 2162 PACKET_4BYTE_SEQUENCE_NUMBER, |
| 2163 PACKET_2BYTE_SEQUENCE_NUMBER, | 2163 PACKET_2BYTE_SEQUENCE_NUMBER, |
| 2164 PACKET_1BYTE_SEQUENCE_NUMBER}; | 2164 PACKET_1BYTE_SEQUENCE_NUMBER}; |
| 2165 // For each sequence number length size, revive a packet and check sequence | 2165 // For each sequence number length size, revive a packet and check sequence |
| 2166 // number length in the revived packet. | 2166 // number length in the revived packet. |
| 2167 for (size_t i = 0; i < arraysize(lengths); ++i) { | 2167 for (size_t i = 0; i < arraysize(lengths); ++i) { |
| 2168 // Set sequence_number_length_ (for data and FEC packets). | 2168 // Set sequence_number_length_ (for data and FEC packets). |
| 2169 sequence_number_length_ = lengths[i]; | 2169 sequence_number_length_ = lengths[i]; |
| 2170 fec_packet += 2; | 2170 fec_packet += 2; |
| 2171 // Don't send missing packet, but send fec packet right after it. | 2171 // Don't send missing packet, but send fec packet right after it. |
| 2172 ProcessFecPacket(/*seq_num=*/fec_packet, /*fec_group=*/fec_packet - 1, | 2172 ProcessFecPacket(fec_packet, fec_packet - 1, true, !kEntropyFlag, NULL); |
| 2173 true, !kEntropyFlag, NULL); | |
| 2174 // Sequence number length in the revived header should be the same as | 2173 // Sequence number length in the revived header should be the same as |
| 2175 // in the original data/fec packet headers. | 2174 // in the original data/fec packet headers. |
| 2176 EXPECT_EQ(sequence_number_length_, fec_visitor->revived_header(). | 2175 EXPECT_EQ(sequence_number_length_, fec_visitor->revived_header(). |
| 2177 public_header.sequence_number_length); | 2176 public_header.sequence_number_length); |
| 2178 } | 2177 } |
| 2179 } | 2178 } |
| 2180 | 2179 |
| 2181 TEST_P(QuicConnectionTest, ReviveMissingPacketWithVaryingConnectionIdLengths) { | 2180 TEST_P(QuicConnectionTest, ReviveMissingPacketWithVaryingConnectionIdLengths) { |
| 2182 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2181 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2183 | 2182 |
| 2184 // Set up a debug visitor to the connection. | 2183 // Set up a debug visitor to the connection. |
| 2185 scoped_ptr<FecQuicConnectionDebugVisitor> | 2184 scoped_ptr<FecQuicConnectionDebugVisitor> |
| 2186 fec_visitor(new FecQuicConnectionDebugVisitor); | 2185 fec_visitor(new FecQuicConnectionDebugVisitor); |
| 2187 connection_.set_debug_visitor(fec_visitor.get()); | 2186 connection_.set_debug_visitor(fec_visitor.get()); |
| 2188 | 2187 |
| 2189 QuicPacketSequenceNumber fec_packet = 0; | 2188 QuicPacketSequenceNumber fec_packet = 0; |
| 2190 QuicConnectionIdLength lengths[] = {PACKET_8BYTE_CONNECTION_ID, | 2189 QuicConnectionIdLength lengths[] = {PACKET_8BYTE_CONNECTION_ID, |
| 2191 PACKET_4BYTE_CONNECTION_ID, | 2190 PACKET_4BYTE_CONNECTION_ID, |
| 2192 PACKET_1BYTE_CONNECTION_ID, | 2191 PACKET_1BYTE_CONNECTION_ID, |
| 2193 PACKET_0BYTE_CONNECTION_ID}; | 2192 PACKET_0BYTE_CONNECTION_ID}; |
| 2194 // For each connection id length size, revive a packet and check connection | 2193 // For each connection id length size, revive a packet and check connection |
| 2195 // id length in the revived packet. | 2194 // id length in the revived packet. |
| 2196 for (size_t i = 0; i < arraysize(lengths); ++i) { | 2195 for (size_t i = 0; i < arraysize(lengths); ++i) { |
| 2197 // Set connection id length (for data and FEC packets). | 2196 // Set connection id length (for data and FEC packets). |
| 2198 connection_id_length_ = lengths[i]; | 2197 connection_id_length_ = lengths[i]; |
| 2199 fec_packet += 2; | 2198 fec_packet += 2; |
| 2200 // Don't send missing packet, but send fec packet right after it. | 2199 // Don't send missing packet, but send fec packet right after it. |
| 2201 ProcessFecPacket(/*seq_num=*/fec_packet, /*fec_group=*/fec_packet - 1, | 2200 ProcessFecPacket(fec_packet, fec_packet - 1, true, !kEntropyFlag, NULL); |
| 2202 true, !kEntropyFlag, NULL); | |
| 2203 // Connection id length in the revived header should be the same as | 2201 // Connection id length in the revived header should be the same as |
| 2204 // in the original data/fec packet headers. | 2202 // in the original data/fec packet headers. |
| 2205 EXPECT_EQ(connection_id_length_, | 2203 EXPECT_EQ(connection_id_length_, |
| 2206 fec_visitor->revived_header().public_header.connection_id_length); | 2204 fec_visitor->revived_header().public_header.connection_id_length); |
| 2207 } | 2205 } |
| 2208 } | 2206 } |
| 2209 | 2207 |
| 2210 TEST_P(QuicConnectionTest, ReviveMissingPacketAfterDataPacketThenFecPacket) { | 2208 TEST_P(QuicConnectionTest, ReviveMissingPacketAfterDataPacketThenFecPacket) { |
| 2211 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2209 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2212 | 2210 |
| (...skipping 1805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4018 QuicBlockedFrame blocked; | 4016 QuicBlockedFrame blocked; |
| 4019 blocked.stream_id = 3; | 4017 blocked.stream_id = 3; |
| 4020 EXPECT_CALL(visitor_, OnBlockedFrames(_)); | 4018 EXPECT_CALL(visitor_, OnBlockedFrames(_)); |
| 4021 ProcessFramePacket(QuicFrame(&blocked)); | 4019 ProcessFramePacket(QuicFrame(&blocked)); |
| 4022 EXPECT_TRUE(ack_alarm->IsSet()); | 4020 EXPECT_TRUE(ack_alarm->IsSet()); |
| 4023 } | 4021 } |
| 4024 | 4022 |
| 4025 } // namespace | 4023 } // namespace |
| 4026 } // namespace test | 4024 } // namespace test |
| 4027 } // namespace net | 4025 } // namespace net |
| OLD | NEW |