summaryrefslogtreecommitdiffstats
path: root/net/socket
diff options
context:
space:
mode:
authormbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-09 22:52:33 +0000
committermbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-09 22:52:33 +0000
commit4f552ba2fe6734e252a6ac06f00973f8fa31efb2 (patch)
treecb1ea7fac59ba574fc788c2e6529123be8006933 /net/socket
parentf1b11d3fd8f23de89265a6e101f7190526c5861a (diff)
downloadchromium_src-4f552ba2fe6734e252a6ac06f00973f8fa31efb2.zip
chromium_src-4f552ba2fe6734e252a6ac06f00973f8fa31efb2.tar.gz
chromium_src-4f552ba2fe6734e252a6ac06f00973f8fa31efb2.tar.bz2
Make our Mock Sockets capable of running full duplex.
BUG=none TEST=none Review URL: http://codereview.chromium.org/273013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28622 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket')
-rw-r--r--net/socket/socket_test_util.cc21
-rw-r--r--net/socket/socket_test_util.h3
2 files changed, 6 insertions, 18 deletions
diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc
index b3fbcfe..e053f6c 100644
--- a/net/socket/socket_test_util.cc
+++ b/net/socket/socket_test_util.cc
@@ -17,7 +17,6 @@ namespace net {
MockClientSocket::MockClientSocket()
: ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)),
- callback_(NULL),
connected_(false) {
}
@@ -32,7 +31,6 @@ void MockClientSocket::GetSSLCertRequestInfo(
void MockClientSocket::Disconnect() {
connected_ = false;
- callback_ = NULL;
}
bool MockClientSocket::IsConnected() const {
@@ -52,17 +50,15 @@ int MockClientSocket::GetPeerName(struct sockaddr *name, socklen_t *namelen) {
void MockClientSocket::RunCallbackAsync(net::CompletionCallback* callback,
int result) {
- callback_ = callback;
MessageLoop::current()->PostTask(FROM_HERE,
method_factory_.NewRunnableMethod(
- &MockClientSocket::RunCallback, result));
+ &MockClientSocket::RunCallback, callback, result));
}
-void MockClientSocket::RunCallback(int result) {
- net::CompletionCallback* c = callback_;
- callback_ = NULL;
- if (c)
- c->Run(result);
+void MockClientSocket::RunCallback(net::CompletionCallback* callback,
+ int result) {
+ if (callback)
+ callback->Run(result);
}
MockTCPClientSocket::MockTCPClientSocket(const net::AddressList& addresses,
@@ -77,7 +73,6 @@ MockTCPClientSocket::MockTCPClientSocket(const net::AddressList& addresses,
}
int MockTCPClientSocket::Connect(net::CompletionCallback* callback) {
- DCHECK(!callback_);
if (connected_)
return net::OK;
connected_ = true;
@@ -90,8 +85,6 @@ int MockTCPClientSocket::Connect(net::CompletionCallback* callback) {
int MockTCPClientSocket::Read(net::IOBuffer* buf, int buf_len,
net::CompletionCallback* callback) {
- DCHECK(!callback_);
-
if (!IsConnected())
return net::ERR_UNEXPECTED;
@@ -124,7 +117,6 @@ int MockTCPClientSocket::Write(net::IOBuffer* buf, int buf_len,
net::CompletionCallback* callback) {
DCHECK(buf);
DCHECK_GT(buf_len, 0);
- DCHECK(!callback_);
if (!IsConnected())
return net::ERR_UNEXPECTED;
@@ -185,7 +177,6 @@ void MockSSLClientSocket::GetSSLInfo(net::SSLInfo* ssl_info) {
}
int MockSSLClientSocket::Connect(net::CompletionCallback* callback) {
- DCHECK(!callback_);
ConnectCallback* connect_callback = new ConnectCallback(
this, callback, data_->connect.result);
int rv = transport_->Connect(connect_callback);
@@ -210,13 +201,11 @@ void MockSSLClientSocket::Disconnect() {
int MockSSLClientSocket::Read(net::IOBuffer* buf, int buf_len,
net::CompletionCallback* callback) {
- DCHECK(!callback_);
return transport_->Read(buf, buf_len, callback);
}
int MockSSLClientSocket::Write(net::IOBuffer* buf, int buf_len,
net::CompletionCallback* callback) {
- DCHECK(!callback_);
return transport_->Write(buf, buf_len, callback);
}
diff --git a/net/socket/socket_test_util.h b/net/socket/socket_test_util.h
index adfa3cb..23cadec 100644
--- a/net/socket/socket_test_util.h
+++ b/net/socket/socket_test_util.h
@@ -256,10 +256,9 @@ class MockClientSocket : public net::SSLClientSocket {
protected:
void RunCallbackAsync(net::CompletionCallback* callback, int result);
- void RunCallback(int result);
+ void RunCallback(net::CompletionCallback*, int result);
ScopedRunnableMethodFactory<MockClientSocket> method_factory_;
- net::CompletionCallback* callback_;
bool connected_;
};