| // 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 QUICHE_HTTP2_DECODER_HTTP2_FRAME_DECODER_LISTENER_TEST_UTIL_H_ |
| #define QUICHE_HTTP2_DECODER_HTTP2_FRAME_DECODER_LISTENER_TEST_UTIL_H_ |
| |
| #include <stddef.h> |
| |
| #include <cstdint> |
| |
| #include "net/third_party/quiche/src/http2/decoder/http2_frame_decoder_listener.h" |
| #include "net/third_party/quiche/src/http2/http2_constants.h" |
| #include "net/third_party/quiche/src/http2/http2_structures.h" |
| |
| namespace http2 { |
| |
| // Fail if any of the methods are called. Allows a test to override only the |
| // expected calls. |
| class FailingHttp2FrameDecoderListener : public Http2FrameDecoderListener { |
| public: |
| FailingHttp2FrameDecoderListener(); |
| ~FailingHttp2FrameDecoderListener() override; |
| |
| // TODO(jamessynge): Remove OnFrameHeader once done with supporting |
| // SpdyFramer's exact states. |
| bool OnFrameHeader(const Http2FrameHeader& header) override; |
| void OnDataStart(const Http2FrameHeader& header) override; |
| void OnDataPayload(const char* data, size_t len) override; |
| void OnDataEnd() override; |
| void OnHeadersStart(const Http2FrameHeader& header) override; |
| void OnHeadersPriority(const Http2PriorityFields& priority) override; |
| void OnHpackFragment(const char* data, size_t len) override; |
| void OnHeadersEnd() override; |
| void OnPriorityFrame(const Http2FrameHeader& header, |
| const Http2PriorityFields& priority) override; |
| void OnContinuationStart(const Http2FrameHeader& header) override; |
| void OnContinuationEnd() override; |
| void OnPadLength(size_t trailing_length) override; |
| void OnPadding(const char* padding, size_t skipped_length) override; |
| void OnRstStream(const Http2FrameHeader& header, |
| Http2ErrorCode error_code) override; |
| void OnSettingsStart(const Http2FrameHeader& header) override; |
| void OnSetting(const Http2SettingFields& setting_fields) override; |
| void OnSettingsEnd() override; |
| void OnSettingsAck(const Http2FrameHeader& header) override; |
| void OnPushPromiseStart(const Http2FrameHeader& header, |
| const Http2PushPromiseFields& promise, |
| size_t total_padding_length) override; |
| void OnPushPromiseEnd() override; |
| void OnPing(const Http2FrameHeader& header, |
| const Http2PingFields& ping) override; |
| void OnPingAck(const Http2FrameHeader& header, |
| const Http2PingFields& ping) override; |
| void OnGoAwayStart(const Http2FrameHeader& header, |
| const Http2GoAwayFields& goaway) override; |
| void OnGoAwayOpaqueData(const char* data, size_t len) override; |
| void OnGoAwayEnd() override; |
| void OnWindowUpdate(const Http2FrameHeader& header, |
| uint32_t increment) override; |
| void OnAltSvcStart(const Http2FrameHeader& header, |
| size_t origin_length, |
| size_t value_length) override; |
| void OnAltSvcOriginData(const char* data, size_t len) override; |
| void OnAltSvcValueData(const char* data, size_t len) override; |
| void OnAltSvcEnd() override; |
| void OnUnknownStart(const Http2FrameHeader& header) override; |
| void OnUnknownPayload(const char* data, size_t len) override; |
| void OnUnknownEnd() override; |
| void OnPaddingTooLong(const Http2FrameHeader& header, |
| size_t missing_length) override; |
| void OnFrameSizeError(const Http2FrameHeader& header) override; |
| |
| private: |
| void EnsureNotAbstract() { FailingHttp2FrameDecoderListener instance; } |
| }; |
| |
| // HTTP2_VLOG's all the calls it receives, and forwards those calls to an |
| // optional listener. |
| class LoggingHttp2FrameDecoderListener : public Http2FrameDecoderListener { |
| public: |
| LoggingHttp2FrameDecoderListener(); |
| explicit LoggingHttp2FrameDecoderListener(Http2FrameDecoderListener* wrapped); |
| ~LoggingHttp2FrameDecoderListener() override; |
| |
| // TODO(jamessynge): Remove OnFrameHeader once done with supporting |
| // SpdyFramer's exact states. |
| bool OnFrameHeader(const Http2FrameHeader& header) override; |
| void OnDataStart(const Http2FrameHeader& header) override; |
| void OnDataPayload(const char* data, size_t len) override; |
| void OnDataEnd() override; |
| void OnHeadersStart(const Http2FrameHeader& header) override; |
| void OnHeadersPriority(const Http2PriorityFields& priority) override; |
| void OnHpackFragment(const char* data, size_t len) override; |
| void OnHeadersEnd() override; |
| void OnPriorityFrame(const Http2FrameHeader& header, |
| const Http2PriorityFields& priority) override; |
| void OnContinuationStart(const Http2FrameHeader& header) override; |
| void OnContinuationEnd() override; |
| void OnPadLength(size_t trailing_length) override; |
| void OnPadding(const char* padding, size_t skipped_length) override; |
| void OnRstStream(const Http2FrameHeader& header, |
| Http2ErrorCode error_code) override; |
| void OnSettingsStart(const Http2FrameHeader& header) override; |
| void OnSetting(const Http2SettingFields& setting_fields) override; |
| void OnSettingsEnd() override; |
| void OnSettingsAck(const Http2FrameHeader& header) override; |
| void OnPushPromiseStart(const Http2FrameHeader& header, |
| const Http2PushPromiseFields& promise, |
| size_t total_padding_length) override; |
| void OnPushPromiseEnd() override; |
| void OnPing(const Http2FrameHeader& header, |
| const Http2PingFields& ping) override; |
| void OnPingAck(const Http2FrameHeader& header, |
| const Http2PingFields& ping) override; |
| void OnGoAwayStart(const Http2FrameHeader& header, |
| const Http2GoAwayFields& goaway) override; |
| void OnGoAwayOpaqueData(const char* data, size_t len) override; |
| void OnGoAwayEnd() override; |
| void OnWindowUpdate(const Http2FrameHeader& header, |
| uint32_t increment) override; |
| void OnAltSvcStart(const Http2FrameHeader& header, |
| size_t origin_length, |
| size_t value_length) override; |
| void OnAltSvcOriginData(const char* data, size_t len) override; |
| void OnAltSvcValueData(const char* data, size_t len) override; |
| void OnAltSvcEnd() override; |
| void OnUnknownStart(const Http2FrameHeader& header) override; |
| void OnUnknownPayload(const char* data, size_t len) override; |
| void OnUnknownEnd() override; |
| void OnPaddingTooLong(const Http2FrameHeader& header, |
| size_t missing_length) override; |
| void OnFrameSizeError(const Http2FrameHeader& header) override; |
| |
| private: |
| void EnsureNotAbstract() { LoggingHttp2FrameDecoderListener instance; } |
| |
| Http2FrameDecoderListener* wrapped_; |
| }; |
| |
| } // namespace http2 |
| |
| #endif // QUICHE_HTTP2_DECODER_HTTP2_FRAME_DECODER_LISTENER_TEST_UTIL_H_ |