Chromium Code Reviews| 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 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 607 QuicConnectionTest() | 607 QuicConnectionTest() |
| 608 : connection_id_(42), | 608 : connection_id_(42), |
| 609 framer_(SupportedVersions(version()), QuicTime::Zero(), false), | 609 framer_(SupportedVersions(version()), QuicTime::Zero(), false), |
| 610 peer_creator_(connection_id_, &framer_, &random_generator_), | 610 peer_creator_(connection_id_, &framer_, &random_generator_), |
| 611 send_algorithm_(new StrictMock<MockSendAlgorithm>), | 611 send_algorithm_(new StrictMock<MockSendAlgorithm>), |
| 612 loss_algorithm_(new MockLossAlgorithm()), | 612 loss_algorithm_(new MockLossAlgorithm()), |
| 613 helper_(new TestConnectionHelper(&clock_, &random_generator_)), | 613 helper_(new TestConnectionHelper(&clock_, &random_generator_)), |
| 614 writer_(new TestPacketWriter(version())), | 614 writer_(new TestPacketWriter(version())), |
| 615 connection_(connection_id_, IPEndPoint(), helper_.get(), | 615 connection_(connection_id_, IPEndPoint(), helper_.get(), |
| 616 writer_.get(), false, version()), | 616 writer_.get(), false, version()), |
| 617 visitor_(), | |
|
Ryan Hamilton
2014/07/29 19:16:50
nit: this shouldn't be required, should it?
ramant (doing other things)
2014/07/29 21:28:58
Done.
| |
| 617 frame1_(1, false, 0, MakeIOVector(data1)), | 618 frame1_(1, false, 0, MakeIOVector(data1)), |
| 618 frame2_(1, false, 3, MakeIOVector(data2)), | 619 frame2_(1, false, 3, MakeIOVector(data2)), |
| 619 sequence_number_length_(PACKET_6BYTE_SEQUENCE_NUMBER), | 620 sequence_number_length_(PACKET_6BYTE_SEQUENCE_NUMBER), |
| 620 connection_id_length_(PACKET_8BYTE_CONNECTION_ID) { | 621 connection_id_length_(PACKET_8BYTE_CONNECTION_ID) { |
| 621 connection_.set_visitor(&visitor_); | 622 connection_.set_visitor(&visitor_); |
| 622 connection_.SetSendAlgorithm(send_algorithm_); | 623 connection_.SetSendAlgorithm(send_algorithm_); |
| 623 connection_.SetLossAlgorithm(loss_algorithm_); | 624 connection_.SetLossAlgorithm(loss_algorithm_); |
| 624 framer_.set_received_entropy_calculator(&entropy_calculator_); | 625 framer_.set_received_entropy_calculator(&entropy_calculator_); |
| 625 // Simplify tests by not sending feedback unless specifically configured. | 626 // Simplify tests by not sending feedback unless specifically configured. |
| 626 SetFeedback(NULL); | 627 SetFeedback(NULL); |
| (...skipping 1487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2114 // Don't send missing packet 1. | 2115 // Don't send missing packet 1. |
| 2115 ProcessFecPacket(2, 1, true, !kEntropyFlag, NULL); | 2116 ProcessFecPacket(2, 1, true, !kEntropyFlag, NULL); |
| 2116 // Entropy flag should be false, so entropy should be 0. | 2117 // Entropy flag should be false, so entropy should be 0. |
| 2117 EXPECT_EQ(0u, QuicConnectionPeer::ReceivedEntropyHash(&connection_, 2)); | 2118 EXPECT_EQ(0u, QuicConnectionPeer::ReceivedEntropyHash(&connection_, 2)); |
| 2118 } | 2119 } |
| 2119 | 2120 |
| 2120 TEST_P(QuicConnectionTest, ReviveMissingPacketWithVaryingSeqNumLengths) { | 2121 TEST_P(QuicConnectionTest, ReviveMissingPacketWithVaryingSeqNumLengths) { |
| 2121 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2122 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2122 | 2123 |
| 2123 // Set up a debug visitor to the connection. | 2124 // Set up a debug visitor to the connection. |
| 2124 scoped_ptr<FecQuicConnectionDebugVisitor> | 2125 FecQuicConnectionDebugVisitor* fec_visitor = |
| 2125 fec_visitor(new FecQuicConnectionDebugVisitor); | 2126 new FecQuicConnectionDebugVisitor(); |
| 2126 connection_.set_debug_visitor(fec_visitor.get()); | 2127 connection_.set_debug_visitor(fec_visitor); |
| 2127 | 2128 |
| 2128 QuicPacketSequenceNumber fec_packet = 0; | 2129 QuicPacketSequenceNumber fec_packet = 0; |
| 2129 QuicSequenceNumberLength lengths[] = {PACKET_6BYTE_SEQUENCE_NUMBER, | 2130 QuicSequenceNumberLength lengths[] = {PACKET_6BYTE_SEQUENCE_NUMBER, |
| 2130 PACKET_4BYTE_SEQUENCE_NUMBER, | 2131 PACKET_4BYTE_SEQUENCE_NUMBER, |
| 2131 PACKET_2BYTE_SEQUENCE_NUMBER, | 2132 PACKET_2BYTE_SEQUENCE_NUMBER, |
| 2132 PACKET_1BYTE_SEQUENCE_NUMBER}; | 2133 PACKET_1BYTE_SEQUENCE_NUMBER}; |
| 2133 // For each sequence number length size, revive a packet and check sequence | 2134 // For each sequence number length size, revive a packet and check sequence |
| 2134 // number length in the revived packet. | 2135 // number length in the revived packet. |
| 2135 for (size_t i = 0; i < arraysize(lengths); ++i) { | 2136 for (size_t i = 0; i < arraysize(lengths); ++i) { |
| 2136 // Set sequence_number_length_ (for data and FEC packets). | 2137 // Set sequence_number_length_ (for data and FEC packets). |
| 2137 sequence_number_length_ = lengths[i]; | 2138 sequence_number_length_ = lengths[i]; |
| 2138 fec_packet += 2; | 2139 fec_packet += 2; |
| 2139 // Don't send missing packet, but send fec packet right after it. | 2140 // Don't send missing packet, but send fec packet right after it. |
| 2140 ProcessFecPacket(fec_packet, fec_packet - 1, true, !kEntropyFlag, NULL); | 2141 ProcessFecPacket(fec_packet, fec_packet - 1, true, !kEntropyFlag, NULL); |
| 2141 // Sequence number length in the revived header should be the same as | 2142 // Sequence number length in the revived header should be the same as |
| 2142 // in the original data/fec packet headers. | 2143 // in the original data/fec packet headers. |
| 2143 EXPECT_EQ(sequence_number_length_, fec_visitor->revived_header(). | 2144 EXPECT_EQ(sequence_number_length_, fec_visitor->revived_header(). |
| 2144 public_header.sequence_number_length); | 2145 public_header.sequence_number_length); |
| 2145 } | 2146 } |
| 2146 } | 2147 } |
| 2147 | 2148 |
| 2148 TEST_P(QuicConnectionTest, ReviveMissingPacketWithVaryingConnectionIdLengths) { | 2149 TEST_P(QuicConnectionTest, ReviveMissingPacketWithVaryingConnectionIdLengths) { |
| 2149 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 2150 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 2150 | 2151 |
| 2151 // Set up a debug visitor to the connection. | 2152 // Set up a debug visitor to the connection. |
| 2152 scoped_ptr<FecQuicConnectionDebugVisitor> | 2153 FecQuicConnectionDebugVisitor* fec_visitor = |
| 2153 fec_visitor(new FecQuicConnectionDebugVisitor); | 2154 new FecQuicConnectionDebugVisitor(); |
| 2154 connection_.set_debug_visitor(fec_visitor.get()); | 2155 connection_.set_debug_visitor(fec_visitor); |
| 2155 | 2156 |
| 2156 QuicPacketSequenceNumber fec_packet = 0; | 2157 QuicPacketSequenceNumber fec_packet = 0; |
| 2157 QuicConnectionIdLength lengths[] = {PACKET_8BYTE_CONNECTION_ID, | 2158 QuicConnectionIdLength lengths[] = {PACKET_8BYTE_CONNECTION_ID, |
| 2158 PACKET_4BYTE_CONNECTION_ID, | 2159 PACKET_4BYTE_CONNECTION_ID, |
| 2159 PACKET_1BYTE_CONNECTION_ID, | 2160 PACKET_1BYTE_CONNECTION_ID, |
| 2160 PACKET_0BYTE_CONNECTION_ID}; | 2161 PACKET_0BYTE_CONNECTION_ID}; |
| 2161 // For each connection id length size, revive a packet and check connection | 2162 // For each connection id length size, revive a packet and check connection |
| 2162 // id length in the revived packet. | 2163 // id length in the revived packet. |
| 2163 for (size_t i = 0; i < arraysize(lengths); ++i) { | 2164 for (size_t i = 0; i < arraysize(lengths); ++i) { |
| 2164 // Set connection id length (for data and FEC packets). | 2165 // Set connection id length (for data and FEC packets). |
| (...skipping 1776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3941 MOCK_METHOD1(OnVersionNegotiationPacket, | 3942 MOCK_METHOD1(OnVersionNegotiationPacket, |
| 3942 void(const QuicVersionNegotiationPacket&)); | 3943 void(const QuicVersionNegotiationPacket&)); |
| 3943 | 3944 |
| 3944 MOCK_METHOD2(OnRevivedPacket, | 3945 MOCK_METHOD2(OnRevivedPacket, |
| 3945 void(const QuicPacketHeader&, StringPiece payload)); | 3946 void(const QuicPacketHeader&, StringPiece payload)); |
| 3946 }; | 3947 }; |
| 3947 | 3948 |
| 3948 TEST_P(QuicConnectionTest, OnPacketHeaderDebugVisitor) { | 3949 TEST_P(QuicConnectionTest, OnPacketHeaderDebugVisitor) { |
| 3949 QuicPacketHeader header; | 3950 QuicPacketHeader header; |
| 3950 | 3951 |
| 3951 scoped_ptr<MockQuicConnectionDebugVisitor> | 3952 MockQuicConnectionDebugVisitor* debug_visitor = |
| 3952 debug_visitor(new StrictMock<MockQuicConnectionDebugVisitor>); | 3953 new MockQuicConnectionDebugVisitor(); |
| 3953 connection_.set_debug_visitor(debug_visitor.get()); | 3954 connection_.set_debug_visitor(debug_visitor); |
| 3954 EXPECT_CALL(*debug_visitor, OnPacketHeader(Ref(header))).Times(1); | 3955 EXPECT_CALL(*debug_visitor, OnPacketHeader(Ref(header))).Times(1); |
| 3955 connection_.OnPacketHeader(header); | 3956 connection_.OnPacketHeader(header); |
| 3956 } | 3957 } |
| 3957 | 3958 |
| 3958 TEST_P(QuicConnectionTest, Pacing) { | 3959 TEST_P(QuicConnectionTest, Pacing) { |
| 3959 ValueRestore<bool> old_flag(&FLAGS_enable_quic_pacing, true); | 3960 ValueRestore<bool> old_flag(&FLAGS_enable_quic_pacing, true); |
| 3960 | 3961 |
| 3961 TestConnection server(connection_id_, IPEndPoint(), helper_.get(), | 3962 TestConnection server(connection_id_, IPEndPoint(), helper_.get(), |
| 3962 writer_.get(), true, version()); | 3963 writer_.get(), true, version()); |
| 3963 TestConnection client(connection_id_, IPEndPoint(), helper_.get(), | 3964 TestConnection client(connection_id_, IPEndPoint(), helper_.get(), |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 3985 QuicBlockedFrame blocked; | 3986 QuicBlockedFrame blocked; |
| 3986 blocked.stream_id = 3; | 3987 blocked.stream_id = 3; |
| 3987 EXPECT_CALL(visitor_, OnBlockedFrames(_)); | 3988 EXPECT_CALL(visitor_, OnBlockedFrames(_)); |
| 3988 ProcessFramePacket(QuicFrame(&blocked)); | 3989 ProcessFramePacket(QuicFrame(&blocked)); |
| 3989 EXPECT_TRUE(ack_alarm->IsSet()); | 3990 EXPECT_TRUE(ack_alarm->IsSet()); |
| 3990 } | 3991 } |
| 3991 | 3992 |
| 3992 } // namespace | 3993 } // namespace |
| 3993 } // namespace test | 3994 } // namespace test |
| 3994 } // namespace net | 3995 } // namespace net |
| OLD | NEW |