Skip to content

Commit

Permalink
Http Pipelinining: Make unit tests more friendly to greedily
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mmenke@chromium.org committed Jan 8, 2013
1 parent 101517a commit 74a1a24
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions net/http/http_pipelined_connection_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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_;
};

Expand Down

0 comments on commit 74a1a24

Please sign in to comment.