Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(327)

Unified Diff: net/quic/quic_http_stream_test.cc

Issue 2163883004: Do not invoke QuicHttpStream::DoCallback when in DoLoop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a test which crashes with the exact call stack without the patch Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« net/quic/quic_http_stream.cc ('K') | « net/quic/quic_http_stream.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_http_stream_test.cc
diff --git a/net/quic/quic_http_stream_test.cc b/net/quic/quic_http_stream_test.cc
index 8f76a7fd80ec766ec224dd582ad7bdf89f9eaee4..11ae2cb63b6f3ffa031eb91ba4648970792fec4c 100644
--- a/net/quic/quic_http_stream_test.cc
+++ b/net/quic/quic_http_stream_test.cc
@@ -144,6 +144,26 @@ class ReadErrorUploadDataStream : public UploadDataStream {
DISALLOW_COPY_AND_ASSIGN(ReadErrorUploadDataStream);
};
+// A Callback that deletes the QuicHttpStream.
+class DeleteStreamCallback : public TestCompletionCallbackBase {
+ public:
+ DeleteStreamCallback(std::unique_ptr<QuicHttpStream> stream)
+ : stream_(std::move(stream)),
+ callback_(base::Bind(&DeleteStreamCallback::DeleteStream,
+ base::Unretained(this))) {}
+
+ const CompletionCallback& callback() const { return callback_; }
+
+ private:
+ void DeleteStream(int result) {
+ stream_.reset();
+ SetResult(result);
+ }
+
+ std::unique_ptr<QuicHttpStream> stream_;
+ CompletionCallback callback_;
+};
+
} // namespace
class QuicHttpStreamPeer {
@@ -1312,6 +1332,41 @@ TEST_P(QuicHttpStreamTest, CheckPriorityWithNoDelegate) {
EXPECT_EQ(0, stream_->GetTotalReceivedBytes());
}
+TEST_P(QuicHttpStreamTest, SessionClosedDuringDoLoop) {
+ SetRequest("POST", "/", DEFAULT_PRIORITY);
+ size_t spdy_request_headers_frame_length;
+ AddWrite(ConstructRequestHeadersPacket(1, !kFin, DEFAULT_PRIORITY,
+ &spdy_request_headers_frame_length));
+ AddWrite(
+ ConstructClientDataPacket(2, kIncludeVersion, !kFin, 0, kUploadData));
+ // Second data write will result in a synchronous failure which will close
+ // the session.
+ AddWrite(SYNCHRONOUS, ERR_FAILED);
+ Initialize();
+
+ ChunkedUploadDataStream upload_data_stream(0);
+
+ request_.method = "POST";
+ request_.url = GURL("http://www.example.org/");
+ request_.upload_data_stream = &upload_data_stream;
+ ASSERT_EQ(OK, request_.upload_data_stream->Init(
+ TestCompletionCallback().callback()));
+
+ size_t chunk_size = strlen(kUploadData);
+ upload_data_stream.AppendData(kUploadData, chunk_size, false);
+ ASSERT_EQ(OK,
+ stream_->InitializeStream(&request_, DEFAULT_PRIORITY,
+ net_log_.bound(), callback_.callback()));
+ QuicHttpStream* stream = stream_.get();
+ DeleteStreamCallback delete_stream_callback(std::move(stream_));
+ // SendRequest() completes asynchronously after the final chunk is added.
+ ASSERT_EQ(ERR_IO_PENDING,
+ stream->SendRequest(headers_, &response_, callback_.callback()));
+ upload_data_stream.AppendData(kUploadData, chunk_size, true);
+ int rv = callback_.WaitForResult();
+ EXPECT_EQ(ERR_QUIC_PROTOCOL_ERROR, rv);
+}
+
TEST_P(QuicHttpStreamTest, SessionClosedBeforeSendHeadersComplete) {
SetRequest("POST", "/", DEFAULT_PRIORITY);
AddWrite(SYNCHRONOUS, ERR_FAILED);
« net/quic/quic_http_stream.cc ('K') | « net/quic/quic_http_stream.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698