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

Unified Diff: net/http2/hpack/decoder/hpack_string_collector.h

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
Index: net/http2/hpack/decoder/hpack_string_collector.h
diff --git a/net/http2/hpack/decoder/hpack_string_collector.h b/net/http2/hpack/decoder/hpack_string_collector.h
new file mode 100644
index 0000000000000000000000000000000000000000..1bc58310044b1cedb079cbf065aa25c16481b8a6
--- /dev/null
+++ b/net/http2/hpack/decoder/hpack_string_collector.h
@@ -0,0 +1,63 @@
+// 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.
+
+#ifndef NET_HTTP2_HPACK_DECODER_HPACK_STRING_COLLECTOR_H_
+#define NET_HTTP2_HPACK_DECODER_HPACK_STRING_COLLECTOR_H_
+
+// Supports tests of decoding HPACK strings.
+
+#include <stddef.h>
+
+#include <iosfwd>
+#include <string>
+
+#include "base/strings/string_piece.h"
+#include "net/http2/hpack/decoder/hpack_string_decoder_listener.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+namespace test {
+
+// Records the callbacks associated with a decoding a string; must
+// call Clear() between decoding successive strings.
+struct HpackStringCollector : public HpackStringDecoderListener {
+ enum CollectorState {
+ kGenesis,
+ kStarted,
+ kEnded,
+ };
+
+ HpackStringCollector();
+ HpackStringCollector(const std::string& str, bool huffman);
+
+ void Clear();
+ bool IsClear() const;
+ bool IsInProgress() const;
+ bool HasEnded() const;
+
+ void OnStringStart(bool huffman, size_t length) override;
+ void OnStringData(const char* data, size_t length) override;
+ void OnStringEnd() override;
+
+ ::testing::AssertionResult Collected(base::StringPiece str,
+ bool is_huffman_encoded) const;
+
+ std::string ToString() const;
+
+ std::string s;
+ size_t len;
+ bool huffman_encoded;
+ CollectorState state;
+};
+
+bool operator==(const HpackStringCollector& a, const HpackStringCollector& b);
+
+bool operator!=(const HpackStringCollector& a, const HpackStringCollector& b);
+
+std::ostream& operator<<(std::ostream& out, const HpackStringCollector& v);
+
+} // namespace test
+} // namespace net
+
+#endif // NET_HTTP2_HPACK_DECODER_HPACK_STRING_COLLECTOR_H_
« no previous file with comments | « net/http2/hpack/decoder/hpack_entry_type_decoder_test.cc ('k') | net/http2/hpack/decoder/hpack_string_collector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698