| 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 <cstdint> | 10 #include <cstdint> |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 // values and when destructed, restores those values. | 183 // values and when destructed, restores those values. |
| 184 class QuicFlagSaver { | 184 class QuicFlagSaver { |
| 185 public: | 185 public: |
| 186 QuicFlagSaver(); | 186 QuicFlagSaver(); |
| 187 ~QuicFlagSaver(); | 187 ~QuicFlagSaver(); |
| 188 }; | 188 }; |
| 189 | 189 |
| 190 // Compute SHA-1 hash of the supplied std::string. | 190 // Compute SHA-1 hash of the supplied std::string. |
| 191 std::string Sha1Hash(QuicStringPiece data); | 191 std::string Sha1Hash(QuicStringPiece data); |
| 192 | 192 |
| 193 // Given endpoint in memory |connection_id|, returns peer's in memory connection |
| 194 // id. |
| 195 QuicConnectionId GetPeerInMemoryConnectionId(QuicConnectionId connection_id); |
| 196 |
| 193 // Simple random number generator used to compute random numbers suitable | 197 // Simple random number generator used to compute random numbers suitable |
| 194 // for pseudo-randomly dropping packets in tests. It works by computing | 198 // for pseudo-randomly dropping packets in tests. It works by computing |
| 195 // the sha1 hash of the current seed, and using the first 64 bits as | 199 // the sha1 hash of the current seed, and using the first 64 bits as |
| 196 // the next random number, and the next seed. | 200 // the next random number, and the next seed. |
| 197 class SimpleRandom : public QuicRandom { | 201 class SimpleRandom : public QuicRandom { |
| 198 public: | 202 public: |
| 199 SimpleRandom() : seed_(0) {} | 203 SimpleRandom() : seed_(0) {} |
| 200 ~SimpleRandom() override {} | 204 ~SimpleRandom() override {} |
| 201 | 205 |
| 202 // Returns a random number in the range [0, kuint64max]. | 206 // Returns a random number in the range [0, kuint64max]. |
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 iov->iov_base = const_cast<char*>(str.data()); | 981 iov->iov_base = const_cast<char*>(str.data()); |
| 978 iov->iov_len = static_cast<size_t>(str.size()); | 982 iov->iov_len = static_cast<size_t>(str.size()); |
| 979 QuicIOVector quic_iov(iov, 1, str.size()); | 983 QuicIOVector quic_iov(iov, 1, str.size()); |
| 980 return quic_iov; | 984 return quic_iov; |
| 981 } | 985 } |
| 982 | 986 |
| 983 } // namespace test | 987 } // namespace test |
| 984 } // namespace net | 988 } // namespace net |
| 985 | 989 |
| 986 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 990 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
| OLD | NEW |