| 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/test_tools/quic_test_utils.h" | 5 #include "net/quic/test_tools/quic_test_utils.h" |
| 6 | 6 |
| 7 #include "base/sha1.h" | 7 #include "base/sha1.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "net/quic/crypto/crypto_framer.h" | 10 #include "net/quic/crypto/crypto_framer.h" |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 packet.serialized_packet.packet = packet.serialized_packet.packet->Clone(); | 331 packet.serialized_packet.packet = packet.serialized_packet.packet->Clone(); |
| 332 } | 332 } |
| 333 encrypted_packets_.push_back(packet.serialized_packet.packet); | 333 encrypted_packets_.push_back(packet.serialized_packet.packet); |
| 334 // Transfer ownership of the packet to the SentPacketManager and the | 334 // Transfer ownership of the packet to the SentPacketManager and the |
| 335 // ack notifier to the AckNotifierManager. | 335 // ack notifier to the AckNotifierManager. |
| 336 sent_packet_manager_.OnPacketSent( | 336 sent_packet_manager_.OnPacketSent( |
| 337 &packet.serialized_packet, 0, QuicTime::Zero(), 1000, | 337 &packet.serialized_packet, 0, QuicTime::Zero(), 1000, |
| 338 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA); | 338 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA); |
| 339 } | 339 } |
| 340 | 340 |
| 341 MockSession::MockSession(QuicConnection* connection) | 341 MockQuicSpdySession::MockQuicSpdySession(QuicConnection* connection) |
| 342 : QuicSession(connection, DefaultQuicConfig()) { | 342 : QuicSpdySession(connection, DefaultQuicConfig()) { |
| 343 crypto_stream_.reset(new QuicCryptoStream(this)); | 343 crypto_stream_.reset(new QuicCryptoStream(this)); |
| 344 Initialize(); | 344 Initialize(); |
| 345 ON_CALL(*this, WritevData(_, _, _, _, _, _)) | 345 ON_CALL(*this, WritevData(_, _, _, _, _, _)) |
| 346 .WillByDefault(testing::Return(QuicConsumedData(0, false))); | 346 .WillByDefault(testing::Return(QuicConsumedData(0, false))); |
| 347 } | 347 } |
| 348 | 348 |
| 349 MockSession::~MockSession() { | 349 MockQuicSpdySession::~MockQuicSpdySession() { |
| 350 } | 350 } |
| 351 | 351 |
| 352 TestServerSession::TestServerSession( | 352 TestQuicSpdyServerSession::TestQuicSpdyServerSession( |
| 353 QuicConnection* connection, | 353 QuicConnection* connection, |
| 354 const QuicConfig& config, | 354 const QuicConfig& config, |
| 355 const QuicCryptoServerConfig* crypto_config) | 355 const QuicCryptoServerConfig* crypto_config) |
| 356 : QuicSession(connection, config) { | 356 : QuicSpdySession(connection, config) { |
| 357 crypto_stream_.reset(new QuicCryptoServerStream(crypto_config, this)); | 357 crypto_stream_.reset(new QuicCryptoServerStream(crypto_config, this)); |
| 358 Initialize(); | 358 Initialize(); |
| 359 } | 359 } |
| 360 | 360 |
| 361 TestServerSession::~TestServerSession() { | 361 TestQuicSpdyServerSession::~TestQuicSpdyServerSession() { |
| 362 } | 362 } |
| 363 | 363 |
| 364 QuicCryptoServerStream* TestServerSession::GetCryptoStream() { | 364 QuicCryptoServerStream* TestQuicSpdyServerSession::GetCryptoStream() { |
| 365 return crypto_stream_.get(); | 365 return crypto_stream_.get(); |
| 366 } | 366 } |
| 367 | 367 |
| 368 TestClientSession::TestClientSession(QuicConnection* connection, | 368 TestQuicSpdyClientSession::TestQuicSpdyClientSession( |
| 369 const QuicConfig& config, | 369 QuicConnection* connection, |
| 370 const QuicServerId& server_id, | 370 const QuicConfig& config, |
| 371 QuicCryptoClientConfig* crypto_config) | 371 const QuicServerId& server_id, |
| 372 QuicCryptoClientConfig* crypto_config) |
| 372 : QuicClientSessionBase(connection, config) { | 373 : QuicClientSessionBase(connection, config) { |
| 373 crypto_stream_.reset(new QuicCryptoClientStream( | 374 crypto_stream_.reset(new QuicCryptoClientStream( |
| 374 server_id, this, CryptoTestUtils::ProofVerifyContextForTesting(), | 375 server_id, this, CryptoTestUtils::ProofVerifyContextForTesting(), |
| 375 crypto_config)); | 376 crypto_config)); |
| 376 Initialize(); | 377 Initialize(); |
| 377 } | 378 } |
| 378 | 379 |
| 379 TestClientSession::~TestClientSession() {} | 380 TestQuicSpdyClientSession::~TestQuicSpdyClientSession() { |
| 381 } |
| 380 | 382 |
| 381 QuicCryptoClientStream* TestClientSession::GetCryptoStream() { | 383 QuicCryptoClientStream* TestQuicSpdyClientSession::GetCryptoStream() { |
| 382 return crypto_stream_.get(); | 384 return crypto_stream_.get(); |
| 383 } | 385 } |
| 384 | 386 |
| 385 MockPacketWriter::MockPacketWriter() { | 387 MockPacketWriter::MockPacketWriter() { |
| 386 } | 388 } |
| 387 | 389 |
| 388 MockPacketWriter::~MockPacketWriter() { | 390 MockPacketWriter::~MockPacketWriter() { |
| 389 } | 391 } |
| 390 | 392 |
| 391 MockSendAlgorithm::MockSendAlgorithm() { | 393 MockSendAlgorithm::MockSendAlgorithm() { |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 } | 788 } |
| 787 | 789 |
| 788 MockQuicConnectionDebugVisitor::~MockQuicConnectionDebugVisitor() { | 790 MockQuicConnectionDebugVisitor::~MockQuicConnectionDebugVisitor() { |
| 789 } | 791 } |
| 790 | 792 |
| 791 void CreateClientSessionForTest(QuicServerId server_id, | 793 void CreateClientSessionForTest(QuicServerId server_id, |
| 792 bool supports_stateless_rejects, | 794 bool supports_stateless_rejects, |
| 793 QuicTime::Delta connection_start_time, | 795 QuicTime::Delta connection_start_time, |
| 794 QuicCryptoClientConfig* crypto_client_config, | 796 QuicCryptoClientConfig* crypto_client_config, |
| 795 PacketSavingConnection** client_connection, | 797 PacketSavingConnection** client_connection, |
| 796 TestClientSession** client_session) { | 798 TestQuicSpdyClientSession** client_session) { |
| 797 CHECK(crypto_client_config); | 799 CHECK(crypto_client_config); |
| 798 CHECK(client_connection); | 800 CHECK(client_connection); |
| 799 CHECK(client_session); | 801 CHECK(client_session); |
| 800 CHECK(!connection_start_time.IsZero()) | 802 CHECK(!connection_start_time.IsZero()) |
| 801 << "Connections must start at non-zero times, otherwise the " | 803 << "Connections must start at non-zero times, otherwise the " |
| 802 << "strike-register will be unhappy."; | 804 << "strike-register will be unhappy."; |
| 803 | 805 |
| 804 QuicConfig config = supports_stateless_rejects | 806 QuicConfig config = supports_stateless_rejects |
| 805 ? DefaultQuicConfigStatelessRejects() | 807 ? DefaultQuicConfigStatelessRejects() |
| 806 : DefaultQuicConfig(); | 808 : DefaultQuicConfig(); |
| 807 *client_connection = new PacketSavingConnection(Perspective::IS_CLIENT); | 809 *client_connection = new PacketSavingConnection(Perspective::IS_CLIENT); |
| 808 *client_session = new TestClientSession(*client_connection, config, server_id, | 810 *client_session = new TestQuicSpdyClientSession( |
| 809 crypto_client_config); | 811 *client_connection, config, server_id, crypto_client_config); |
| 810 (*client_connection)->AdvanceTime(connection_start_time); | 812 (*client_connection)->AdvanceTime(connection_start_time); |
| 811 } | 813 } |
| 812 | 814 |
| 813 void CreateServerSessionForTest(QuicServerId server_id, | 815 void CreateServerSessionForTest(QuicServerId server_id, |
| 814 QuicTime::Delta connection_start_time, | 816 QuicTime::Delta connection_start_time, |
| 815 QuicCryptoServerConfig* server_crypto_config, | 817 QuicCryptoServerConfig* server_crypto_config, |
| 816 PacketSavingConnection** server_connection, | 818 PacketSavingConnection** server_connection, |
| 817 TestServerSession** server_session) { | 819 TestQuicSpdyServerSession** server_session) { |
| 818 CHECK(server_crypto_config); | 820 CHECK(server_crypto_config); |
| 819 CHECK(server_connection); | 821 CHECK(server_connection); |
| 820 CHECK(server_session); | 822 CHECK(server_session); |
| 821 CHECK(!connection_start_time.IsZero()) | 823 CHECK(!connection_start_time.IsZero()) |
| 822 << "Connections must start at non-zero times, otherwise the " | 824 << "Connections must start at non-zero times, otherwise the " |
| 823 << "strike-register will be unhappy."; | 825 << "strike-register will be unhappy."; |
| 824 | 826 |
| 825 *server_connection = new PacketSavingConnection(Perspective::IS_SERVER); | 827 *server_connection = new PacketSavingConnection(Perspective::IS_SERVER); |
| 826 *server_session = new TestServerSession( | 828 *server_session = new TestQuicSpdyServerSession( |
| 827 *server_connection, DefaultQuicConfig(), server_crypto_config); | 829 *server_connection, DefaultQuicConfig(), server_crypto_config); |
| 828 | 830 |
| 829 // We advance the clock initially because the default time is zero and the | 831 // We advance the clock initially because the default time is zero and the |
| 830 // strike register worries that we've just overflowed a uint32 time. | 832 // strike register worries that we've just overflowed a uint32 time. |
| 831 (*server_connection)->AdvanceTime(connection_start_time); | 833 (*server_connection)->AdvanceTime(connection_start_time); |
| 832 } | 834 } |
| 833 | 835 |
| 834 } // namespace test | 836 } // namespace test |
| 835 } // namespace net | 837 } // namespace net |
| OLD | NEW |