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

Unified Diff: net/socket/socket_test_util.h

Issue 8801005: base::Bind: Convert Socket::Read. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes. Created 9 years 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.h ('k') | net/socket/socket_test_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/socket_test_util.h
diff --git a/net/socket/socket_test_util.h b/net/socket/socket_test_util.h
index fa47d26fd0f36da03aaedf37b3e0775c6543fc64..73ffc3d7c907ba24c39d55de3aa7e13849447bb4 100644
--- a/net/socket/socket_test_util.h
+++ b/net/socket/socket_test_util.h
@@ -19,6 +19,7 @@
#include "base/memory/weak_ptr.h"
#include "base/string16.h"
#include "net/base/address_list.h"
+#include "net/base/completion_callback.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "net/base/net_log.h"
@@ -587,6 +588,8 @@ class MockClientSocket : public net::SSLClientSocket {
// Socket implementation.
virtual int Read(net::IOBuffer* buf, int buf_len,
net::OldCompletionCallback* callback) = 0;
+ virtual int Read(net::IOBuffer* buf, int buf_len,
+ const net::CompletionCallback& callback) = 0;
virtual int Write(net::IOBuffer* buf, int buf_len,
net::OldCompletionCallback* callback) = 0;
virtual bool SetReceiveBufferSize(int32 size) OVERRIDE;
@@ -634,12 +637,15 @@ class MockTCPClientSocket : public MockClientSocket, public AsyncSocket {
public:
MockTCPClientSocket(const net::AddressList& addresses, net::NetLog* net_log,
net::SocketDataProvider* socket);
+ virtual ~MockTCPClientSocket();
net::AddressList addresses() const { return addresses_; }
// Socket implementation.
virtual int Read(net::IOBuffer* buf, int buf_len,
net::OldCompletionCallback* callback) OVERRIDE;
+ virtual int Read(net::IOBuffer* buf, int buf_len,
+ const net::CompletionCallback& callback) OVERRIDE;
virtual int Write(net::IOBuffer* buf, int buf_len,
net::OldCompletionCallback* callback) OVERRIDE;
@@ -677,7 +683,8 @@ class MockTCPClientSocket : public MockClientSocket, public AsyncSocket {
// While an asynchronous IO is pending, we save our user-buffer state.
net::IOBuffer* pending_buf_;
int pending_buf_len_;
- net::OldCompletionCallback* pending_callback_;
+ net::OldCompletionCallback* old_pending_callback_;
+ net::CompletionCallback pending_callback_;
bool was_used_to_convey_data_;
};
@@ -695,11 +702,13 @@ class DeterministicMockTCPClientSocket : public MockClientSocket,
void CompleteWrite();
int CompleteRead();
- // Socket:
+ // Socket implementation.
virtual int Write(net::IOBuffer* buf, int buf_len,
net::OldCompletionCallback* callback) OVERRIDE;
virtual int Read(net::IOBuffer* buf, int buf_len,
net::OldCompletionCallback* callback) OVERRIDE;
+ virtual int Read(net::IOBuffer* buf, int buf_len,
+ const net::CompletionCallback& callback) OVERRIDE;
// StreamSocket implementation.
virtual int Connect(net::OldCompletionCallback* callback) OVERRIDE;
@@ -725,7 +734,8 @@ class DeterministicMockTCPClientSocket : public MockClientSocket,
net::IOBuffer* read_buf_;
int read_buf_len_;
bool read_pending_;
- net::OldCompletionCallback* read_callback_;
+ net::OldCompletionCallback* old_read_callback_;
+ net::CompletionCallback read_callback_;
net::DeterministicSocketData* data_;
bool was_used_to_convey_data_;
};
@@ -743,6 +753,8 @@ class MockSSLClientSocket : public MockClientSocket, public AsyncSocket {
// Socket implementation.
virtual int Read(net::IOBuffer* buf, int buf_len,
net::OldCompletionCallback* callback) OVERRIDE;
+ virtual int Read(net::IOBuffer* buf, int buf_len,
+ const net::CompletionCallback& callback) OVERRIDE;
virtual int Write(net::IOBuffer* buf, int buf_len,
net::OldCompletionCallback* callback) OVERRIDE;
@@ -785,31 +797,35 @@ class MockUDPClientSocket : public DatagramClientSocket,
MockUDPClientSocket(SocketDataProvider* data, net::NetLog* net_log);
virtual ~MockUDPClientSocket();
- // Socket interface
+ // Socket implementation.
virtual int Read(net::IOBuffer* buf, int buf_len,
net::OldCompletionCallback* callback) OVERRIDE;
+ virtual int Read(net::IOBuffer* buf, int buf_len,
+ const net::CompletionCallback& callback) OVERRIDE;
virtual int Write(net::IOBuffer* buf, int buf_len,
net::OldCompletionCallback* callback) OVERRIDE;
virtual bool SetReceiveBufferSize(int32 size) OVERRIDE;
virtual bool SetSendBufferSize(int32 size) OVERRIDE;
- // DatagramSocket interface
+ // DatagramSocket implementation.
virtual void Close() OVERRIDE;
virtual int GetPeerAddress(IPEndPoint* address) const OVERRIDE;
virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE;
virtual const BoundNetLog& NetLog() const OVERRIDE;
- // DatagramClientSocket interface
+ // DatagramClientSocket implementation.
virtual int Connect(const IPEndPoint& address) OVERRIDE;
- // AsyncSocket interface
+ // AsyncSocket implementation.
virtual void OnReadComplete(const MockRead& data) OVERRIDE;
private:
int CompleteRead();
void RunCallbackAsync(net::OldCompletionCallback* callback, int result);
- void RunCallback(net::OldCompletionCallback* callback, int result);
+ void RunCallbackAsync(const net::CompletionCallback& callback, int result);
+ void RunOldCallback(net::OldCompletionCallback* callback, int result);
+ void RunCallback(const net::CompletionCallback& callback, int result);
bool connected_;
SocketDataProvider* data_;
@@ -820,7 +836,8 @@ class MockUDPClientSocket : public DatagramClientSocket,
// While an asynchronous IO is pending, we save our user-buffer state.
net::IOBuffer* pending_buf_;
int pending_buf_len_;
- net::OldCompletionCallback* pending_callback_;
+ net::OldCompletionCallback* old_pending_callback_;
+ net::CompletionCallback pending_callback_;
BoundNetLog net_log_;
« no previous file with comments | « net/socket/socket.h ('k') | net/socket/socket_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698