Removes Http2VisitorInterface methods OnReadyToSendDataForStream() and OnReadyToSendMetadataForStream().
The DataSource and MetadataSource interfaces provide other ways for users to send data and metadata via the adapter classes.
PiperOrigin-RevId: 389950507
diff --git a/http2/adapter/callback_visitor.cc b/http2/adapter/callback_visitor.cc
index 0e666cb..7849574 100644
--- a/http2/adapter/callback_visitor.cc
+++ b/http2/adapter/callback_visitor.cc
@@ -349,14 +349,6 @@
return 0;
}
-void CallbackVisitor::OnReadyToSendDataForStream(Http2StreamId /*stream_id*/,
- char* /*destination_buffer*/,
- size_t /*length*/,
- int64_t* /*written*/,
- bool* /*end_stream*/) {
- QUICHE_LOG(DFATAL) << "Not implemented";
-}
-
bool CallbackVisitor::OnInvalidFrame(Http2StreamId stream_id, int error_code) {
QUICHE_VLOG(1) << "OnInvalidFrame(" << stream_id << ", " << error_code << ")";
QUICHE_DCHECK_EQ(stream_id, current_frame_.hd.stream_id);
@@ -367,23 +359,6 @@
return true;
}
-void CallbackVisitor::OnReadyToSendMetadataForStream(Http2StreamId stream_id,
- char* buffer,
- size_t length,
- int64_t* written) {
- if (callbacks_->pack_extension_callback) {
- nghttp2_frame frame;
- frame.hd.type = kMetadataFrameType;
- frame.hd.stream_id = stream_id;
- frame.hd.flags = 0;
- frame.hd.length = 0;
- *written = callbacks_->pack_extension_callback(nullptr, ToUint8Ptr(buffer),
- length, &frame, user_data_);
- }
- QUICHE_VLOG(1) << "OnReadyToSendMetadataForStream(stream_id=" << stream_id
- << ", length=" << length << ", written=" << *written << ")";
-}
-
void CallbackVisitor::OnBeginMetadataForStream(Http2StreamId stream_id,
size_t payload_length) {
QUICHE_VLOG(1) << "OnBeginMetadataForStream(stream_id=" << stream_id
diff --git a/http2/adapter/callback_visitor.h b/http2/adapter/callback_visitor.h
index 6d40277..f33df0e 100644
--- a/http2/adapter/callback_visitor.h
+++ b/http2/adapter/callback_visitor.h
@@ -60,12 +60,7 @@
size_t length, uint8_t flags) override;
int OnFrameSent(uint8_t frame_type, Http2StreamId stream_id, size_t length,
uint8_t flags, uint32_t error_code) override;
- void OnReadyToSendDataForStream(Http2StreamId stream_id,
- char* destination_buffer, size_t length,
- int64_t* written, bool* end_stream) override;
bool OnInvalidFrame(Http2StreamId stream_id, int error_code) override;
- void OnReadyToSendMetadataForStream(Http2StreamId stream_id, char* buffer,
- size_t length, int64_t* written) override;
void OnBeginMetadataForStream(Http2StreamId stream_id,
size_t payload_length) override;
bool OnMetadataForStream(Http2StreamId stream_id,
diff --git a/http2/adapter/callback_visitor_test.cc b/http2/adapter/callback_visitor_test.cc
index 10d6c90..eaf3f98 100644
--- a/http2/adapter/callback_visitor_test.cc
+++ b/http2/adapter/callback_visitor_test.cc
@@ -155,28 +155,6 @@
EXPECT_CALL(callbacks, OnStreamClose(5, NGHTTP2_REFUSED_STREAM));
visitor.OnCloseStream(5, Http2ErrorCode::REFUSED_STREAM);
-
- // Metadata events
- constexpr size_t kMetadataBufferSize = 256;
- char metadata_dest[kMetadataBufferSize];
- int64_t written = 0;
-
- const absl::string_view kExampleFrame = "This is supposed to be metadata.";
- EXPECT_CALL(
- callbacks,
- OnPackExtension(_, kMetadataBufferSize,
- Field(&nghttp2_frame::hd,
- HasFrameHeaderRef(7, kMetadataFrameType, _))))
- .WillOnce(testing::Invoke(
- [kExampleFrame](uint8_t* buf, size_t /*len*/,
- const nghttp2_frame* /*frame*/) -> int64_t {
- std::memcpy(buf, kExampleFrame.data(), kExampleFrame.size());
- return kExampleFrame.size();
- }));
- visitor.OnReadyToSendMetadataForStream(7, metadata_dest, kMetadataBufferSize,
- &written);
- ASSERT_EQ(written, kExampleFrame.size());
- EXPECT_EQ(absl::string_view(metadata_dest, written), kExampleFrame);
}
TEST(ClientCallbackVisitorUnitTest, HeadersWithContinuation) {
@@ -311,28 +289,6 @@
EXPECT_CALL(callbacks, OnStreamClose(3, NGHTTP2_INTERNAL_ERROR));
visitor.OnCloseStream(3, Http2ErrorCode::INTERNAL_ERROR);
-
- // Metadata events
- constexpr size_t kMetadataBufferSize = 256;
- char metadata_dest[kMetadataBufferSize];
- int64_t written = 0;
-
- const absl::string_view kExampleFrame = "This is supposed to be metadata.";
- EXPECT_CALL(
- callbacks,
- OnPackExtension(_, kMetadataBufferSize,
- Field(&nghttp2_frame::hd,
- HasFrameHeaderRef(5, kMetadataFrameType, _))))
- .WillOnce(testing::Invoke(
- [kExampleFrame](uint8_t* buf, size_t /*len*/,
- const nghttp2_frame* /*frame*/) -> int64_t {
- std::memcpy(buf, kExampleFrame.data(), kExampleFrame.size());
- return kExampleFrame.size();
- }));
- visitor.OnReadyToSendMetadataForStream(5, metadata_dest, kMetadataBufferSize,
- &written);
- ASSERT_EQ(written, kExampleFrame.size());
- EXPECT_EQ(absl::string_view(metadata_dest, written), kExampleFrame);
}
} // namespace
diff --git a/http2/adapter/http2_visitor_interface.h b/http2/adapter/http2_visitor_interface.h
index 2de5e5b..a95f70a 100644
--- a/http2/adapter/http2_visitor_interface.h
+++ b/http2/adapter/http2_visitor_interface.h
@@ -164,30 +164,12 @@
size_t length, uint8_t flags,
uint32_t error_code) = 0;
- // Called when the connection is ready to send data for a stream. The
- // implementation should write at most |length| bytes of the data payload to
- // the |destination_buffer| and set |end_stream| to true IFF there will be no
- // more data sent on this stream. Sets |written| to the number of bytes
- // written to the |destination_buffer| or a negative value if an error occurs.
- virtual void OnReadyToSendDataForStream(Http2StreamId stream_id,
- char* destination_buffer,
- size_t length, int64_t* written,
- bool* end_stream) = 0;
-
// Called when the connection receives an invalid frame. |error_code| is a
// negative integer error code generated by the library. A return value of
// false will result in the connection entering an error state, with no
// further frame processing possible.
virtual bool OnInvalidFrame(Http2StreamId stream_id, int error_code) = 0;
- // Called when the connection is ready to write metadata for |stream_id| to
- // the wire. The implementation should write at most |length| bytes of the
- // serialized metadata payload to the |buffer| and set |written| to the number
- // of bytes written or a negative value if there was an error.
- virtual void OnReadyToSendMetadataForStream(Http2StreamId stream_id,
- char* buffer, size_t length,
- int64_t* written) = 0;
-
// Called when the connection receives the beginning of a METADATA frame
// (which may itself be the middle of a logical metadata block). The metadata
// payload will be provided via subsequent calls to OnMetadataForStream().
diff --git a/http2/adapter/mock_http2_visitor.h b/http2/adapter/mock_http2_visitor.h
index 568549b..a489270 100644
--- a/http2/adapter/mock_http2_visitor.h
+++ b/http2/adapter/mock_http2_visitor.h
@@ -110,16 +110,6 @@
MOCK_METHOD(bool, OnInvalidFrame, (Http2StreamId stream_id, int error_code),
(override));
- MOCK_METHOD(void, OnReadyToSendDataForStream,
- (Http2StreamId stream_id, char* destination_buffer, size_t length,
- int64_t* written, bool* end_stream),
- (override));
-
- MOCK_METHOD(void, OnReadyToSendMetadataForStream,
- (Http2StreamId stream_id, char* buffer, size_t length,
- int64_t* written),
- (override));
-
MOCK_METHOD(void,
OnBeginMetadataForStream,
(Http2StreamId stream_id, size_t payload_length),
diff --git a/http2/adapter/nghttp2_callbacks.cc b/http2/adapter/nghttp2_callbacks.cc
index f4b738e..6cfdbcb 100644
--- a/http2/adapter/nghttp2_callbacks.cc
+++ b/http2/adapter/nghttp2_callbacks.cc
@@ -253,15 +253,12 @@
return 0;
}
-ssize_t OnPackExtensionCallback(nghttp2_session* /*session*/, uint8_t* buf,
- size_t len, const nghttp2_frame* frame,
+ssize_t OnPackExtensionCallback(nghttp2_session* /*session*/, uint8_t* /*buf*/,
+ size_t /*len*/, const nghttp2_frame* /*frame*/,
void* user_data) {
QUICHE_CHECK_NE(user_data, nullptr);
- auto* visitor = static_cast<Http2VisitorInterface*>(user_data);
- int64_t written = 0;
- visitor->OnReadyToSendMetadataForStream(
- frame->hd.stream_id, reinterpret_cast<char*>(buf), len, &written);
- return written;
+ QUICHE_LOG(DFATAL) << "Not implemented";
+ return NGHTTP2_ERR_CALLBACK_FAILURE;
}
int OnError(nghttp2_session* /*session*/, int /*lib_error_code*/,
diff --git a/http2/adapter/recording_http2_visitor.cc b/http2/adapter/recording_http2_visitor.cc
index 71083c5..9407ce0 100644
--- a/http2/adapter/recording_http2_visitor.cc
+++ b/http2/adapter/recording_http2_visitor.cc
@@ -141,24 +141,6 @@
return true;
}
-void RecordingHttp2Visitor::OnReadyToSendDataForStream(
- Http2StreamId stream_id, char* /*destination_buffer*/, size_t length,
- int64_t* /*written*/, bool* /*end_stream*/) {
- // TODO(b/181586191): Revisit this. The visitor is expected to write to the
- // |destination_buffer| and set the other pointer values appropriately.
- events_.push_back(
- absl::StrFormat("OnReadyToSendDataForStream %d %d", stream_id, length));
-}
-
-void RecordingHttp2Visitor::OnReadyToSendMetadataForStream(
- Http2StreamId stream_id, char* /*buffer*/, size_t length,
- int64_t* /*written*/) {
- // TODO(b/181586191): Revisit this. The visitor is expected to write to the
- // |buffer| and set *written appropriately.
- events_.push_back(absl::StrFormat("OnReadyToSendMetadataForStream %d %d",
- stream_id, length));
-}
-
void RecordingHttp2Visitor::OnBeginMetadataForStream(Http2StreamId stream_id,
size_t payload_length) {
events_.push_back(absl::StrFormat("OnBeginMetadataForStream %d %d", stream_id,
diff --git a/http2/adapter/recording_http2_visitor.h b/http2/adapter/recording_http2_visitor.h
index fb1532a..a443905 100644
--- a/http2/adapter/recording_http2_visitor.h
+++ b/http2/adapter/recording_http2_visitor.h
@@ -59,11 +59,6 @@
int OnFrameSent(uint8_t frame_type, Http2StreamId stream_id, size_t length,
uint8_t flags, uint32_t error_code) override;
bool OnInvalidFrame(Http2StreamId stream_id, int error_code) override;
- void OnReadyToSendDataForStream(Http2StreamId stream_id,
- char* destination_buffer, size_t length,
- int64_t* written, bool* end_stream) override;
- void OnReadyToSendMetadataForStream(Http2StreamId stream_id, char* buffer,
- size_t length, int64_t* written) override;
void OnBeginMetadataForStream(Http2StreamId stream_id,
size_t payload_length) override;
bool OnMetadataForStream(Http2StreamId stream_id,
diff --git a/http2/adapter/recording_http2_visitor_test.cc b/http2/adapter/recording_http2_visitor_test.cc
index 8f278d7..6763244 100644
--- a/http2/adapter/recording_http2_visitor_test.cc
+++ b/http2/adapter/recording_http2_visitor_test.cc
@@ -85,11 +85,6 @@
visitor->OnPushPromiseForStream(stream_id, another_stream_id);
visitor->OnGoAway(stream_id, error_code, some_string);
visitor->OnWindowUpdate(stream_id, some_int);
- visitor->OnReadyToSendDataForStream(
- stream_id, /*destination_buffer=*/nullptr, length, /*written=*/nullptr,
- /*end_stream=*/nullptr);
- visitor->OnReadyToSendMetadataForStream(stream_id, /*buffer=*/nullptr,
- length, /*written=*/nullptr);
visitor->OnBeginMetadataForStream(stream_id, length);
visitor->OnMetadataForStream(stream_id, some_string);
visitor->OnMetadataForStream(stream_id, another_string);