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

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

Issue 2619043003: Add HpackDecoderState and HpackDecoderListener. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/http2/hpack/decoder/hpack_decoder_listener.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http2/hpack/decoder/hpack_decoder_listener.h
diff --git a/net/http2/hpack/decoder/hpack_decoder_listener.h b/net/http2/hpack/decoder/hpack_decoder_listener.h
new file mode 100644
index 0000000000000000000000000000000000000000..a5facd6ddb3a72fcd652b8f4c07372c375e5cb16
--- /dev/null
+++ b/net/http2/hpack/decoder/hpack_decoder_listener.h
@@ -0,0 +1,65 @@
+// 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.
+
+// Defines HpackDecoderListener, the base class of listeners for HTTP header
+// lists decoded from an HPACK block.
+
+#ifndef NET_HTTP2_HPACK_DECODER_HPACK_DECODER_LISTENER_H_
+#define NET_HTTP2_HPACK_DECODER_HPACK_DECODER_LISTENER_H_
+
+#include "base/strings/string_piece.h"
+#include "net/base/net_export.h"
+#include "net/http2/hpack/hpack_string.h"
+#include "net/http2/hpack/http2_hpack_constants.h"
+
+namespace net {
+
+class NET_EXPORT HpackDecoderListener {
+ public:
+ HpackDecoderListener();
+ virtual ~HpackDecoderListener();
+
+ // OnHeaderListStart is called at the start of decoding an HPACK block into
+ // an HTTP/2 header list. Will only be called once per block, even if it
+ // extends into CONTINUATION frames.
+ virtual void OnHeaderListStart() = 0;
+
+ // Called for each header name-value pair that is decoded, in the order they
+ // appear in the HPACK block. Multiple values for a given key will be emitted
+ // as multiple calls to OnHeader.
+ virtual void OnHeader(HpackEntryType entry_type,
+ const HpackString& name,
+ const HpackString& value) = 0;
+
+ // OnHeaderListEnd is called after successfully decoding an HPACK block into
+ // an HTTP/2 header list. Will only be called once per block, even if it
+ // extends into CONTINUATION frames.
+ virtual void OnHeaderListEnd() = 0;
+
+ // OnHeaderErrorDetected is called if an error is detected while decoding.
+ // error_message may be used in a GOAWAY frame as the Opaque Data.
+ virtual void OnHeaderErrorDetected(base::StringPiece error_message) = 0;
+};
+
+// A no-op implementation of HpackDecoderListener, useful for ignoring
+// callbacks once an error is detected.
+class NET_EXPORT HpackDecoderNoOpListener : public HpackDecoderListener {
+ public:
+ HpackDecoderNoOpListener();
+ ~HpackDecoderNoOpListener() override;
+
+ void OnHeaderListStart() override;
+ void OnHeader(HpackEntryType entry_type,
+ const HpackString& name,
+ const HpackString& value) override;
+ void OnHeaderListEnd() override;
+ void OnHeaderErrorDetected(base::StringPiece error_message) override;
+
+ // Returns a listener that ignores all the calls.
+ static HpackDecoderNoOpListener* NoOpListener();
+};
+
+} // namespace net
+
+#endif // NET_HTTP2_HPACK_DECODER_HPACK_DECODER_LISTENER_H_
« no previous file with comments | « no previous file | net/http2/hpack/decoder/hpack_decoder_listener.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698