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

Side by Side Diff: net/http2/http2_structures_test_util.cc

Issue 2554683003: Revert of Add new HTTP/2 and HPACK decoder in net/http2/. (Closed)
Patch Set: Created 4 years 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/http2_structures_test_util.h ('k') | net/http2/tools/failure.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #include "net/http2/http2_structures_test_util.h"
6
7 #include "net/http2/http2_constants.h"
8 #include "net/http2/http2_constants_test_util.h"
9 #include "net/http2/http2_structures.h"
10 #include "net/http2/tools/http2_random.h"
11
12 namespace net {
13 namespace test {
14
15 void Randomize(Http2FrameHeader* p, RandomBase* rng) {
16 p->payload_length = rng->Rand32() & 0xffffff;
17 p->type = static_cast<Http2FrameType>(rng->Rand8());
18 p->flags = static_cast<Http2FrameFlag>(rng->Rand8());
19 p->stream_id = rng->Rand32() & StreamIdMask();
20 }
21 void Randomize(Http2PriorityFields* p, RandomBase* rng) {
22 p->stream_dependency = rng->Rand32() & StreamIdMask();
23 p->weight = rng->Rand8() + 1;
24 p->is_exclusive = rng->OneIn(2);
25 }
26 void Randomize(Http2RstStreamFields* p, RandomBase* rng) {
27 p->error_code = static_cast<Http2ErrorCode>(rng->Rand32());
28 }
29 void Randomize(Http2SettingFields* p, RandomBase* rng) {
30 p->parameter = static_cast<Http2SettingsParameter>(rng->Rand16());
31 p->value = rng->Rand32();
32 }
33 void Randomize(Http2PushPromiseFields* p, RandomBase* rng) {
34 p->promised_stream_id = rng->Rand32() & StreamIdMask();
35 }
36 void Randomize(Http2PingFields* p, RandomBase* rng) {
37 for (int ndx = 0; ndx < 8; ++ndx) {
38 p->opaque_data[ndx] = rng->Rand8();
39 }
40 }
41 void Randomize(Http2GoAwayFields* p, RandomBase* rng) {
42 p->last_stream_id = rng->Rand32() & StreamIdMask();
43 p->error_code = static_cast<Http2ErrorCode>(rng->Rand32());
44 }
45 void Randomize(Http2WindowUpdateFields* p, RandomBase* rng) {
46 p->window_size_increment = rng->Rand32() & 0x7fffffff;
47 }
48 void Randomize(Http2AltSvcFields* p, RandomBase* rng) {
49 p->origin_length = rng->Rand16();
50 }
51
52 void ScrubFlagsOfHeader(Http2FrameHeader* header) {
53 uint8_t invalid_mask = InvalidFlagMaskForFrameType(header->type);
54 uint8_t keep_mask = ~invalid_mask;
55 header->RetainFlags(keep_mask);
56 }
57
58 bool FrameIsPadded(const Http2FrameHeader& header) {
59 switch (header.type) {
60 case Http2FrameType::DATA:
61 case Http2FrameType::HEADERS:
62 case Http2FrameType::PUSH_PROMISE:
63 return header.IsPadded();
64 default:
65 return false;
66 }
67 }
68
69 bool FrameHasPriority(const Http2FrameHeader& header) {
70 switch (header.type) {
71 case Http2FrameType::HEADERS:
72 return header.HasPriority();
73 case Http2FrameType::PRIORITY:
74 return true;
75 default:
76 return false;
77 }
78 }
79
80 bool FrameCanHavePayload(const Http2FrameHeader& header) {
81 switch (header.type) {
82 case Http2FrameType::DATA:
83 case Http2FrameType::HEADERS:
84 case Http2FrameType::PUSH_PROMISE:
85 case Http2FrameType::CONTINUATION:
86 case Http2FrameType::PING:
87 case Http2FrameType::GOAWAY:
88 case Http2FrameType::ALTSVC:
89 return true;
90 default:
91 return false;
92 }
93 }
94
95 bool FrameCanHaveHpackPayload(const Http2FrameHeader& header) {
96 switch (header.type) {
97 case Http2FrameType::HEADERS:
98 case Http2FrameType::PUSH_PROMISE:
99 case Http2FrameType::CONTINUATION:
100 return true;
101 default:
102 return false;
103 }
104 }
105
106 } // namespace test
107 } // namespace net
OLDNEW
« no previous file with comments | « net/http2/http2_structures_test_util.h ('k') | net/http2/tools/failure.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698