Add an interface method for accepting trailers (with ownership) in Balsa.
This CL introduces BalsaVisitorInterface::OnTrailers() to deliver trailers with
ownership, with the eventual goal of replacing
BalsaVisitorInterface::ProcessTrailers() that delivers a non-owning reference
to trailers. The goal is to migrate [1] and move the trailers-processing logic
to a callback in BackendResponder, somewhat simplifying HttpReader (more
details in descendant cl/550634500). A stretch goal is to unconditionally
deliver trailers and then store them in HttpRequestInfo only if the conditions
in [2] hold true.
[1] http://google3/gfe/gfe2/jetstream/http_reader.cc;l=353;rcl=547269861
[2] http://google3/gfe/gfe2/jetstream/backend_responder.cc;l=1119-1120;rcl=549171119
PiperOrigin-RevId: 551249347
diff --git a/quiche/balsa/balsa_frame_test.cc b/quiche/balsa/balsa_frame_test.cc
index 6eec66a..d80465d 100644
--- a/quiche/balsa/balsa_frame_test.cc
+++ b/quiche/balsa/balsa_frame_test.cc
@@ -547,6 +547,8 @@
MOCK_METHOD(void, OnTrailerInput, (absl::string_view input), (override));
MOCK_METHOD(void, ProcessHeaders, (const FakeHeaders& headers));
MOCK_METHOD(void, ProcessTrailers, (const FakeHeaders& headers));
+ MOCK_METHOD(void, OnTrailers, (std::unique_ptr<BalsaHeaders> trailers),
+ (override));
MOCK_METHOD(void, OnRequestFirstLineInput,
(absl::string_view line_input, absl::string_view method_input,
absl::string_view request_uri, absl::string_view version_input),
diff --git a/quiche/balsa/balsa_visitor_interface.h b/quiche/balsa/balsa_visitor_interface.h
index 89355f3..db955fb 100644
--- a/quiche/balsa/balsa_visitor_interface.h
+++ b/quiche/balsa/balsa_visitor_interface.h
@@ -85,9 +85,19 @@
// Arguments:
// trailer - contains the parsed headers in the order in which
// they occurred in the trailer.
+ // TODO(b/134507471): Remove this and update the OnTrailers() comment.
virtual void ProcessTrailers(const BalsaHeaders& trailer) = 0;
// Summary:
+ // Called when the trailers are framed and processed. This callback is only
+ // called when the trailers option is set in the framer, and it is mutually
+ // exclusive with ProcessTrailers().
+ // Arguments:
+ // trailers - contains the parsed headers in the order in which they
+ // occurred in the trailers.
+ virtual void OnTrailers(std::unique_ptr<BalsaHeaders> trailers) = 0;
+
+ // Summary:
// Called when the first line of the message is parsed, in this case, for a
// request.
// Arguments:
diff --git a/quiche/balsa/noop_balsa_visitor.h b/quiche/balsa/noop_balsa_visitor.h
index 5645070..20c478d 100644
--- a/quiche/balsa/noop_balsa_visitor.h
+++ b/quiche/balsa/noop_balsa_visitor.h
@@ -36,6 +36,7 @@
void OnTrailerInput(absl::string_view /*input*/) override {}
void ProcessHeaders(const BalsaHeaders& /*headers*/) override {}
void ProcessTrailers(const BalsaHeaders& /*trailer*/) override {}
+ void OnTrailers(std::unique_ptr<BalsaHeaders> /*trailers*/) override {}
void OnRequestFirstLineInput(absl::string_view /*line_input*/,
absl::string_view /*method_input*/,