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/tools/quic/quic_dispatcher.h" | 5 #include "net/tools/quic/quic_dispatcher.h" |
6 | 6 |
7 #include <ostream> | 7 #include <ostream> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 // Processes a packet. | 223 // Processes a packet. |
224 void ProcessPacket(IPEndPoint client_address, | 224 void ProcessPacket(IPEndPoint client_address, |
225 QuicConnectionId connection_id, | 225 QuicConnectionId connection_id, |
226 bool has_version_flag, | 226 bool has_version_flag, |
227 QuicVersion version, | 227 QuicVersion version, |
228 const string& data, | 228 const string& data, |
229 QuicConnectionIdLength connection_id_length, | 229 QuicConnectionIdLength connection_id_length, |
230 QuicPacketNumberLength packet_number_length, | 230 QuicPacketNumberLength packet_number_length, |
231 QuicPacketNumber packet_number) { | 231 QuicPacketNumber packet_number) { |
232 QuicVersionVector versions(SupportedVersions(version)); | 232 QuicVersionVector versions(SupportedVersions(version)); |
233 scoped_ptr<QuicEncryptedPacket> packet(ConstructEncryptedPacket( | 233 std::unique_ptr<QuicEncryptedPacket> packet(ConstructEncryptedPacket( |
234 connection_id, has_version_flag, false, false, 0, packet_number, data, | 234 connection_id, has_version_flag, false, false, 0, packet_number, data, |
235 connection_id_length, packet_number_length, &versions)); | 235 connection_id_length, packet_number_length, &versions)); |
236 scoped_ptr<QuicReceivedPacket> received_packet( | 236 std::unique_ptr<QuicReceivedPacket> received_packet( |
237 ConstructReceivedPacket(*packet, helper_.GetClock()->Now())); | 237 ConstructReceivedPacket(*packet, helper_.GetClock()->Now())); |
238 | 238 |
239 data_ = string(packet->data(), packet->length()); | 239 data_ = string(packet->data(), packet->length()); |
240 dispatcher_.ProcessPacket(server_address_, client_address, | 240 dispatcher_.ProcessPacket(server_address_, client_address, |
241 *received_packet); | 241 *received_packet); |
242 } | 242 } |
243 | 243 |
244 void ValidatePacket(const QuicEncryptedPacket& packet) { | 244 void ValidatePacket(const QuicEncryptedPacket& packet) { |
245 EXPECT_EQ(data_.length(), packet.AsStringPiece().length()); | 245 EXPECT_EQ(data_.length(), packet.AsStringPiece().length()); |
246 EXPECT_EQ(data_, packet.AsStringPiece()); | 246 EXPECT_EQ(data_, packet.AsStringPiece()); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 &session1_))); | 351 &session1_))); |
352 ProcessPacket(client_address, connection_id, true, false, "foo"); | 352 ProcessPacket(client_address, connection_id, true, false, "foo"); |
353 | 353 |
354 // Close the connection by sending public reset packet. | 354 // Close the connection by sending public reset packet. |
355 QuicPublicResetPacket packet; | 355 QuicPublicResetPacket packet; |
356 packet.public_header.connection_id = connection_id; | 356 packet.public_header.connection_id = connection_id; |
357 packet.public_header.reset_flag = true; | 357 packet.public_header.reset_flag = true; |
358 packet.public_header.version_flag = false; | 358 packet.public_header.version_flag = false; |
359 packet.rejected_packet_number = 19191; | 359 packet.rejected_packet_number = 19191; |
360 packet.nonce_proof = 132232; | 360 packet.nonce_proof = 132232; |
361 scoped_ptr<QuicEncryptedPacket> encrypted( | 361 std::unique_ptr<QuicEncryptedPacket> encrypted( |
362 QuicFramer::BuildPublicResetPacket(packet)); | 362 QuicFramer::BuildPublicResetPacket(packet)); |
363 scoped_ptr<QuicReceivedPacket> received( | 363 std::unique_ptr<QuicReceivedPacket> received( |
364 ConstructReceivedPacket(*encrypted, helper_.GetClock()->Now())); | 364 ConstructReceivedPacket(*encrypted, helper_.GetClock()->Now())); |
365 EXPECT_CALL(*session1_, OnConnectionClosed(QUIC_PUBLIC_RESET, _, | 365 EXPECT_CALL(*session1_, OnConnectionClosed(QUIC_PUBLIC_RESET, _, |
366 ConnectionCloseSource::FROM_PEER)) | 366 ConnectionCloseSource::FROM_PEER)) |
367 .Times(1) | 367 .Times(1) |
368 .WillOnce(WithoutArgs(Invoke( | 368 .WillOnce(WithoutArgs(Invoke( |
369 reinterpret_cast<MockServerConnection*>(session1_->connection()), | 369 reinterpret_cast<MockServerConnection*>(session1_->connection()), |
370 &MockServerConnection::UnregisterOnConnectionClosed))); | 370 &MockServerConnection::UnregisterOnConnectionClosed))); |
371 EXPECT_CALL(*reinterpret_cast<MockConnection*>(session1_->connection()), | 371 EXPECT_CALL(*reinterpret_cast<MockConnection*>(session1_->connection()), |
372 ProcessUdpPacket(_, _, _)) | 372 ProcessUdpPacket(_, _, _)) |
373 .WillOnce( | 373 .WillOnce( |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 | 836 |
837 // And we'll resume where we left off when we get another call. | 837 // And we'll resume where we left off when we get another call. |
838 EXPECT_CALL(*connection2(), OnCanWrite()); | 838 EXPECT_CALL(*connection2(), OnCanWrite()); |
839 dispatcher_.OnCanWrite(); | 839 dispatcher_.OnCanWrite(); |
840 EXPECT_FALSE(dispatcher_.HasPendingWrites()); | 840 EXPECT_FALSE(dispatcher_.HasPendingWrites()); |
841 } | 841 } |
842 | 842 |
843 } // namespace | 843 } // namespace |
844 } // namespace test | 844 } // namespace test |
845 } // namespace net | 845 } // namespace net |
OLD | NEW |