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

Unified Diff: net/http/http_pipelined_connection_impl_unittest.cc

Issue 8414010: Fix pipelining crash on canceled user callbacks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Manually destruct Created 9 years, 2 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
Index: net/http/http_pipelined_connection_impl_unittest.cc
diff --git a/net/http/http_pipelined_connection_impl_unittest.cc b/net/http/http_pipelined_connection_impl_unittest.cc
index 420d8dc401ba8096c78082ac6590c8259cbc24cc..a95549430ca21d0be72bf5b870b3e4f19871aa3b 100644
--- a/net/http/http_pipelined_connection_impl_unittest.cc
+++ b/net/http/http_pipelined_connection_impl_unittest.cc
@@ -1025,6 +1025,67 @@ TEST_F(HttpPipelinedConnectionImplTest, CloseOtherDuringReadCallback) {
data_->RunFor(1);
}
+TEST_F(HttpPipelinedConnectionImplTest, CloseBeforeSendCallbackRuns) {
+ MockWrite writes[] = {
+ MockWrite(true, 0, "GET /close.html HTTP/1.1\r\n\r\n"),
+ MockWrite(true, 1, "GET /dummy.html HTTP/1.1\r\n\r\n"),
+ };
+ Initialize(NULL, 0, writes, arraysize(writes));
+
+ scoped_ptr<HttpStream> close_stream(NewTestStream("close.html"));
+ scoped_ptr<HttpStream> dummy_stream(NewTestStream("dummy.html"));
+
+ scoped_ptr<TestOldCompletionCallback> close_callback(
+ new TestOldCompletionCallback);
+ HttpRequestHeaders headers;
+ HttpResponseInfo response;
+ EXPECT_EQ(ERR_IO_PENDING, close_stream->SendRequest(
+ headers, NULL, &response, close_callback.get()));
+
+ data_->RunFor(1);
+ EXPECT_FALSE(close_callback->have_result());
+
+ close_stream->Close(false);
+ close_stream.reset();
+ close_callback.reset();
+
+ MessageLoop::current()->RunAllPending();
+}
+
+TEST_F(HttpPipelinedConnectionImplTest, CloseBeforeReadCallbackRuns) {
+ MockWrite writes[] = {
+ MockWrite(false, 0, "GET /close.html HTTP/1.1\r\n\r\n"),
+ MockWrite(false, 3, "GET /dummy.html HTTP/1.1\r\n\r\n"),
+ };
+ MockRead reads[] = {
+ MockRead(false, 1, "HTTP/1.1 200 OK\r\n"),
+ MockRead(true, 2, "Content-Length: 7\r\n\r\n"),
+ };
+ Initialize(reads, arraysize(reads), writes, arraysize(writes));
+
+ scoped_ptr<HttpStream> close_stream(NewTestStream("close.html"));
+ scoped_ptr<HttpStream> dummy_stream(NewTestStream("dummy.html"));
+
+ HttpRequestHeaders headers;
+ HttpResponseInfo response;
+ EXPECT_EQ(OK,
+ close_stream->SendRequest(headers, NULL, &response, &callback_));
+
+ scoped_ptr<TestOldCompletionCallback> close_callback(
+ new TestOldCompletionCallback);
+ EXPECT_EQ(ERR_IO_PENDING,
+ close_stream->ReadResponseHeaders(close_callback.get()));
+
+ data_->RunFor(1);
+ EXPECT_FALSE(close_callback->have_result());
+
+ close_stream->Close(false);
+ close_stream.reset();
+ close_callback.reset();
+
+ MessageLoop::current()->RunAllPending();
+}
+
TEST_F(HttpPipelinedConnectionImplTest, OnPipelineHasCapacity) {
MockWrite writes[] = {
MockWrite(false, 0, "GET /ok.html HTTP/1.1\r\n\r\n"),
« net/http/http_pipelined_connection_impl.cc ('K') | « net/http/http_pipelined_connection_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698