diff options
author | mmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-08 00:21:57 +0000 |
---|---|---|
committer | mmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-08 00:21:57 +0000 |
commit | 74a1a246e1beb24d4bde15859e8dafe40d872291 (patch) | |
tree | cc9d0b91f4fcfe9ac34b10858832422bf6aac591 /net | |
parent | 101517a702f370bbe61e3420e93d93506e16c060 (diff) | |
download | chromium_src-74a1a246e1beb24d4bde15859e8dafe40d872291.zip chromium_src-74a1a246e1beb24d4bde15859e8dafe40d872291.tar.gz chromium_src-74a1a246e1beb24d4bde15859e8dafe40d872291.tar.bz2 |
Http Pipelinining: Make unit tests more friendly to greedily
reading from sockets.
In particular, prevent the parser from reading beyond all ReadData in
HttpPipelinedConnectionImplTest.ConnectionSuddenlyClosedAfterResponse,
and fix a test that was trying to reuse a connection when
an earlier stream failed on it.
BUG=166915
Review URL: https://codereview.chromium.org/11795003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175423 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/http/http_pipelined_connection_impl_unittest.cc | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/net/http/http_pipelined_connection_impl_unittest.cc b/net/http/http_pipelined_connection_impl_unittest.cc index d807a6b..bbb6001 100644 --- a/net/http/http_pipelined_connection_impl_unittest.cc +++ b/net/http/http_pipelined_connection_impl_unittest.cc @@ -574,6 +574,8 @@ TEST_F(HttpPipelinedConnectionImplTest, ConnectionSuddenlyClosedAfterResponse) { MockRead reads[] = { MockRead(SYNCHRONOUS, 3, "HTTP/1.1 200 OK\r\n\r\n"), MockRead(SYNCHRONOUS, 4, "ok.html"), + MockRead(ASYNC, OK, 6), // Connection closed message. Not read before the + // ERR_SOCKET_NOT_CONNECTED. }; Initialize(reads, arraysize(reads), writes, arraysize(writes)); @@ -940,20 +942,25 @@ TEST_F(HttpPipelinedConnectionImplTest, CloseCalledBeforeReadCallback) { class StreamDeleter { public: - StreamDeleter(HttpStream* stream) : - stream_(stream), - ALLOW_THIS_IN_INITIALIZER_LIST(callback_( - base::Bind(&StreamDeleter::OnIOComplete, base::Unretained(this)))) { + StreamDeleter(HttpStream* stream) + : stream_(stream), + ALLOW_THIS_IN_INITIALIZER_LIST(callback_( + base::Bind(&StreamDeleter::OnIOComplete, base::Unretained(this)))) { + } + + ~StreamDeleter() { + EXPECT_FALSE(stream_); } const CompletionCallback& callback() { return callback_; } private: void OnIOComplete(int result) { - delete stream_; + stream_->Close(true); + stream_.reset(); } - HttpStream* stream_; + scoped_ptr<HttpStream> stream_; CompletionCallback callback_; }; |