Make TCP FastOpen work again.

In TCPClientSocketLibevent, this requires making IsConnected pretend the
socket is connected so that GetPeerAddress will succeed.

In SSLClientSocketNSS, revert the workaround because we don't need to
delay the GetPeerAddress call.

[email protected]
BUG=none
TEST=none

Review URL: http://codereview.chromium.org/7155014

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90090 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/net/socket/tcp_client_socket_libevent.cc b/net/socket/tcp_client_socket_libevent.cc
index 8540342..38c3446 100644
--- a/net/socket/tcp_client_socket_libevent.cc
+++ b/net/socket/tcp_client_socket_libevent.cc
@@ -384,6 +384,15 @@
   if (socket_ == kInvalidSocket || waiting_connect())
     return false;
 
+  if (use_tcp_fastopen_ && !tcp_fastopen_connected_) {
+    // With TCP FastOpen, we pretend that the socket is connected.
+    // This allows GetPeerAddress() to return current_ai_ as the peer
+    // address.  Since we don't fail over to the next address if
+    // sendto() fails, current_ai_ is the only possible peer address.
+    CHECK(current_ai_);
+    return true;
+  }
+
   // Check if connection is alive.
   char c;
   int rv = HANDLE_EINTR(recv(socket_, &c, 1, MSG_PEEK));
@@ -401,6 +410,9 @@
   if (socket_ == kInvalidSocket || waiting_connect())
     return false;
 
+  // TODO(wtc): should we also handle the TCP FastOpen case here,
+  // as we do in IsConnected()?
+
   // Check if connection is alive and we haven't received any data
   // unexpectedly.
   char c;