OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/tools/quic/quic_time_wait_list_manager.h" | 5 #include "net/tools/quic/quic_time_wait_list_manager.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 | 8 |
9 #include "net/quic/crypto/crypto_protocol.h" | 9 #include "net/quic/crypto/crypto_protocol.h" |
10 #include "net/quic/crypto/null_encrypter.h" | 10 #include "net/quic/crypto/null_encrypter.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 using testing::Truly; | 38 using testing::Truly; |
39 using testing::_; | 39 using testing::_; |
40 | 40 |
41 namespace net { | 41 namespace net { |
42 namespace tools { | 42 namespace tools { |
43 namespace test { | 43 namespace test { |
44 | 44 |
45 class FramerVisitorCapturingPublicReset : public NoOpFramerVisitor { | 45 class FramerVisitorCapturingPublicReset : public NoOpFramerVisitor { |
46 public: | 46 public: |
47 FramerVisitorCapturingPublicReset() {} | 47 FramerVisitorCapturingPublicReset() {} |
48 virtual ~FramerVisitorCapturingPublicReset() {} | 48 virtual ~FramerVisitorCapturingPublicReset() OVERRIDE {} |
49 | 49 |
50 virtual void OnPublicResetPacket( | 50 virtual void OnPublicResetPacket( |
51 const QuicPublicResetPacket& public_reset) OVERRIDE { | 51 const QuicPublicResetPacket& public_reset) OVERRIDE { |
52 public_reset_packet_ = public_reset; | 52 public_reset_packet_ = public_reset; |
53 } | 53 } |
54 | 54 |
55 const QuicPublicResetPacket public_reset_packet() { | 55 const QuicPublicResetPacket public_reset_packet() { |
56 return public_reset_packet_; | 56 return public_reset_packet_; |
57 } | 57 } |
58 | 58 |
(...skipping 30 matching lines...) Expand all Loading... |
89 class QuicTimeWaitListManagerTest : public ::testing::Test { | 89 class QuicTimeWaitListManagerTest : public ::testing::Test { |
90 protected: | 90 protected: |
91 QuicTimeWaitListManagerTest() | 91 QuicTimeWaitListManagerTest() |
92 : time_wait_list_manager_(&writer_, &visitor_, | 92 : time_wait_list_manager_(&writer_, &visitor_, |
93 &epoll_server_, QuicSupportedVersions()), | 93 &epoll_server_, QuicSupportedVersions()), |
94 framer_(QuicSupportedVersions(), QuicTime::Zero(), true), | 94 framer_(QuicSupportedVersions(), QuicTime::Zero(), true), |
95 connection_id_(45), | 95 connection_id_(45), |
96 client_address_(net::test::TestPeerIPAddress(), kTestPort), | 96 client_address_(net::test::TestPeerIPAddress(), kTestPort), |
97 writer_is_blocked_(false) {} | 97 writer_is_blocked_(false) {} |
98 | 98 |
99 virtual ~QuicTimeWaitListManagerTest() {} | 99 virtual ~QuicTimeWaitListManagerTest() OVERRIDE {} |
100 | 100 |
101 virtual void SetUp() { | 101 virtual void SetUp() OVERRIDE { |
102 EXPECT_CALL(writer_, IsWriteBlocked()) | 102 EXPECT_CALL(writer_, IsWriteBlocked()) |
103 .WillRepeatedly(ReturnPointee(&writer_is_blocked_)); | 103 .WillRepeatedly(ReturnPointee(&writer_is_blocked_)); |
104 EXPECT_CALL(writer_, IsWriteBlockedDataBuffered()) | 104 EXPECT_CALL(writer_, IsWriteBlockedDataBuffered()) |
105 .WillRepeatedly(Return(false)); | 105 .WillRepeatedly(Return(false)); |
106 } | 106 } |
107 | 107 |
108 void AddConnectionId(QuicConnectionId connection_id) { | 108 void AddConnectionId(QuicConnectionId connection_id) { |
109 AddConnectionId(connection_id, QuicVersionMax(), NULL); | 109 AddConnectionId(connection_id, QuicVersionMax(), NULL); |
110 } | 110 } |
111 | 111 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 class ValidatePublicResetPacketPredicate | 174 class ValidatePublicResetPacketPredicate |
175 : public MatcherInterface<const std::tr1::tuple<const char*, int> > { | 175 : public MatcherInterface<const std::tr1::tuple<const char*, int> > { |
176 public: | 176 public: |
177 explicit ValidatePublicResetPacketPredicate(QuicConnectionId connection_id, | 177 explicit ValidatePublicResetPacketPredicate(QuicConnectionId connection_id, |
178 QuicPacketSequenceNumber number) | 178 QuicPacketSequenceNumber number) |
179 : connection_id_(connection_id), sequence_number_(number) { | 179 : connection_id_(connection_id), sequence_number_(number) { |
180 } | 180 } |
181 | 181 |
182 virtual bool MatchAndExplain( | 182 virtual bool MatchAndExplain( |
183 const std::tr1::tuple<const char*, int> packet_buffer, | 183 const std::tr1::tuple<const char*, int> packet_buffer, |
184 testing::MatchResultListener* /* listener */) const { | 184 testing::MatchResultListener* /* listener */) const OVERRIDE { |
185 FramerVisitorCapturingPublicReset visitor; | 185 FramerVisitorCapturingPublicReset visitor; |
186 QuicFramer framer(QuicSupportedVersions(), | 186 QuicFramer framer(QuicSupportedVersions(), |
187 QuicTime::Zero(), | 187 QuicTime::Zero(), |
188 false); | 188 false); |
189 framer.set_visitor(&visitor); | 189 framer.set_visitor(&visitor); |
190 QuicEncryptedPacket encrypted(std::tr1::get<0>(packet_buffer), | 190 QuicEncryptedPacket encrypted(std::tr1::get<0>(packet_buffer), |
191 std::tr1::get<1>(packet_buffer)); | 191 std::tr1::get<1>(packet_buffer)); |
192 framer.ProcessPacket(encrypted); | 192 framer.ProcessPacket(encrypted); |
193 QuicPublicResetPacket packet = visitor.public_reset_packet(); | 193 QuicPublicResetPacket packet = visitor.public_reset_packet(); |
194 return connection_id_ == packet.public_header.connection_id && | 194 return connection_id_ == packet.public_header.connection_id && |
195 packet.public_header.reset_flag && !packet.public_header.version_flag && | 195 packet.public_header.reset_flag && !packet.public_header.version_flag && |
196 sequence_number_ == packet.rejected_sequence_number && | 196 sequence_number_ == packet.rejected_sequence_number && |
197 net::test::TestPeerIPAddress() == packet.client_address.address() && | 197 net::test::TestPeerIPAddress() == packet.client_address.address() && |
198 kTestPort == packet.client_address.port(); | 198 kTestPort == packet.client_address.port(); |
199 } | 199 } |
200 | 200 |
201 virtual void DescribeTo(::std::ostream* os) const { } | 201 virtual void DescribeTo(::std::ostream* os) const OVERRIDE {} |
202 | 202 |
203 virtual void DescribeNegationTo(::std::ostream* os) const { } | 203 virtual void DescribeNegationTo(::std::ostream* os) const OVERRIDE {} |
204 | 204 |
205 private: | 205 private: |
206 QuicConnectionId connection_id_; | 206 QuicConnectionId connection_id_; |
207 QuicPacketSequenceNumber sequence_number_; | 207 QuicPacketSequenceNumber sequence_number_; |
208 }; | 208 }; |
209 | 209 |
210 | 210 |
211 Matcher<const std::tr1::tuple<const char*, int> > PublicResetPacketEq( | 211 Matcher<const std::tr1::tuple<const char*, int> > PublicResetPacketEq( |
212 QuicConnectionId connection_id, | 212 QuicConnectionId connection_id, |
213 QuicPacketSequenceNumber sequence_number) { | 213 QuicPacketSequenceNumber sequence_number) { |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 EXPECT_CALL(epoll_server_, RegisterAlarm(_, _)); | 452 EXPECT_CALL(epoll_server_, RegisterAlarm(_, _)); |
453 | 453 |
454 time_wait_list_manager_.CleanUpOldConnectionIds(); | 454 time_wait_list_manager_.CleanUpOldConnectionIds(); |
455 EXPECT_FALSE(IsConnectionIdInTimeWait(kConnectionId1)); | 455 EXPECT_FALSE(IsConnectionIdInTimeWait(kConnectionId1)); |
456 EXPECT_TRUE(IsConnectionIdInTimeWait(kConnectionId2)); | 456 EXPECT_TRUE(IsConnectionIdInTimeWait(kConnectionId2)); |
457 } | 457 } |
458 } // namespace | 458 } // namespace |
459 } // namespace test | 459 } // namespace test |
460 } // namespace tools | 460 } // namespace tools |
461 } // namespace net | 461 } // namespace net |
OLD | NEW |