| Index: net/socket/tcp_client_socket_win.cc
 | 
| diff --git a/net/socket/tcp_client_socket_win.cc b/net/socket/tcp_client_socket_win.cc
 | 
| index 9e93bf0b76cf0f1f28b1cb61b1fba7b92e6fa5f5..6d733fa6fe5f468b65ccca9b77dba94b298e3bb0 100644
 | 
| --- a/net/socket/tcp_client_socket_win.cc
 | 
| +++ b/net/socket/tcp_client_socket_win.cc
 | 
| @@ -22,97 +22,12 @@
 | 
|  #include "net/base/network_change_notifier.h"
 | 
|  #include "net/base/sys_addrinfo.h"
 | 
|  #include "net/base/winsock_init.h"
 | 
| +#include "net/base/winsock_util.h"
 | 
|  
 | 
|  namespace net {
 | 
|  
 | 
|  namespace {
 | 
|  
 | 
| -// Prevent the compiler from optimizing away the arguments so they appear
 | 
| -// nicely on the stack in crash dumps.
 | 
| -#pragma warning (disable: 4748)
 | 
| -#pragma optimize( "", off )
 | 
| -
 | 
| -// Pass the important values as function arguments so that they are available
 | 
| -// in crash dumps.
 | 
| -void CheckEventWait(WSAEVENT hEvent, DWORD wait_rv, DWORD expected) {
 | 
| -  if (wait_rv != expected) {
 | 
| -    DWORD err = ERROR_SUCCESS;
 | 
| -    if (wait_rv == WAIT_FAILED)
 | 
| -      err = GetLastError();
 | 
| -    CHECK(false);  // Crash.
 | 
| -  }
 | 
| -}
 | 
| -
 | 
| -#pragma optimize( "", on )
 | 
| -#pragma warning (default: 4748)
 | 
| -
 | 
| -// Assert that the (manual-reset) event object is not signaled.
 | 
| -void AssertEventNotSignaled(WSAEVENT hEvent) {
 | 
| -  DWORD wait_rv = WaitForSingleObject(hEvent, 0);
 | 
| -  CheckEventWait(hEvent, wait_rv, WAIT_TIMEOUT);
 | 
| -}
 | 
| -
 | 
| -// If the (manual-reset) event object is signaled, resets it and returns true.
 | 
| -// Otherwise, does nothing and returns false.  Called after a Winsock function
 | 
| -// succeeds synchronously
 | 
| -//
 | 
| -// Our testing shows that except in rare cases (when running inside QEMU),
 | 
| -// the event object is already signaled at this point, so we call this method
 | 
| -// to avoid a context switch in common cases.  This is just a performance
 | 
| -// optimization.  The code still works if this function simply returns false.
 | 
| -bool ResetEventIfSignaled(WSAEVENT hEvent) {
 | 
| -  // TODO(wtc): Remove the CHECKs after enough testing.
 | 
| -  DWORD wait_rv = WaitForSingleObject(hEvent, 0);
 | 
| -  if (wait_rv == WAIT_TIMEOUT)
 | 
| -    return false;  // The event object is not signaled.
 | 
| -  CheckEventWait(hEvent, wait_rv, WAIT_OBJECT_0);
 | 
| -  BOOL ok = WSAResetEvent(hEvent);
 | 
| -  CHECK(ok);
 | 
| -  return true;
 | 
| -}
 | 
| -
 | 
| -//-----------------------------------------------------------------------------
 | 
| -
 | 
| -int MapWinsockError(int os_error) {
 | 
| -  // There are numerous Winsock error codes, but these are the ones we thus far
 | 
| -  // find interesting.
 | 
| -  switch (os_error) {
 | 
| -    case WSAEACCES:
 | 
| -      return ERR_ACCESS_DENIED;
 | 
| -    case WSAENETDOWN:
 | 
| -      return ERR_INTERNET_DISCONNECTED;
 | 
| -    case WSAETIMEDOUT:
 | 
| -      return ERR_TIMED_OUT;
 | 
| -    case WSAECONNRESET:
 | 
| -    case WSAENETRESET:  // Related to keep-alive
 | 
| -      return ERR_CONNECTION_RESET;
 | 
| -    case WSAECONNABORTED:
 | 
| -      return ERR_CONNECTION_ABORTED;
 | 
| -    case WSAECONNREFUSED:
 | 
| -      return ERR_CONNECTION_REFUSED;
 | 
| -    case WSA_IO_INCOMPLETE:
 | 
| -    case WSAEDISCON:
 | 
| -      // WSAEDISCON is returned by WSARecv or WSARecvFrom for message-oriented
 | 
| -      // sockets (where a return value of zero means a zero-byte message) to
 | 
| -      // indicate graceful connection shutdown.  We should not ever see this
 | 
| -      // error code for TCP sockets, which are byte stream oriented.
 | 
| -      LOG(DFATAL) << "Unexpected error " << os_error
 | 
| -                  << " mapped to net::ERR_UNEXPECTED";
 | 
| -      return ERR_UNEXPECTED;
 | 
| -    case WSAEHOSTUNREACH:
 | 
| -    case WSAENETUNREACH:
 | 
| -      return ERR_ADDRESS_UNREACHABLE;
 | 
| -    case WSAEADDRNOTAVAIL:
 | 
| -      return ERR_ADDRESS_INVALID;
 | 
| -    case ERROR_SUCCESS:
 | 
| -      return OK;
 | 
| -    default:
 | 
| -      LOG(WARNING) << "Unknown error " << os_error
 | 
| -                   << " mapped to net::ERR_FAILED";
 | 
| -      return ERR_FAILED;
 | 
| -  }
 | 
| -}
 | 
| -
 | 
|  int MapConnectError(int os_error) {
 | 
|    switch (os_error) {
 | 
|      // connect fails with WSAEACCES when Windows Firewall blocks the
 | 
| 
 |