summaryrefslogtreecommitdiffstats
path: root/net/socket/socket_test_util.cc
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-05 22:39:42 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-05 22:39:42 +0000
commitd911f1b926178d0642e0bb07bb42c6623d1bbf73 (patch)
tree33c2eb6b9769d98eee500825ebc4e550e64e3a4f /net/socket/socket_test_util.cc
parentf40b49e10c5ad2a4aa360a20e467442fca29e315 (diff)
downloadchromium_src-d911f1b926178d0642e0bb07bb42c6623d1bbf73.zip
chromium_src-d911f1b926178d0642e0bb07bb42c6623d1bbf73.tar.gz
chromium_src-d911f1b926178d0642e0bb07bb42c6623d1bbf73.tar.bz2
Get tests working for Alternate-Protocol and proxies.
Fixed some bugs along the way. Review URL: http://codereview.chromium.org/1947004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46509 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket/socket_test_util.cc')
-rw-r--r--net/socket/socket_test_util.cc20
1 files changed, 15 insertions, 5 deletions
diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc
index 399a34c..99a200f 100644
--- a/net/socket/socket_test_util.cc
+++ b/net/socket/socket_test_util.cc
@@ -531,7 +531,7 @@ OrderedSocketData::OrderedSocketData(
MockRead* reads, size_t reads_count, MockWrite* writes, size_t writes_count)
: StaticSocketDataProvider(reads, reads_count, writes, writes_count),
sequence_number_(0), loop_stop_stage_(0), callback_(NULL),
- ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)) {
+ blocked_(false), ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)) {
}
OrderedSocketData::OrderedSocketData(
@@ -540,11 +540,13 @@ OrderedSocketData::OrderedSocketData(
MockWrite* writes, size_t writes_count)
: StaticSocketDataProvider(reads, reads_count, writes, writes_count),
sequence_number_(0), loop_stop_stage_(0), callback_(NULL),
- ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)) {
+ blocked_(false), ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)) {
set_connect_data(connect);
}
MockRead OrderedSocketData::GetNextRead() {
+ factory_.RevokeAll();
+ blocked_ = false;
const MockRead& next_read = StaticSocketDataProvider::PeekRead();
if (next_read.sequence_number & MockRead::STOPLOOP)
EndLoop();
@@ -559,6 +561,7 @@ MockRead OrderedSocketData::GetNextRead() {
<< ": I/O Pending";
MockRead result = MockRead(true, ERR_IO_PENDING);
DumpMockRead(result);
+ blocked_ = true;
return result;
}
@@ -567,9 +570,16 @@ MockWriteResult OrderedSocketData::OnWrite(const std::string& data) {
<< ": Write " << write_index();
DumpMockRead(PeekWrite());
++sequence_number_;
- MessageLoop::current()->PostDelayedTask(
- FROM_HERE,
- factory_.NewRunnableMethod(&OrderedSocketData::CompleteRead), 100);
+ if (blocked_) {
+ // TODO(willchan): This 100ms delay seems to work around some weirdness. We
+ // should probably fix the weirdness. One example is in SpdyStream,
+ // DoSendRequest() will return ERR_IO_PENDING, and there's a race. If the
+ // SYN_REPLY causes OnResponseReceived() to get called before
+ // SpdyStream::ReadResponseHeaders() is called, we hit a NOTREACHED().
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ factory_.NewRunnableMethod(&OrderedSocketData::CompleteRead), 100);
+ }
return StaticSocketDataProvider::OnWrite(data);
}