| 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/stl_util.h" | 8 #include "base/stl_util.h" |
| 8 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 9 #include "net/quic/crypto/crypto_framer.h" | 10 #include "net/quic/crypto/crypto_framer.h" |
| 10 #include "net/quic/crypto/crypto_handshake.h" | 11 #include "net/quic/crypto/crypto_handshake.h" |
| 11 #include "net/quic/crypto/crypto_utils.h" | 12 #include "net/quic/crypto/crypto_utils.h" |
| 12 #include "net/quic/crypto/null_encrypter.h" | 13 #include "net/quic/crypto/null_encrypter.h" |
| 13 #include "net/quic/crypto/quic_decrypter.h" | 14 #include "net/quic/crypto/quic_decrypter.h" |
| 14 #include "net/quic/crypto/quic_encrypter.h" | 15 #include "net/quic/crypto/quic_encrypter.h" |
| 15 #include "net/quic/quic_framer.h" | 16 #include "net/quic/quic_framer.h" |
| 16 #include "net/quic/quic_packet_creator.h" | 17 #include "net/quic/quic_packet_creator.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 const size_t frame_size = framer->GetSerializedFrameLength( | 76 const size_t frame_size = framer->GetSerializedFrameLength( |
| 76 frames[i], max_plaintext_size - packet_size, first_frame, last_frame, | 77 frames[i], max_plaintext_size - packet_size, first_frame, last_frame, |
| 77 header.is_in_fec_group, | 78 header.is_in_fec_group, |
| 78 header.public_header.sequence_number_length); | 79 header.public_header.sequence_number_length); |
| 79 DCHECK(frame_size); | 80 DCHECK(frame_size); |
| 80 packet_size += frame_size; | 81 packet_size += frame_size; |
| 81 } | 82 } |
| 82 return framer->BuildDataPacket(header, frames, packet_size); | 83 return framer->BuildDataPacket(header, frames, packet_size); |
| 83 } | 84 } |
| 84 | 85 |
| 86 uint64 SimpleRandom::RandUint64() { |
| 87 unsigned char hash[base::kSHA1Length]; |
| 88 base::SHA1HashBytes(reinterpret_cast<unsigned char*>(&seed_), sizeof(seed_), |
| 89 hash); |
| 90 memcpy(&seed_, hash, sizeof(seed_)); |
| 91 return seed_; |
| 92 } |
| 93 |
| 85 MockFramerVisitor::MockFramerVisitor() { | 94 MockFramerVisitor::MockFramerVisitor() { |
| 86 // By default, we want to accept packets. | 95 // By default, we want to accept packets. |
| 87 ON_CALL(*this, OnProtocolVersionMismatch(_)) | 96 ON_CALL(*this, OnProtocolVersionMismatch(_)) |
| 88 .WillByDefault(testing::Return(false)); | 97 .WillByDefault(testing::Return(false)); |
| 89 | 98 |
| 90 // By default, we want to accept packets. | 99 // By default, we want to accept packets. |
| 91 ON_CALL(*this, OnUnauthenticatedHeader(_)) | 100 ON_CALL(*this, OnUnauthenticatedHeader(_)) |
| 92 .WillByDefault(testing::Return(true)); | 101 .WillByDefault(testing::Return(true)); |
| 93 | 102 |
| 94 ON_CALL(*this, OnUnauthenticatedPublicHeader(_)) | 103 ON_CALL(*this, OnUnauthenticatedPublicHeader(_)) |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 } | 591 } |
| 583 | 592 |
| 584 QuicVersionVector SupportedVersions(QuicVersion version) { | 593 QuicVersionVector SupportedVersions(QuicVersion version) { |
| 585 QuicVersionVector versions; | 594 QuicVersionVector versions; |
| 586 versions.push_back(version); | 595 versions.push_back(version); |
| 587 return versions; | 596 return versions; |
| 588 } | 597 } |
| 589 | 598 |
| 590 } // namespace test | 599 } // namespace test |
| 591 } // namespace net | 600 } // namespace net |
| OLD | NEW |