Replace indeterminate BHTTP request decoder factory method with public constructor.

The factory method `Create` was introduced in the absence of `ABSL_DIE_IF_NULL` (as recommended in [totw/116](go/totw/116#one-step-further-one-less-comment-storing-a-reference)) from QUICHE, but it has now been decided that the public constructor with absl annotations is enough.

PiperOrigin-RevId: 856725179
diff --git a/quiche/binary_http/binary_http_message.h b/quiche/binary_http/binary_http_message.h
index f2ca6b7..927c4db 100644
--- a/quiche/binary_http/binary_http_message.h
+++ b/quiche/binary_http/binary_http_message.h
@@ -3,8 +3,6 @@
 
 #include <cstddef>
 #include <cstdint>
-#include <functional>
-#include <memory>
 #include <optional>
 #include <ostream>
 #include <string>
@@ -13,7 +11,6 @@
 
 #include "absl/base/attributes.h"
 #include "absl/base/nullability.h"
-#include "absl/container/flat_hash_map.h"
 #include "absl/status/status.h"
 #include "absl/status/statusor.h"
 #include "absl/strings/string_view.h"
@@ -241,15 +238,10 @@
   // Creates a new IndeterminateLengthDecoder. Does not take ownership of
   // `message_section_handler`, which must refer to a valid handler that
   // outlives this decoder.
-  static absl::StatusOr<BinaryHttpRequest::IndeterminateLengthDecoder> Create(
+  explicit IndeterminateLengthDecoder(
       MessageSectionHandler* absl_nonnull message_section_handler
-          ABSL_ATTRIBUTE_LIFETIME_BOUND) {
-    if (message_section_handler == nullptr) {
-      return absl::InvalidArgumentError("MessageSectionHandler is null");
-    }
-    return BinaryHttpRequest::IndeterminateLengthDecoder(
-        message_section_handler);
-  }
+          ABSL_ATTRIBUTE_LIFETIME_BOUND)
+      : message_section_handler_(*message_section_handler) {}
 
   // Decodes an Indeterminate-Length BHTTP request. As the caller receives
   // portions of the request, the caller can call this method with the request
@@ -265,10 +257,6 @@
   absl::Status Decode(absl::string_view data, bool end_stream);
 
  private:
-  explicit IndeterminateLengthDecoder(
-      MessageSectionHandler* absl_nonnull message_section_handler
-          ABSL_ATTRIBUTE_LIFETIME_BOUND)
-      : message_section_handler_(*message_section_handler) {}
   // Carries out the decode logic from the checkpoint. Returns
   // OutOfRangeError if there is not enough data to decode the current
   // section. When a section is fully decoded, the checkpoint is updated.
diff --git a/quiche/binary_http/binary_http_message_test.cc b/quiche/binary_http/binary_http_message_test.cc
index ceb688d..b56ae74 100644
--- a/quiche/binary_http/binary_http_message_test.cc
+++ b/quiche/binary_http/binary_http_message_test.cc
@@ -570,10 +570,8 @@
           kPadding),
       &request_bytes));
   RequestMessageSectionTestHandler handler;
-  absl::StatusOr<BinaryHttpRequest::IndeterminateLengthDecoder> decoder =
-      BinaryHttpRequest::IndeterminateLengthDecoder::Create(&handler);
-  QUICHE_ASSERT_OK(decoder);
-  QUICHE_EXPECT_OK(decoder->Decode(request_bytes, /*end_stream=*/true));
+  BinaryHttpRequest::IndeterminateLengthDecoder decoder(&handler);
+  QUICHE_EXPECT_OK(decoder.Decode(request_bytes, /*end_stream=*/true));
   QUICHE_EXPECT_OK(
       ExpectRequestMessageSectionHandler(handler.GetMessageData()));
 }
@@ -625,70 +623,56 @@
   std::string error_message = "Failed to handle control data";
   EXPECT_CALL(*handler, OnControlData(_))
       .WillOnce(Return(absl::InternalError(error_message)));
