| 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/sha1.h" | 9 #include "base/sha1.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 } | 343 } |
| 344 | 344 |
| 345 MockQuicSession::MockQuicSession(QuicConnection* connection) | 345 MockQuicSession::MockQuicSession(QuicConnection* connection) |
| 346 : QuicSession(connection, DefaultQuicConfig()) { | 346 : QuicSession(connection, DefaultQuicConfig()) { |
| 347 crypto_stream_.reset(new QuicCryptoStream(this)); | 347 crypto_stream_.reset(new QuicCryptoStream(this)); |
| 348 Initialize(); | 348 Initialize(); |
| 349 ON_CALL(*this, WritevData(_, _, _, _, _, _)) | 349 ON_CALL(*this, WritevData(_, _, _, _, _, _)) |
| 350 .WillByDefault(testing::Return(QuicConsumedData(0, false))); | 350 .WillByDefault(testing::Return(QuicConsumedData(0, false))); |
| 351 } | 351 } |
| 352 | 352 |
| 353 MockQuicSession::~MockQuicSession() {} | 353 MockQuicSession::~MockQuicSession() { |
| 354 delete connection(); |
| 355 } |
| 354 | 356 |
| 355 // static | 357 // static |
| 356 QuicConsumedData MockQuicSession::ConsumeAllData( | 358 QuicConsumedData MockQuicSession::ConsumeAllData( |
| 357 ReliableQuicStream* /*stream*/, | 359 ReliableQuicStream* /*stream*/, |
| 358 QuicStreamId /*id*/, | 360 QuicStreamId /*id*/, |
| 359 const QuicIOVector& data, | 361 const QuicIOVector& data, |
| 360 QuicStreamOffset /*offset*/, | 362 QuicStreamOffset /*offset*/, |
| 361 bool fin, | 363 bool fin, |
| 362 QuicAckListenerInterface* /*ack_notifier_delegate*/) { | 364 QuicAckListenerInterface* /*ack_notifier_delegate*/) { |
| 363 return QuicConsumedData(data.total_length, fin); | 365 return QuicConsumedData(data.total_length, fin); |
| 364 } | 366 } |
| 365 | 367 |
| 366 MockQuicSpdySession::MockQuicSpdySession(QuicConnection* connection) | 368 MockQuicSpdySession::MockQuicSpdySession(QuicConnection* connection) |
| 367 : QuicSpdySession(connection, DefaultQuicConfig()) { | 369 : QuicSpdySession(connection, DefaultQuicConfig()) { |
| 368 crypto_stream_.reset(new QuicCryptoStream(this)); | 370 crypto_stream_.reset(new QuicCryptoStream(this)); |
| 369 Initialize(); | 371 Initialize(); |
| 370 ON_CALL(*this, WritevData(_, _, _, _, _, _)) | 372 ON_CALL(*this, WritevData(_, _, _, _, _, _)) |
| 371 .WillByDefault(testing::Return(QuicConsumedData(0, false))); | 373 .WillByDefault(testing::Return(QuicConsumedData(0, false))); |
| 372 } | 374 } |
| 373 | 375 |
| 374 MockQuicSpdySession::~MockQuicSpdySession() {} | 376 MockQuicSpdySession::~MockQuicSpdySession() { |
| 377 delete connection(); |
| 378 } |
| 375 | 379 |
| 376 TestQuicSpdyServerSession::TestQuicSpdyServerSession( | 380 TestQuicSpdyServerSession::TestQuicSpdyServerSession( |
| 377 QuicConnection* connection, | 381 QuicConnection* connection, |
| 378 const QuicConfig& config, | 382 const QuicConfig& config, |
| 379 const QuicCryptoServerConfig* crypto_config, | 383 const QuicCryptoServerConfig* crypto_config, |
| 380 QuicCompressedCertsCache* compressed_certs_cache) | 384 QuicCompressedCertsCache* compressed_certs_cache) |
| 381 : QuicServerSessionBase(config, | 385 : QuicServerSessionBase(config, |
| 382 connection, | 386 connection, |
| 383 &visitor_, | 387 &visitor_, |
| 384 &helper_, | 388 &helper_, |
| 385 crypto_config, | 389 crypto_config, |
| 386 compressed_certs_cache) { | 390 compressed_certs_cache) { |
| 387 Initialize(); | 391 Initialize(); |
| 388 ON_CALL(helper_, GenerateConnectionIdForReject(_)) | 392 ON_CALL(helper_, GenerateConnectionIdForReject(_)) |
| 389 .WillByDefault( | 393 .WillByDefault( |
| 390 testing::Return(connection->random_generator()->RandUint64())); | 394 testing::Return(connection->random_generator()->RandUint64())); |
| 391 ON_CALL(helper_, CanAcceptClientHello(_, _, _)) | 395 ON_CALL(helper_, CanAcceptClientHello(_, _, _)) |
| 392 .WillByDefault(testing::Return(true)); | 396 .WillByDefault(testing::Return(true)); |
| 393 } | 397 } |
| 394 | 398 |
| 395 TestQuicSpdyServerSession::~TestQuicSpdyServerSession() {} | 399 TestQuicSpdyServerSession::~TestQuicSpdyServerSession() { |
| 400 delete connection(); |
| 401 } |
| 396 | 402 |
| 397 QuicCryptoServerStreamBase* | 403 QuicCryptoServerStreamBase* |
| 398 TestQuicSpdyServerSession::CreateQuicCryptoServerStream( | 404 TestQuicSpdyServerSession::CreateQuicCryptoServerStream( |
| 399 const QuicCryptoServerConfig* crypto_config, | 405 const QuicCryptoServerConfig* crypto_config, |
| 400 QuicCompressedCertsCache* compressed_certs_cache) { | 406 QuicCompressedCertsCache* compressed_certs_cache) { |
| 401 return new QuicCryptoServerStream(crypto_config, compressed_certs_cache, | 407 return new QuicCryptoServerStream(crypto_config, compressed_certs_cache, |
| 402 FLAGS_enable_quic_stateless_reject_support, | 408 FLAGS_enable_quic_stateless_reject_support, |
| 403 this); | 409 this); |
| 404 } | 410 } |
| 405 | 411 |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 893 // strike register worries that we've just overflowed a uint32_t time. | 899 // strike register worries that we've just overflowed a uint32_t time. |
| 894 (*server_connection)->AdvanceTime(connection_start_time); | 900 (*server_connection)->AdvanceTime(connection_start_time); |
| 895 } | 901 } |
| 896 | 902 |
| 897 QuicStreamId QuicClientDataStreamId(int i) { | 903 QuicStreamId QuicClientDataStreamId(int i) { |
| 898 return kClientDataStreamId1 + 2 * i; | 904 return kClientDataStreamId1 + 2 * i; |
| 899 } | 905 } |
| 900 | 906 |
| 901 } // namespace test | 907 } // namespace test |
| 902 } // namespace net | 908 } // namespace net |
| OLD | NEW |