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

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: 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
« no previous file with comments | « net/http/http_pipelined_connection_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f6720f4056e86a5b2d2bedc075ccfe4843e3c00e 100644
--- a/net/http/http_pipelined_connection_impl_unittest.cc
+++ b/net/http/http_pipelined_connection_impl_unittest.cc
@@ -1025,6 +1025,57 @@ 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"));
+
+ TestOldCompletionCallback close_callback;
+ HttpRequestHeaders headers;
+ HttpResponseInfo response;
+ EXPECT_EQ(ERR_IO_PENDING, close_stream->SendRequest(
+ headers, NULL, &response, &close_callback));
+
+ data_->RunFor(1);
+ EXPECT_FALSE(close_callback.have_result());
+
+ close_stream->Close(false);
mmenke 2011/10/28 00:54:09 Add "MessageLoop::current()->RunAllPending();" to
+}
+
+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_));
+
+ TestOldCompletionCallback close_callback;
+ EXPECT_EQ(ERR_IO_PENDING,
+ close_stream->ReadResponseHeaders(&close_callback));
+
+ data_->RunFor(1);
+ EXPECT_FALSE(close_callback.have_result());
+
+ close_stream->Close(false);
+}
+
TEST_F(HttpPipelinedConnectionImplTest, OnPipelineHasCapacity) {
MockWrite writes[] = {
MockWrite(false, 0, "GET /ok.html HTTP/1.1\r\n\r\n"),
« no previous file with comments | « 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