-  absl::StatusOr<BinaryHttpRequest::IndeterminateLengthDecoder> decoder =
-      BinaryHttpRequest::IndeterminateLengthDecoder::Create(handler.get());
-  QUICHE_ASSERT_OK(decoder);
-  EXPECT_THAT(decoder->Decode(request_bytes, true),
+  BinaryHttpRequest::IndeterminateLengthDecoder decoder(handler.get());
+  EXPECT_THAT(decoder.Decode(request_bytes, true),
               test::StatusIs(kInternal, HasSubstr(error_message)));
 
   handler = GetMockMessageSectionHandler();
   error_message = "Failed to handle header";
   EXPECT_CALL(*handler, OnHeader(_, _))
       .WillOnce(Return(absl::InternalError(error_message)));
-  absl::StatusOr<BinaryHttpRequest::IndeterminateLengthDecoder> decoder2 =
-      BinaryHttpRequest::IndeterminateLengthDecoder::Create(handler.get());
-  QUICHE_ASSERT_OK(decoder2);
-  EXPECT_THAT(decoder2->Decode(request_bytes, true),
+  BinaryHttpRequest::IndeterminateLengthDecoder decoder2(handler.get());
+  EXPECT_THAT(decoder2.Decode(request_bytes, true),
               test::StatusIs(kInternal, HasSubstr(error_message)));
 
   handler = GetMockMessageSectionHandler();
   error_message = "Failed to handle headers done";
   EXPECT_CALL(*handler, OnHeadersDone())
       .WillOnce(Return(absl::InternalError(error_message)));
-  absl::StatusOr<BinaryHttpRequest::IndeterminateLengthDecoder> decoder3 =
-      BinaryHttpRequest::IndeterminateLengthDecoder::Create(handler.get());
-  QUICHE_ASSERT_OK(decoder3);
-  EXPECT_THAT(decoder3->Decode(request_bytes, true),
+  BinaryHttpRequest::IndeterminateLengthDecoder decoder3(handler.get());
+  EXPECT_THAT(decoder3.Decode(request_bytes, true),
               test::StatusIs(kInternal, HasSubstr(error_message)));
 
   handler = GetMockMessageSectionHandler();
   error_message = "Failed to handle body chunk";
   EXPECT_CALL(*handler, OnBodyChunk(_))
       .WillOnce(Return(absl::InternalError(error_message)));
-  absl::StatusOr<BinaryHttpRequest::IndeterminateLengthDecoder> decoder4 =
-      BinaryHttpRequest::IndeterminateLengthDecoder::Create(handler.get());
-  QUICHE_ASSERT_OK(decoder4);
-  EXPECT_THAT(decoder4->Decode(request_bytes, true),
+  BinaryHttpRequest::IndeterminateLengthDecoder decoder4(handler.get());
+  EXPECT_THAT(decoder4.Decode(request_bytes, true),
               test::StatusIs(kInternal, HasSubstr(error_message)));
 
   handler = GetMockMessageSectionHandler();
   error_message = "Failed to handle body chunks done";
   EXPECT_CALL(*handler, OnBodyChunksDone())
       .WillOnce(Return(absl::InternalError(error_message)));
-  absl::StatusOr<BinaryHttpRequest::IndeterminateLengthDecoder> decoder5 =
-      BinaryHttpRequest::IndeterminateLengthDecoder::Create(handler.get());
-  QUICHE_ASSERT_OK(decoder5);
-  EXPECT_THAT(decoder5->Decode(request_bytes, true),
+  BinaryHttpRequest::IndeterminateLengthDecoder decoder5(handler.get());
+  EXPECT_THAT(decoder5.Decode(request_bytes, true),
               test::StatusIs(kInternal, HasSubstr(error_message)));
 
   handler = GetMockMessageSectionHandler();
   error_message = "Failed to handle trailer";
   EXPECT_CALL(*handler, OnTrailer(_, _))
       .WillOnce(Return(absl::InternalError(error_message)));
-  absl::StatusOr<BinaryHttpRequest::IndeterminateLengthDecoder> decoder6 =
-      BinaryHttpRequest::IndeterminateLengthDecoder::Create(handler.get());
-  QUICHE_ASSERT_OK(decoder6);
-  EXPECT_THAT(decoder6->Decode(request_bytes, true),
+  BinaryHttpRequest::IndeterminateLengthDecoder decoder6(handler.get());
+  EXPECT_THAT(decoder6.Decode(request_bytes, true),
               test::StatusIs(kInternal, HasSubstr(error_message)));
 
   handler = GetMockMessageSectionHandler();
   error_message = "Failed to handle trailers done";
   EXPECT_CALL(*handler, OnTrailersDone())
       .WillOnce(Return(absl::InternalError(error_message)));
-  absl::StatusOr<BinaryHttpRequest::IndeterminateLengthDecoder> decoder7 =
-      BinaryHttpRequest::IndeterminateLengthDecoder::Create(handler.get());
-  QUICHE_ASSERT_OK(decoder7);
-  EXPECT_THAT(decoder7->Decode(request_bytes, true),
+  BinaryHttpRequest::IndeterminateLengthDecoder decoder7(handler.get());
+  EXPECT_THAT(decoder7.Decode(request_bytes, true),
               test::StatusIs(kInternal, HasSubstr(error_message)));
 }
 
@@ -703,15 +687,13 @@
           kPadding),
       &request_bytes));
   RequestMessageSectionTestHandler handler;
-  absl::StatusOr<BinaryHttpRequest::IndeterminateLengthDecoder> decoder =
-      BinaryHttpRequest::IndeterminateLengthDecoder::Create(&handler);
-  QUICHE_ASSERT_OK(decoder);
+  BinaryHttpRequest::IndeterminateLengthDecoder decoder(&handler);
   for (uint64_t i = 0; i < request_bytes.size() - 1; i++) {
     QUICHE_EXPECT_OK(
-        decoder->Decode(absl::string_view(&request_bytes[i], 1), false));
+        decoder.Decode(absl::string_view(&request_bytes[i], 1), false));
   }
   // Decode the last byte, send end_stream.
-  QUICHE_EXPECT_OK(decoder->Decode(
+  QUICHE_EXPECT_OK(decoder.Decode(
       absl::string_view(&request_bytes[request_bytes.size() - 1], 1), true));
   QUICHE_EXPECT_OK(
       ExpectRequestMessageSectionHandler(handler.GetMessageData()));
@@ -725,29 +707,23 @@
   std::string request_bytes;
   EXPECT_TRUE(absl::HexStringToBytes(incomplete_request_bytes, &request_bytes));
   RequestMessageSectionTestHandler handler;
-  absl::StatusOr<BinaryHttpRequest::IndeterminateLengthDecoder> decoder =
-      BinaryHttpRequest::IndeterminateLengthDecoder::Create(&handler);
-  QUICHE_ASSERT_OK(decoder);
-  EXPECT_THAT(decoder->Decode(request_bytes, /*end_stream=*/true),
+  BinaryHttpRequest::IndeterminateLengthDecoder decoder(&handler);
+  EXPECT_THAT(decoder.Decode(request_bytes, /*end_stream=*/true),
               test::StatusIs(kInvalidArgument));
 }
 
 TEST(IndeterminateLengthDecoder, InvalidFramingError) {
   RequestMessageSectionTestHandler handler;
-  absl::StatusOr<BinaryHttpRequest::IndeterminateLengthDecoder> decoder =
-      BinaryHttpRequest::IndeterminateLengthDecoder::Create(&handler);
-  QUICHE_ASSERT_OK(decoder);
+  BinaryHttpRequest::IndeterminateLengthDecoder decoder(&handler);
   std::string request_bytes;
   EXPECT_TRUE(absl::HexStringToBytes("00", &request_bytes));
-  absl::Status status = decoder->Decode(request_bytes, /*end_stream=*/false);
+  absl::Status status = decoder.Decode(request_bytes, /*end_stream=*/false);
   EXPECT_THAT(status, test::StatusIs(kInvalidArgument));
 }
 
 TEST(IndeterminateLengthDecoder, InvalidPaddingError) {
   RequestMessageSectionTestHandler handler;
-  absl::StatusOr<BinaryHttpRequest::IndeterminateLengthDecoder> decoder =
-      BinaryHttpRequest::IndeterminateLengthDecoder::Create(&handler);
-  QUICHE_ASSERT_OK(decoder);
+  BinaryHttpRequest::IndeterminateLengthDecoder decoder(&handler);
   std::string request_bytes;
   EXPECT_TRUE(absl::HexStringToBytes(
       absl::StrCat(
@@ -757,8 +733,8 @@
           kIndeterminateLengthEncodedRequestTrailers, kContentTerminator,
           kPadding),
       &request_bytes));
-  QUICHE_EXPECT_OK(decoder->Decode(request_bytes, /*end_stream=*/false));
-  absl::Status status = decoder->Decode("\x01", /*end_stream=*/false);
+  QUICHE_EXPECT_OK(decoder.Decode(request_bytes, /*end_stream=*/false));
+  absl::Status status = decoder.Decode("\x01", /*end_stream=*/false);
   EXPECT_THAT(status, test::StatusIs(kInvalidArgument));
 }
 
@@ -784,9 +760,7 @@
 
 TEST(IndeterminateLengthDecoder, TruncatedBodyAndTrailers) {
   RequestMessageSectionTestHandler handler;
-  absl::StatusOr<BinaryHttpRequest::IndeterminateLengthDecoder> decoder =
-      BinaryHttpRequest::IndeterminateLengthDecoder::Create(&handler);
-  QUICHE_ASSERT_OK(decoder);
+  BinaryHttpRequest::IndeterminateLengthDecoder decoder(&handler);
   std::string request_bytes;
   EXPECT_TRUE(absl::HexStringToBytes(
       absl::StrCat(
@@ -794,7 +768,7 @@
           kIndeterminateLengthEncodedRequestHeaders, k8ByteContentTerminator),
       &request_bytes));
 
-  QUICHE_EXPECT_OK(decoder->Decode(request_bytes, /*end_stream=*/true));
+  QUICHE_EXPECT_OK(decoder.Decode(request_bytes, /*end_stream=*/true));
   auto message_data = handler.GetMessageData();
   EXPECT_TRUE(message_data.body_chunks_done_);
   EXPECT_THAT(message_data.body_chunks_, IsEmpty());
@@ -803,9 +777,7 @@
 
 TEST(IndeterminateLengthDecoder, TruncatedBodyAndTrailersSplitEndStream) {
   RequestMessageSectionTestHandler handler;
-  absl::StatusOr<BinaryHttpRequest::IndeterminateLengthDecoder> decoder =
-      BinaryHttpRequest::IndeterminateLengthDecoder::Create(&handler);
-  QUICHE_ASSERT_OK(decoder);
+  BinaryHttpRequest::IndeterminateLengthDecoder decoder(&handler);
   std::string request_bytes;
   EXPECT_TRUE(absl::HexStringToBytes(
       absl::StrCat(
@@ -813,9 +785,9 @@
           kIndeterminateLengthEncodedRequestHeaders, k8ByteContentTerminator),
       &request_bytes));
 
-  QUICHE_EXPECT_OK(decoder->Decode(request_bytes, /*end_stream=*/false));
+  QUICHE_EXPECT_OK(decoder.Decode(request_bytes, /*end_stream=*/false));
   // Send `end_stream` with no data.
-  QUICHE_EXPECT_OK(decoder->Decode("", /*end_stream=*/true));
+  QUICHE_EXPECT_OK(decoder.Decode("", /*end_stream=*/true));
   auto message_data = handler.GetMessageData();
   EXPECT_TRUE(message_data.body_chunks_done_);
   EXPECT_THAT(message_data.body_chunks_, IsEmpty());
@@ -982,10 +954,8 @@
   EXPECT_EQ(encoded_data, expected);
 
   RequestMessageSectionTestHandler handler;
-  absl::StatusOr<BinaryHttpRequest::IndeterminateLengthDecoder> decoder =
-      BinaryHttpRequest::IndeterminateLengthDecoder::Create(&handler);
-  QUICHE_ASSERT_OK(decoder);
-  QUICHE_EXPECT_OK(decoder->Decode(encoded_data, /*end_stream=*/true));
+  BinaryHttpRequest::IndeterminateLengthDecoder decoder(&handler);
+  QUICHE_EXPECT_OK(decoder.Decode(encoded_data, /*end_stream=*/true));
   QUICHE_EXPECT_OK(
       ExpectRequestMessageSectionHandler(handler.GetMessageData()));
 }
@@ -1923,9 +1893,7 @@
 
 TEST(IndeterminateLengthDecoder, TruncatedTrailers) {
   RequestMessageSectionTestHandler handler;
-  absl::StatusOr<BinaryHttpRequest::IndeterminateLengthDecoder> decoder =
-      BinaryHttpRequest::IndeterminateLengthDecoder::Create(&handler);
-  QUICHE_EXPECT_OK(decoder);
+  BinaryHttpRequest::IndeterminateLengthDecoder decoder(&handler);
   std::string request_bytes;
   EXPECT_TRUE(absl::HexStringToBytes(
       absl::StrCat(
@@ -1935,7 +1903,7 @@
           k4ByteContentTerminator),
       &request_bytes));
 
-  QUICHE_EXPECT_OK(decoder->Decode(request_bytes, /*end_stream=*/true));
+  QUICHE_EXPECT_OK(decoder.Decode(request_bytes, /*end_stream=*/true));
   auto message_data = handler.GetMessageData();
   EXPECT_TRUE(message_data.body_chunks_done_);
   std::vector<std::string> expected_body_chunks = {"chunk1", "chunk2",
@@ -1946,9 +1914,7 @@
 
 TEST(IndeterminateLengthDecoder, TruncatedTrailersSplitEndStream) {
   RequestMessageSectionTestHandler handler;
-  absl::StatusOr<BinaryHttpRequest::IndeterminateLengthDecoder> decoder =
-      BinaryHttpRequest::IndeterminateLengthDecoder::Create(&handler);
-  QUICHE_EXPECT_OK(decoder);
+  BinaryHttpRequest::IndeterminateLengthDecoder decoder(&handler);
   std::string request_bytes;
   EXPECT_TRUE(absl::HexStringToBytes(
       absl::StrCat(
@@ -1958,9 +1924,9 @@
           k4ByteContentTerminator),
       &request_bytes));
 
-  QUICHE_EXPECT_OK(decoder->Decode(request_bytes, /*end_stream=*/false));
+  QUICHE_EXPECT_OK(decoder.Decode(request_bytes, /*end_stream=*/false));
   // Send `end_stream` with no data.
-  QUICHE_EXPECT_OK(decoder->Decode("", /*end_stream=*/true));
+  QUICHE_EXPECT_OK(decoder.Decode("", /*end_stream=*/true));
   auto message_data = handler.GetMessageData();
   EXPECT_TRUE(message_data.body_chunks_done_);
   std::vector<std::string> expected_body_chunks = {"chunk1", "chunk2",
@@ -1977,11 +1943,9 @@
           kIndeterminateLengthEncodedRequestHeaders, k8ByteContentTerminator),
       &request_bytes));
   RequestMessageSectionTestHandler handler;
-  absl::StatusOr<BinaryHttpRequest::IndeterminateLengthDecoder> decoder =
-      BinaryHttpRequest::IndeterminateLengthDecoder::Create(&handler);
-  QUICHE_EXPECT_OK(decoder);
-  QUICHE_EXPECT_OK(decoder->Decode(request_bytes, /*end_stream=*/true));
-  absl::Status status = decoder->Decode(request_bytes, /*end_stream=*/false);
+  BinaryHttpRequest::IndeterminateLengthDecoder decoder(&handler);
+  QUICHE_EXPECT_OK(decoder.Decode(request_bytes, /*end_stream=*/true));
+  absl::Status status = decoder.Decode(request_bytes, /*end_stream=*/false);
   EXPECT_THAT(status, test::StatusIs(kInternal));
 }
 
@@ -1995,12 +1959,10 @@
 TEST_P(InvalidEndStreamTest, InvalidEndStreamError) {
   const InvalidEndStreamTestCase& test_case = GetParam();
   RequestMessageSectionTestHandler handler;
-  absl::StatusOr<BinaryHttpRequest::IndeterminateLengthDecoder> decoder =
-      BinaryHttpRequest::IndeterminateLengthDecoder::Create(&handler);
-  QUICHE_EXPECT_OK(decoder);
+  BinaryHttpRequest::IndeterminateLengthDecoder decoder(&handler);
   std::string request_bytes;
   EXPECT_TRUE(absl::HexStringToBytes(test_case.request, &request_bytes));
-  absl::Status status = decoder->Decode(request_bytes, /*end_stream=*/true);
+  absl::Status status = decoder.Decode(request_bytes, /*end_stream=*/true);
   EXPECT_THAT(status, test::StatusIs(kInvalidArgument));
 }