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

Unified Diff: net/socket/socket_test_util.cc

Issue 389007: After draining the body of a 401/407 response, verify that... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Improve comments Created 11 years, 1 month 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/socket/socket_test_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/socket_test_util.cc
===================================================================
--- net/socket/socket_test_util.cc (revision 31823)
+++ net/socket/socket_test_util.cc (working copy)
@@ -66,8 +66,9 @@
: addresses_(addresses),
data_(data),
read_offset_(0),
- read_data_(true, net::ERR_UNEXPECTED),
+ read_data_(false, net::ERR_UNEXPECTED),
need_read_data_(true),
+ peer_closed_connection_(false),
pending_buf_(NULL),
pending_buf_len_(0),
pending_callback_(NULL) {
@@ -87,9 +88,13 @@
return data_->connect_data().result;
}
+bool MockTCPClientSocket::IsConnected() const {
+ return connected_ && !peer_closed_connection_;
+}
+
int MockTCPClientSocket::Read(net::IOBuffer* buf, int buf_len,
net::CompletionCallback* callback) {
- if (!IsConnected())
+ if (!connected_)
return net::ERR_UNEXPECTED;
// If the buffer is already in use, a read is already in progress!
@@ -102,6 +107,12 @@
if (need_read_data_) {
read_data_ = data_->GetNextRead();
+ if (read_data_.result == ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ) {
+ // This MockRead is just a marker to instruct us to set
+ // peer_closed_connection_. Skip it and get the next one.
+ read_data_ = data_->GetNextRead();
+ peer_closed_connection_ = true;
+ }
// ERR_IO_PENDING means that the SocketDataProvider is taking responsibility
// to complete the async IO manually later (via OnReadComplete).
if (read_data_.result == ERR_IO_PENDING) {
@@ -119,7 +130,7 @@
DCHECK(buf);
DCHECK_GT(buf_len, 0);
- if (!IsConnected())
+ if (!connected_)
return net::ERR_UNEXPECTED;
std::string data(buf->data(), buf_len);
@@ -304,7 +315,7 @@
MockRead DynamicSocketDataProvider::GetNextRead() {
if (reads_.empty())
- return MockRead(true, ERR_UNEXPECTED);
+ return MockRead(false, ERR_UNEXPECTED);
MockRead result = reads_.front();
if (short_read_limit_ == 0 || result.data_len <= short_read_limit_) {
reads_.pop_front();
« no previous file with comments | « net/socket/socket_test_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698