Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(537)

Side by Side Diff: net/quic/test_tools/quic_test_utils.cc

Issue 2322233004: Landing Recent QUIC changes until Sun Sep 4 03:41:00 (Closed)
Patch Set: Remove simulation files from the build. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/test_tools/quic_test_utils.h ('k') | net/tools/quic/chlo_extractor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } 110 }
111 111
112 uint64_t SimpleRandom::RandUint64() { 112 uint64_t SimpleRandom::RandUint64() {
113 unsigned char hash[base::kSHA1Length]; 113 unsigned char hash[base::kSHA1Length];
114 base::SHA1HashBytes(reinterpret_cast<unsigned char*>(&seed_), sizeof(seed_), 114 base::SHA1HashBytes(reinterpret_cast<unsigned char*>(&seed_), sizeof(seed_),
115 hash); 115 hash);
116 memcpy(&seed_, hash, sizeof(seed_)); 116 memcpy(&seed_, hash, sizeof(seed_));
117 return seed_; 117 return seed_;
118 } 118 }
119 119
120 void SimpleRandom::RandBytes(void* data, size_t len) {
121 uint8_t* real_data = static_cast<uint8_t*>(data);
122 for (size_t offset = 0; offset < len; offset++) {
123 real_data[offset] = RandUint64() & 0xff;
124 }
125 }
126
127 void SimpleRandom::Reseed(const void* additional_entropy, size_t len) {
128 const uint8_t* real_entropy = static_cast<const uint8_t*>(additional_entropy);
129 for (size_t offset = 0; offset < len; offset++) {
130 // Note: this is not actually a well-established way to incorporate new
131 // entropy, but good enough for tests.
132 seed_ *= real_entropy[len];
133 }
134 }
135
120 MockFramerVisitor::MockFramerVisitor() { 136 MockFramerVisitor::MockFramerVisitor() {
121 // By default, we want to accept packets. 137 // By default, we want to accept packets.
122 ON_CALL(*this, OnProtocolVersionMismatch(_)) 138 ON_CALL(*this, OnProtocolVersionMismatch(_))
123 .WillByDefault(testing::Return(false)); 139 .WillByDefault(testing::Return(false));
124 140
125 // By default, we want to accept packets. 141 // By default, we want to accept packets.
126 ON_CALL(*this, OnUnauthenticatedHeader(_)) 142 ON_CALL(*this, OnUnauthenticatedHeader(_))
127 .WillByDefault(testing::Return(true)); 143 .WillByDefault(testing::Return(true));
128 144
129 ON_CALL(*this, OnUnauthenticatedPublicHeader(_)) 145 ON_CALL(*this, OnUnauthenticatedPublicHeader(_))
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 TestQuicSpdyServerSession::~TestQuicSpdyServerSession() { 427 TestQuicSpdyServerSession::~TestQuicSpdyServerSession() {
412 delete connection(); 428 delete connection();
413 } 429 }
414 430
415 QuicCryptoServerStreamBase* 431 QuicCryptoServerStreamBase*
416 TestQuicSpdyServerSession::CreateQuicCryptoServerStream( 432 TestQuicSpdyServerSession::CreateQuicCryptoServerStream(
417 const QuicCryptoServerConfig* crypto_config, 433 const QuicCryptoServerConfig* crypto_config,
418 QuicCompressedCertsCache* compressed_certs_cache) { 434 QuicCompressedCertsCache* compressed_certs_cache) {
419 return new QuicCryptoServerStream(crypto_config, compressed_certs_cache, 435 return new QuicCryptoServerStream(crypto_config, compressed_certs_cache,
420 FLAGS_enable_quic_stateless_reject_support, 436 FLAGS_enable_quic_stateless_reject_support,
421 this); 437 this, &helper_);
422 } 438 }
423 439
424 QuicCryptoServerStream* TestQuicSpdyServerSession::GetCryptoStream() { 440 QuicCryptoServerStream* TestQuicSpdyServerSession::GetCryptoStream() {
425 return static_cast<QuicCryptoServerStream*>( 441 return static_cast<QuicCryptoServerStream*>(
426 QuicServerSessionBase::GetCryptoStream()); 442 QuicServerSessionBase::GetCryptoStream());
427 } 443 }
428 444
429 TestQuicSpdyClientSession::TestQuicSpdyClientSession( 445 TestQuicSpdyClientSession::TestQuicSpdyClientSession(
430 QuicConnection* connection, 446 QuicConnection* connection,
431 const QuicConfig& config, 447 const QuicConfig& config,
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 // strike register worries that we've just overflowed a uint32_t time. 928 // strike register worries that we've just overflowed a uint32_t time.
913 (*server_connection)->AdvanceTime(connection_start_time); 929 (*server_connection)->AdvanceTime(connection_start_time);
914 } 930 }
915 931
916 QuicStreamId QuicClientDataStreamId(int i) { 932 QuicStreamId QuicClientDataStreamId(int i) {
917 return kClientDataStreamId1 + 2 * i; 933 return kClientDataStreamId1 + 2 * i;
918 } 934 }
919 935
920 } // namespace test 936 } // namespace test
921 } // namespace net 937 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/quic_test_utils.h ('k') | net/tools/quic/chlo_extractor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698