Uses the HeaderValidatorBase type within OgHttp2Session::PassthroughHeadersHandler.

PiperOrigin-RevId: 448002691
diff --git a/quiche/http2/adapter/oghttp2_session.cc b/quiche/http2/adapter/oghttp2_session.cc
index c53c8f2..563b6db 100644
--- a/quiche/http2/adapter/oghttp2_session.cc
+++ b/quiche/http2/adapter/oghttp2_session.cc
@@ -216,6 +216,12 @@
 
 }  // namespace
 
+OgHttp2Session::PassthroughHeadersHandler::PassthroughHeadersHandler(
+    OgHttp2Session& session, Http2VisitorInterface& visitor)
+    : session_(session), visitor_(visitor) {
+  validator_ = absl::make_unique<HeaderValidator>();
+}
+
 void OgHttp2Session::PassthroughHeadersHandler::OnHeaderBlockStart() {
   result_ = Http2VisitorInterface::HEADER_OK;
   const bool status = visitor_.OnBeginHeadersForStream(stream_id_);
@@ -224,7 +230,7 @@
         << "Visitor rejected header block, returning HEADER_CONNECTION_ERROR";
     result_ = Http2VisitorInterface::HEADER_CONNECTION_ERROR;
   }
-  validator_.StartHeaderBlock();
+  validator_->StartHeaderBlock();
 }
 
 Http2VisitorInterface::OnHeaderResult InterpretHeaderStatus(
@@ -248,7 +254,7 @@
     return;
   }
   const HeaderValidator::HeaderStatus validation_result =
-      validator_.ValidateSingleHeader(key, value);
+      validator_->ValidateSingleHeader(key, value);
   if (validation_result == HeaderValidator::HEADER_SKIP) {
     return;
   }
@@ -265,7 +271,7 @@
     size_t /* uncompressed_header_bytes */,
     size_t /* compressed_header_bytes */) {
   if (result_ == Http2VisitorInterface::HEADER_OK) {
-    if (!validator_.FinishHeaderBlock(type_)) {
+    if (!validator_->FinishHeaderBlock(type_)) {
       QUICHE_VLOG(1) << "FinishHeaderBlock returned false; returning "
                         "HEADER_HTTP_MESSAGING";
       result_ = Http2VisitorInterface::HEADER_HTTP_MESSAGING;
diff --git a/quiche/http2/adapter/oghttp2_session.h b/quiche/http2/adapter/oghttp2_session.h
index daca603..5c3caa0 100644
--- a/quiche/http2/adapter/oghttp2_session.h
+++ b/quiche/http2/adapter/oghttp2_session.h
@@ -13,6 +13,7 @@
 #include "quiche/http2/adapter/data_source.h"
 #include "quiche/http2/adapter/event_forwarder.h"
 #include "quiche/http2/adapter/header_validator.h"
+#include "quiche/http2/adapter/header_validator_base.h"
 #include "quiche/http2/adapter/http2_protocol.h"
 #include "quiche/http2/adapter/http2_session.h"
 #include "quiche/http2/adapter/http2_util.h"
@@ -241,9 +242,8 @@
   class QUICHE_EXPORT_PRIVATE PassthroughHeadersHandler
       : public spdy::SpdyHeadersHandlerInterface {
    public:
-    explicit PassthroughHeadersHandler(OgHttp2Session& session,
-                                       Http2VisitorInterface& visitor)
-        : session_(session), visitor_(visitor) {}
+    PassthroughHeadersHandler(OgHttp2Session& session,
+                              Http2VisitorInterface& visitor);
 
     void set_stream_id(Http2StreamId stream_id) {
       stream_id_ = stream_id;
@@ -261,18 +261,18 @@
     absl::string_view status_header() const {
       QUICHE_DCHECK(type_ == HeaderType::RESPONSE ||
                     type_ == HeaderType::RESPONSE_100);
-      return validator_.status_header();
+      return validator_->status_header();
     }
     absl::optional<size_t> content_length() const {
-      return validator_.content_length();
+      return validator_->content_length();
     }
-    void AllowConnect() { validator_.AllowConnect(); }
+    void AllowConnect() { validator_->AllowConnect(); }
     void SetMaxFieldSize(uint32_t field_size) {
-      validator_.SetMaxFieldSize(field_size);
+      validator_->SetMaxFieldSize(field_size);
     }
     void SetAllowObsText(bool allow) {
-      validator_.SetObsTextOption(allow ? ObsTextOption::kAllow
-                                        : ObsTextOption::kDisallow);
+      validator_->SetObsTextOption(allow ? ObsTextOption::kAllow
+                                         : ObsTextOption::kDisallow);
     }
     bool CanReceiveBody() const;
 
@@ -283,7 +283,7 @@
     Http2VisitorInterface::OnHeaderResult result_ =
         Http2VisitorInterface::HEADER_OK;
     // Validates header blocks according to the HTTP/2 specification.
-    HeaderValidator validator_;
+    std::unique_ptr<HeaderValidatorBase> validator_;
     HeaderType type_ = HeaderType::RESPONSE;
     bool frame_contains_fin_ = false;
   };