Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(288)

Side by Side Diff: net/http2/tools/http2_random.h

Issue 2606733004: Add HpackDecoderTables, static and dynamic tables for decoding HPACK. (Closed)
Patch Set: Rebase. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/http2/hpack/hpack_string.cc ('k') | net/http2/tools/http2_random.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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 #ifndef NET_HTTP2_TOOLS_HTTP2_RANDOM_H_ 5 #ifndef NET_HTTP2_TOOLS_HTTP2_RANDOM_H_
6 #define NET_HTTP2_TOOLS_HTTP2_RANDOM_H_ 6 #define NET_HTTP2_TOOLS_HTTP2_RANDOM_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <limits>
10 #include <string> 11 #include <string>
11 12
12 namespace net { 13 namespace net {
13 namespace test { 14 namespace test {
14 15
15 class RandomBase { 16 class RandomBase {
16 public: 17 public:
17 virtual ~RandomBase() {} 18 virtual ~RandomBase() {}
18 virtual bool OneIn(int n) = 0; 19 virtual bool OneIn(int n) = 0;
19 virtual int32_t Uniform(int32_t n) = 0; 20 virtual int32_t Uniform(int32_t n) = 0;
20 virtual uint8_t Rand8() = 0; 21 virtual uint8_t Rand8() = 0;
21 virtual uint16_t Rand16() = 0; 22 virtual uint16_t Rand16() = 0;
22 virtual uint32_t Rand32() = 0; 23 virtual uint32_t Rand32() = 0;
23 virtual uint64_t Rand64() = 0; 24 virtual uint64_t Rand64() = 0;
24 virtual int32_t Next() = 0; 25 virtual int32_t Next() = 0;
25 virtual int32_t Skewed(int max_log) = 0; 26 virtual int32_t Skewed(int max_log) = 0;
26 virtual std::string RandString(int length) = 0; 27 virtual std::string RandString(int length) = 0;
28
29 // STL UniformRandomNumberGenerator implementation.
30 typedef uint32_t result_type;
31 static constexpr result_type min() { return 0; }
32 static constexpr result_type max() {
33 return std::numeric_limits<uint32_t>::max();
34 }
35 result_type operator()() { return Rand32(); }
27 }; 36 };
28 37
38 // Http2Random holds no state: instances use the same base::RandGenerator
39 // with a global state.
29 class Http2Random : public RandomBase { 40 class Http2Random : public RandomBase {
30 public: 41 public:
31 ~Http2Random() override {} 42 ~Http2Random() override {}
32 bool OneIn(int n) override; 43 bool OneIn(int n) override;
33 int32_t Uniform(int32_t n) override; 44 int32_t Uniform(int32_t n) override;
34 uint8_t Rand8() override; 45 uint8_t Rand8() override;
35 uint16_t Rand16() override; 46 uint16_t Rand16() override;
36 uint32_t Rand32() override; 47 uint32_t Rand32() override;
37 uint64_t Rand64() override; 48 uint64_t Rand64() override;
38 int32_t Next() override; 49 int32_t Next() override;
39 int32_t Skewed(int max_log) override; 50 int32_t Skewed(int max_log) override;
40 std::string RandString(int length) override; 51 std::string RandString(int length) override;
41 }; 52 };
42 53
43 } // namespace test 54 } // namespace test
44 } // namespace net 55 } // namespace net
45 56
46 #endif // NET_HTTP2_TOOLS_HTTP2_RANDOM_H_ 57 #endif // NET_HTTP2_TOOLS_HTTP2_RANDOM_H_
OLDNEW
« no previous file with comments | « net/http2/hpack/hpack_string.cc ('k') | net/http2/tools/http2_random.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698