summaryrefslogtreecommitdiffstats
path: root/net/socket/tcp_client_socket_libevent.cc
diff options
context:
space:
mode:
authoragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-10 22:13:46 +0000
committeragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-10 22:13:46 +0000
commit2d6e778368680b39f71e000ee03ce3430b96507a (patch)
tree1ee8495bd25760f5e9cd471594dc413190351b33 /net/socket/tcp_client_socket_libevent.cc
parentbb339ae418909bc5325b1695f6b96bcb9d5370e7 (diff)
downloadchromium_src-2d6e778368680b39f71e000ee03ce3430b96507a.zip
chromium_src-2d6e778368680b39f71e000ee03ce3430b96507a.tar.gz
chromium_src-2d6e778368680b39f71e000ee03ce3430b96507a.tar.bz2
net: assorted changes needed for Snap Start tests.
In IsAllowedBadCert, the pointer compare doesn't always work. Creating a certificate by X509Certificate::CreateFromBytes and putting it in the allowed bad list doesn't match the same certificate from a server. InvalidateSessionIfBadCertificate: I'm sure that there's history here that I don't know, so please review carefully. In order to test resumption against a server with a test certificate we need to avoid destroying the session. ClearSessionCache, AdoptSocket: only for testing BUG=none TEST=none http://codereview.chromium.org/4558004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65713 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket/tcp_client_socket_libevent.cc')
-rw-r--r--net/socket/tcp_client_socket_libevent.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/net/socket/tcp_client_socket_libevent.cc b/net/socket/tcp_client_socket_libevent.cc
index 1bbe827..a3fb281 100644
--- a/net/socket/tcp_client_socket_libevent.cc
+++ b/net/socket/tcp_client_socket_libevent.cc
@@ -140,6 +140,18 @@ TCPClientSocketLibevent::~TCPClientSocketLibevent() {
net_log_.EndEvent(NetLog::TYPE_SOCKET_ALIVE, NULL);
}
+void TCPClientSocketLibevent::AdoptSocket(int socket) {
+ DCHECK_EQ(socket_, kInvalidSocket);
+ socket_ = socket;
+ int error = SetupSocket();
+ DCHECK_EQ(0, error);
+ // This is to make GetPeerAddress work. It's up to the test that is calling
+ // this function to ensure that address_ contains a reasonable address for
+ // this socket. (i.e. at least match IPv4 vs IPv6!).
+ current_ai_ = addresses_.head();
+ use_history_.set_was_ever_connected();
+}
+
int TCPClientSocketLibevent::Connect(CompletionCallback* callback) {
DCHECK(CalledOnValidThread());
@@ -467,7 +479,10 @@ int TCPClientSocketLibevent::CreateSocket(const addrinfo* ai) {
socket_ = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
if (socket_ == kInvalidSocket)
return errno;
+ return SetupSocket();
+}
+int TCPClientSocketLibevent::SetupSocket() {
if (SetNonBlocking(socket_)) {
const int err = errno;
close(socket_);