Remove HttpDecoder::set_visitor().
Since all call sites have a visitor ready when HttpDecoder is instantiated, pass
that in HttpDecoder constructor instead of a set_visitor() method. Also make
HttpDecoder::visitor_ member constant. Just one fewer way to hold HttpDecoder
wrong.
While touching this area already, use |QuicMakeUnique| instead of |new| for
initializing unique_ptr<HttpDecoderVisitor> members. And add quic_ptr_util.h
include to every file touched that needs it, even if no QuicMakeUnique is added
with this CL.
Also remove unused QuicReceiveControlStreamTest::decoder_ member.
gfe-relnote: n/a, change only affects QUIC v99.
PiperOrigin-RevId: 257306155
Change-Id: I6b27704dc6001f69668a36cd6072aaa24a95b389
diff --git a/quic/core/http/http_decoder.h b/quic/core/http/http_decoder.h
index 515daae..b13af0e 100644
--- a/quic/core/http/http_decoder.h
+++ b/quic/core/http/http_decoder.h
@@ -110,16 +110,11 @@
// to allow callers to handle unknown frames.
};
- HttpDecoder();
+ // |visitor| must be non-null, and must outlive HttpDecoder.
+ explicit HttpDecoder(Visitor* visitor);
~HttpDecoder();
- // Set callbacks to be called from the decoder. A visitor must be set, or
- // else the decoder will crash. It is acceptable for the visitor to do
- // nothing. If this is called multiple times, only the last visitor
- // will be used. |visitor| will be owned by the caller.
- void set_visitor(Visitor* visitor) { visitor_ = visitor; }
-
// Processes the input and invokes the appropriate visitor methods, until a
// visitor method returns false or an error occurs. Returns the number of
// bytes processed. Does not process any input if called after an error.
@@ -190,7 +185,7 @@
QuicByteCount MaxFrameLength(uint8_t frame_type);
// Visitor to invoke when messages are parsed.
- Visitor* visitor_; // Unowned.
+ Visitor* const visitor_; // Unowned.
// Current state of the parsing.
HttpDecoderState state_;
// Type of the frame currently being parsed.