OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NET_HTTP2_TOOLS_RANDOM_UTIL_H_ |
| 6 #define NET_HTTP2_TOOLS_RANDOM_UTIL_H_ |
| 7 |
| 8 #include <stddef.h> |
| 9 |
| 10 #include <string> |
| 11 |
| 12 #include "base/strings/string_piece.h" |
| 13 |
| 14 namespace net { |
| 15 namespace test { |
| 16 |
| 17 class RandomBase; |
| 18 |
| 19 // Returns a random string of length |len|, each character drawn uniformly and |
| 20 // independently fom |alphabet|. |
| 21 std::string RandomString(RandomBase* rng, int len, base::StringPiece alphabet); |
| 22 |
| 23 // Returns a random integer in the range [lo, hi). |
| 24 size_t GenerateUniformInRange(size_t lo, size_t hi, RandomBase* rng); |
| 25 |
| 26 // Generate a string with the allowed character set for HTTP/2 / HPACK header |
| 27 // names. |
| 28 std::string GenerateHttp2HeaderName(size_t len, RandomBase* rng); |
| 29 |
| 30 // Generate a string with the web-safe string character set of specified len. |
| 31 std::string GenerateWebSafeString(size_t len, RandomBase* rng); |
| 32 |
| 33 // Generate a string with the web-safe string character set of length [lo, hi). |
| 34 std::string GenerateWebSafeString(size_t lo, size_t hi, RandomBase* rng); |
| 35 |
| 36 } // namespace test |
| 37 } // namespace net |
| 38 |
| 39 #endif // NET_HTTP2_TOOLS_RANDOM_UTIL_H_ |
OLD | NEW |