During a CL review (crrev.com/1723373002/), it was discussed that when stream_->IsDoneReading() is true, we might only need to call OnFinRead().
Specifically, the stream_->SetDelegate(nullptr) and ResetStream() should be removed. The reason is that stream_->OnFinRead() will call QuicHttpStream::OnClose() if both read and write sides are closed. If we null out the delegate before calling OnFinRead(), we will never receive the OnClose() callback. Additionally, OnClose() will reset the stream, so there is no need to call ResetStream() here. I don't think this will cause a bug right now, since QuicHttpStream only supports request/response, but resetting stream here isn't right if QuicHttpStream supports bidirectional streaming in the future.
int QuicHttpStream::ReadAvailableData(IOBuffer* buf, int buf_len) {
int rv = stream_->Read(buf, buf_len);
if (stream_->IsDoneReading()) {
stream_->SetDelegate(nullptr); // <-- should be removed??
stream_->OnFinRead();
ResetStream(); // <-- should be removed??
}
return rv;
}