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

Unified Diff: net/http2/http2_structures_test_util.cc

Issue 2293613002: Add new HTTP/2 and HPACK decoder in net/http2/. (Closed)
Patch Set: Replace LOG(INFO) by VLOG(2) in DecodeBufferTest.SlowDecodeTestStruct so that trybots do not fail. 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http2/http2_structures_test_util.cc
diff --git a/net/http2/http2_structures_test_util.cc b/net/http2/http2_structures_test_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1e6f4290af36bd215c0b380527f70a615b4a76b7
--- /dev/null
+++ b/net/http2/http2_structures_test_util.cc
@@ -0,0 +1,107 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/http2/http2_structures_test_util.h"
+
+#include "net/http2/http2_constants.h"
+#include "net/http2/http2_constants_test_util.h"
+#include "net/http2/http2_structures.h"
+#include "net/http2/tools/http2_random.h"
+
+namespace net {
+namespace test {
+
+void Randomize(Http2FrameHeader* p, RandomBase* rng) {
+ p->payload_length = rng->Rand32() & 0xffffff;
+ p->type = static_cast<Http2FrameType>(rng->Rand8());
+ p->flags = static_cast<Http2FrameFlag>(rng->Rand8());
+ p->stream_id = rng->Rand32() & StreamIdMask();
+}
+void Randomize(Http2PriorityFields* p, RandomBase* rng) {
+ p->stream_dependency = rng->Rand32() & StreamIdMask();
+ p->weight = rng->Rand8() + 1;
+ p->is_exclusive = rng->OneIn(2);
+}
+void Randomize(Http2RstStreamFields* p, RandomBase* rng) {
+ p->error_code = static_cast<Http2ErrorCode>(rng->Rand32());
+}
+void Randomize(Http2SettingFields* p, RandomBase* rng) {
+ p->parameter = static_cast<Http2SettingsParameter>(rng->Rand16());
+ p->value = rng->Rand32();
+}
+void Randomize(Http2PushPromiseFields* p, RandomBase* rng) {
+ p->promised_stream_id = rng->Rand32() & StreamIdMask();
+}
+void Randomize(Http2PingFields* p, RandomBase* rng) {
+ for (int ndx = 0; ndx < 8; ++ndx) {
+ p->opaque_data[ndx] = rng->Rand8();
+ }
+}
+void Randomize(Http2GoAwayFields* p, RandomBase* rng) {
+ p->last_stream_id = rng->Rand32() & StreamIdMask();
+ p->error_code = static_cast<Http2ErrorCode>(rng->Rand32());
+}
+void Randomize(Http2WindowUpdateFields* p, RandomBase* rng) {
+ p->window_size_increment = rng->Rand32() & 0x7fffffff;
+}
+void Randomize(Http2AltSvcFields* p, RandomBase* rng) {
+ p->origin_length = rng->Rand16();
+}
+
+void ScrubFlagsOfHeader(Http2FrameHeader* header) {
+ uint8_t invalid_mask = InvalidFlagMaskForFrameType(header->type);
+ uint8_t keep_mask = ~invalid_mask;
+ header->RetainFlags(keep_mask);
+}
+
+bool FrameIsPadded(const Http2FrameHeader& header) {
+ switch (header.type) {
+ case Http2FrameType::DATA:
+ case Http2FrameType::HEADERS:
+ case Http2FrameType::PUSH_PROMISE:
+ return header.IsPadded();
+ default:
+ return false;
+ }
+}
+
+bool FrameHasPriority(const Http2FrameHeader& header) {
+ switch (header.type) {
+ case Http2FrameType::HEADERS:
+ return header.HasPriority();
+ case Http2FrameType::PRIORITY:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool FrameCanHavePayload(const Http2FrameHeader& header) {
+ switch (header.type) {
+ case Http2FrameType::DATA:
+ case Http2FrameType::HEADERS:
+ case Http2FrameType::PUSH_PROMISE:
+ case Http2FrameType::CONTINUATION:
+ case Http2FrameType::PING:
+ case Http2FrameType::GOAWAY:
+ case Http2FrameType::ALTSVC:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool FrameCanHaveHpackPayload(const Http2FrameHeader& header) {
+ switch (header.type) {
+ case Http2FrameType::HEADERS:
+ case Http2FrameType::PUSH_PROMISE:
+ case Http2FrameType::CONTINUATION:
+ return true;
+ default:
+ return false;
+ }
+}
+
+} // namespace test
+} // namespace net
« 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