diff options
author | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-23 23:28:42 +0000 |
---|---|---|
committer | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-23 23:28:42 +0000 |
commit | 73dd3fa96e82473cfc4c81494fb8a7787b553a1f (patch) | |
tree | 02cd98a50e22ce3808cf8bf5768cb196cef4960e | |
parent | c17d8d4f525271e66d298e05c494065460a1e468 (diff) | |
download | chromium_src-73dd3fa96e82473cfc4c81494fb8a7787b553a1f.zip chromium_src-73dd3fa96e82473cfc4c81494fb8a7787b553a1f.tar.gz chromium_src-73dd3fa96e82473cfc4c81494fb8a7787b553a1f.tar.bz2 |
Reland 32807, which was incorrectly reverted.
The async notification via OnReadComplete was still posting
a callback through this message loop. This makes it difficult
to write tests, as callbacks already scheduled will go in
front of the OnReadComplete(). Treat the notifications through
OnReadComplete as synchronous always.
This doesn't effect existing tests, but makes my new tests
possible.
BUG=none
TEST=this is the test!
Review URL: http://codereview.chromium.org/436014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32886 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | net/socket/socket_test_util.cc | 10 | ||||
-rw-r--r-- | net/socket/socket_test_util.h | 2 |
2 files changed, 9 insertions, 3 deletions
diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc index ef10f76..18ece28 100644 --- a/net/socket/socket_test_util.cc +++ b/net/socket/socket_test_util.cc @@ -150,13 +150,17 @@ void MockTCPClientSocket::OnReadComplete(const MockRead& data) { DCHECK_NE(ERR_IO_PENDING, data.result); // Since we've been waiting for data, need_read_data_ should be true. DCHECK(need_read_data_); - // In order to fire the callback, this IO needs to be marked as async. - DCHECK(data.async); read_data_ = data; need_read_data_ = false; - CompleteRead(); + // The caller is simulating that this IO completes right now. Don't + // let CompleteRead() schedule a callback. + read_data_.async = false; + + net::CompletionCallback* callback = pending_callback_; + int rv = CompleteRead(); + RunCallback(callback, rv); } int MockTCPClientSocket::CompleteRead() { diff --git a/net/socket/socket_test_util.h b/net/socket/socket_test_util.h index d16dcb4..96c5ea7 100644 --- a/net/socket/socket_test_util.h +++ b/net/socket/socket_test_util.h @@ -287,6 +287,8 @@ class MockClientSocket : public net::SSLClientSocket { // If an async IO is pending because the SocketDataProvider returned // ERR_IO_PENDING, then the MockClientSocket waits until this OnReadComplete // is called to complete the asynchronous read operation. + // data.async is ignored, and this read is completed synchronously as + // part of this call. virtual void OnReadComplete(const MockRead& data) = 0; protected: |