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 #include "net/base/net_export.h" |
| 14 |
| 15 namespace net { |
| 16 namespace test { |
| 17 |
| 18 class RandomBase; |
| 19 |
| 20 // Returns a random string of length |len|, each character drawn uniformly and |
| 21 // independently fom |alphabet|. |
| 22 std::string NET_EXPORT_PRIVATE RandomString(RandomBase* rng, |
| 23 int len, |
| 24 base::StringPiece alphabet); |
| 25 |
| 26 // Returns a random integer in the range [lo, hi). |
| 27 size_t NET_EXPORT_PRIVATE GenerateUniformInRange(size_t lo, |
| 28 size_t hi, |
| 29 RandomBase* rng); |
| 30 |
| 31 // Generate a string with the allowed character set for HTTP/2 / HPACK header |
| 32 // names. |
| 33 std::string NET_EXPORT_PRIVATE GenerateHttp2HeaderName(size_t len, |
| 34 RandomBase* rng); |
| 35 |
| 36 // Generate a string with the web-safe string character set of specified len. |
| 37 std::string NET_EXPORT_PRIVATE GenerateWebSafeString(size_t len, |
| 38 RandomBase* rng); |
| 39 |
| 40 // Generate a string with the web-safe string character set of length [lo, hi). |
| 41 std::string NET_EXPORT_PRIVATE GenerateWebSafeString(size_t lo, |
| 42 size_t hi, |
| 43 RandomBase* rng); |
| 44 |
| 45 } // namespace test |
| 46 } // namespace net |
| 47 |
| 48 #endif // NET_HTTP2_TOOLS_RANDOM_UTIL_H_ |
OLD | NEW |