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

Unified Diff: net/socket/socket_test_util.h

Issue 139009: Tests for socks4/4a implementation. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: scoped_refptr Created 11 years, 6 months 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/net.gyp ('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
===================================================================
--- net/socket/socket_test_util.h (revision 19473)
+++ net/socket/socket_test_util.h (working copy)
@@ -10,10 +10,13 @@
#include "base/basictypes.h"
#include "base/logging.h"
+#include "base/scoped_ptr.h"
#include "net/base/address_list.h"
+#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "net/base/ssl_config_service.h"
#include "net/socket/client_socket_factory.h"
+#include "net/socket/ssl_client_socket.h"
namespace net {
@@ -200,6 +203,88 @@
MockSocketArray<MockSSLSocket> mock_ssl_sockets_;
};
+class MockClientSocket : public net::SSLClientSocket {
+ public:
+ MockClientSocket();
+
+ // ClientSocket methods:
+ virtual int Connect(net::CompletionCallback* callback) = 0;
+
+ // SSLClientSocket methods:
+ virtual void GetSSLInfo(net::SSLInfo* ssl_info);
+ virtual void GetSSLCertRequestInfo(
+ net::SSLCertRequestInfo* cert_request_info);
+ virtual void Disconnect();
+ virtual bool IsConnected() const;
+ virtual bool IsConnectedAndIdle() const;
+
+ // Socket methods:
+ virtual int Read(net::IOBuffer* buf, int buf_len,
+ net::CompletionCallback* callback) = 0;
+ virtual int Write(net::IOBuffer* buf, int buf_len,
+ net::CompletionCallback* callback) = 0;
+
+#if defined(OS_LINUX)
+ virtual int GetPeerName(struct sockaddr *name, socklen_t *namelen);
+#endif
+
+ protected:
+ void RunCallbackAsync(net::CompletionCallback* callback, int result);
+ void RunCallback(int result);
+
+ ScopedRunnableMethodFactory<MockClientSocket> method_factory_;
+ net::CompletionCallback* callback_;
+ bool connected_;
+};
+
+class MockTCPClientSocket : public MockClientSocket {
+ public:
+ MockTCPClientSocket(const net::AddressList& addresses,
+ net::MockSocket* socket);
+
+ // ClientSocket methods:
+ virtual int Connect(net::CompletionCallback* callback);
+
+ // Socket methods:
+ virtual int Read(net::IOBuffer* buf, int buf_len,
+ net::CompletionCallback* callback);
+ virtual int Write(net::IOBuffer* buf, int buf_len,
+ net::CompletionCallback* callback);
+
+ private:
+ net::MockSocket* data_;
+ int read_offset_;
+ net::MockRead read_data_;
+ bool need_read_data_;
+};
+
+class MockSSLClientSocket : public MockClientSocket {
+ public:
+ MockSSLClientSocket(
+ net::ClientSocket* transport_socket,
+ const std::string& hostname,
+ const net::SSLConfig& ssl_config,
+ net::MockSSLSocket* socket);
+ ~MockSSLClientSocket();
+
+ virtual void GetSSLInfo(net::SSLInfo* ssl_info);
+
+ virtual int Connect(net::CompletionCallback* callback);
+ virtual void Disconnect();
+
+ // Socket methods:
+ virtual int Read(net::IOBuffer* buf, int buf_len,
+ net::CompletionCallback* callback);
+ virtual int Write(net::IOBuffer* buf, int buf_len,
+ net::CompletionCallback* callback);
+
+ private:
+ class ConnectCallback;
+
+ scoped_ptr<ClientSocket> transport_;
+ net::MockSSLSocket* data_;
+};
+
} // namespace net
#endif // NET_SOCKET_SOCKET_TEST_UTIL_H_
« no previous file with comments | « net/net.gyp ('k') | net/socket/socket_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698