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 // Common utilities for Quic tests | 5 // Common utilities for Quic tests |
6 | 6 |
7 #ifndef NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 7 #ifndef NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
8 #define NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 8 #define NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
9 | 9 |
10 #include <stddef.h> | 10 #include <stddef.h> |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 size_t packet_size); | 209 size_t packet_size); |
210 | 210 |
211 // When constructed, checks that all QUIC flags have their correct default | 211 // When constructed, checks that all QUIC flags have their correct default |
212 // values and when destructed, restores those values. | 212 // values and when destructed, restores those values. |
213 class QuicFlagSaver { | 213 class QuicFlagSaver { |
214 public: | 214 public: |
215 QuicFlagSaver(); | 215 QuicFlagSaver(); |
216 ~QuicFlagSaver(); | 216 ~QuicFlagSaver(); |
217 }; | 217 }; |
218 | 218 |
| 219 // Compute SHA-1 hash of the supplied std::string. |
| 220 std::string Sha1Hash(base::StringPiece data); |
| 221 |
219 // Simple random number generator used to compute random numbers suitable | 222 // Simple random number generator used to compute random numbers suitable |
220 // for pseudo-randomly dropping packets in tests. It works by computing | 223 // for pseudo-randomly dropping packets in tests. It works by computing |
221 // the sha1 hash of the current seed, and using the first 64 bits as | 224 // the sha1 hash of the current seed, and using the first 64 bits as |
222 // the next random number, and the next seed. | 225 // the next random number, and the next seed. |
223 class SimpleRandom : public QuicRandom { | 226 class SimpleRandom : public QuicRandom { |
224 public: | 227 public: |
225 SimpleRandom() : seed_(0) {} | 228 SimpleRandom() : seed_(0) {} |
226 ~SimpleRandom() override {} | 229 ~SimpleRandom() override {} |
227 | 230 |
228 // Returns a random number in the range [0, kuint64max]. | 231 // Returns a random number in the range [0, kuint64max]. |
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 iov->iov_base = const_cast<char*>(str.data()); | 1061 iov->iov_base = const_cast<char*>(str.data()); |
1059 iov->iov_len = static_cast<size_t>(str.size()); | 1062 iov->iov_len = static_cast<size_t>(str.size()); |
1060 QuicIOVector quic_iov(iov, 1, str.size()); | 1063 QuicIOVector quic_iov(iov, 1, str.size()); |
1061 return quic_iov; | 1064 return quic_iov; |
1062 } | 1065 } |
1063 | 1066 |
1064 } // namespace test | 1067 } // namespace test |
1065 } // namespace net | 1068 } // namespace net |
1066 | 1069 |
1067 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 1070 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
OLD | NEW |