| 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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 const QuicIOVector& data, | 321 const QuicIOVector& data, |
| 322 QuicStreamOffset /*offset*/, | 322 QuicStreamOffset /*offset*/, |
| 323 bool fin, | 323 bool fin, |
| 324 QuicAckListenerInterface* /*ack_notifier_delegate*/) { | 324 QuicAckListenerInterface* /*ack_notifier_delegate*/) { |
| 325 return QuicConsumedData(data.total_length, fin); | 325 return QuicConsumedData(data.total_length, fin); |
| 326 } | 326 } |
| 327 | 327 |
| 328 TestQuicSpdyServerSession::TestQuicSpdyServerSession( | 328 TestQuicSpdyServerSession::TestQuicSpdyServerSession( |
| 329 QuicConnection* connection, | 329 QuicConnection* connection, |
| 330 const QuicConfig& config, | 330 const QuicConfig& config, |
| 331 const QuicCryptoServerConfig* crypto_config) | 331 const QuicCryptoServerConfig* crypto_config, |
| 332 : QuicServerSessionBase(config, connection, &visitor_, crypto_config) { | 332 QuicCompressedCertsCache* compressed_certs_cache) |
| 333 : QuicServerSessionBase(config, |
| 334 connection, |
| 335 &visitor_, |
| 336 crypto_config, |
| 337 compressed_certs_cache) { |
| 333 Initialize(); | 338 Initialize(); |
| 334 } | 339 } |
| 335 | 340 |
| 336 TestQuicSpdyServerSession::~TestQuicSpdyServerSession() {} | 341 TestQuicSpdyServerSession::~TestQuicSpdyServerSession() {} |
| 337 | 342 |
| 338 QuicCryptoServerStreamBase* | 343 QuicCryptoServerStreamBase* |
| 339 TestQuicSpdyServerSession::CreateQuicCryptoServerStream( | 344 TestQuicSpdyServerSession::CreateQuicCryptoServerStream( |
| 340 const QuicCryptoServerConfig* crypto_config) { | 345 const QuicCryptoServerConfig* crypto_config) { |
| 341 return new QuicCryptoServerStream( | 346 return new QuicCryptoServerStream( |
| 342 crypto_config, FLAGS_enable_quic_stateless_reject_support, this); | 347 crypto_config, FLAGS_enable_quic_stateless_reject_support, this); |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 QuicConfig config = supports_stateless_rejects | 762 QuicConfig config = supports_stateless_rejects |
| 758 ? DefaultQuicConfigStatelessRejects() | 763 ? DefaultQuicConfigStatelessRejects() |
| 759 : DefaultQuicConfig(); | 764 : DefaultQuicConfig(); |
| 760 *client_connection = new PacketSavingConnection( | 765 *client_connection = new PacketSavingConnection( |
| 761 helper, Perspective::IS_CLIENT, supported_versions); | 766 helper, Perspective::IS_CLIENT, supported_versions); |
| 762 *client_session = new TestQuicSpdyClientSession( | 767 *client_session = new TestQuicSpdyClientSession( |
| 763 *client_connection, config, server_id, crypto_client_config); | 768 *client_connection, config, server_id, crypto_client_config); |
| 764 (*client_connection)->AdvanceTime(connection_start_time); | 769 (*client_connection)->AdvanceTime(connection_start_time); |
| 765 } | 770 } |
| 766 | 771 |
| 767 void CreateServerSessionForTest(QuicServerId server_id, | 772 void CreateServerSessionForTest( |
| 768 QuicTime::Delta connection_start_time, | 773 QuicServerId server_id, |
| 769 QuicVersionVector supported_versions, | 774 QuicTime::Delta connection_start_time, |
| 770 MockConnectionHelper* helper, | 775 QuicVersionVector supported_versions, |
| 771 QuicCryptoServerConfig* server_crypto_config, | 776 MockConnectionHelper* helper, |
| 772 PacketSavingConnection** server_connection, | 777 QuicCryptoServerConfig* server_crypto_config, |
| 773 TestQuicSpdyServerSession** server_session) { | 778 QuicCompressedCertsCache* compressed_certs_cache, |
| 779 PacketSavingConnection** server_connection, |
| 780 TestQuicSpdyServerSession** server_session) { |
| 774 CHECK(server_crypto_config); | 781 CHECK(server_crypto_config); |
| 775 CHECK(server_connection); | 782 CHECK(server_connection); |
| 776 CHECK(server_session); | 783 CHECK(server_session); |
| 777 CHECK(!connection_start_time.IsZero()) | 784 CHECK(!connection_start_time.IsZero()) |
| 778 << "Connections must start at non-zero times, otherwise the " | 785 << "Connections must start at non-zero times, otherwise the " |
| 779 << "strike-register will be unhappy."; | 786 << "strike-register will be unhappy."; |
| 780 | 787 |
| 781 *server_connection = new PacketSavingConnection( | 788 *server_connection = new PacketSavingConnection( |
| 782 helper, Perspective::IS_SERVER, supported_versions); | 789 helper, Perspective::IS_SERVER, supported_versions); |
| 783 *server_session = new TestQuicSpdyServerSession( | 790 *server_session = new TestQuicSpdyServerSession( |
| 784 *server_connection, DefaultQuicConfig(), server_crypto_config); | 791 *server_connection, DefaultQuicConfig(), server_crypto_config, |
| 792 compressed_certs_cache); |
| 785 | 793 |
| 786 // We advance the clock initially because the default time is zero and the | 794 // We advance the clock initially because the default time is zero and the |
| 787 // strike register worries that we've just overflowed a uint32_t time. | 795 // strike register worries that we've just overflowed a uint32_t time. |
| 788 (*server_connection)->AdvanceTime(connection_start_time); | 796 (*server_connection)->AdvanceTime(connection_start_time); |
| 789 } | 797 } |
| 790 | 798 |
| 791 QuicStreamId QuicClientDataStreamId(int i) { | 799 QuicStreamId QuicClientDataStreamId(int i) { |
| 792 return kClientDataStreamId1 + 2 * i; | 800 return kClientDataStreamId1 + 2 * i; |
| 793 } | 801 } |
| 794 | 802 |
| 795 } // namespace test | 803 } // namespace test |
| 796 } // namespace net | 804 } // namespace net |
| OLD | NEW |