diff options
author | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-10 02:27:20 +0000 |
---|---|---|
committer | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-10 02:27:20 +0000 |
commit | 7ba1d1cb8aed95982de70d9ebfddb11aeab03422 (patch) | |
tree | e91e793d29812b98a31d59190b570e5fb77d80d0 /net/socket/tcp_client_socket_win.cc | |
parent | 3da9e382813c630d1e650ace8e79c41d8ccb4a19 (diff) | |
download | chromium_src-7ba1d1cb8aed95982de70d9ebfddb11aeab03422.zip chromium_src-7ba1d1cb8aed95982de70d9ebfddb11aeab03422.tar.gz chromium_src-7ba1d1cb8aed95982de70d9ebfddb11aeab03422.tar.bz2 |
Fix a style nit in client_socket.h.
Use the |os_error| name consistently for all the function
arguments and local variables that represent OS errors.
R=eroman
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/374008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31537 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket/tcp_client_socket_win.cc')
-rw-r--r-- | net/socket/tcp_client_socket_win.cc | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/net/socket/tcp_client_socket_win.cc b/net/socket/tcp_client_socket_win.cc index 08d1b19..0bb8148 100644 --- a/net/socket/tcp_client_socket_win.cc +++ b/net/socket/tcp_client_socket_win.cc @@ -42,10 +42,10 @@ bool ResetEventIfSignaled(WSAEVENT hEvent) { //----------------------------------------------------------------------------- -int MapWinsockError(int err) { +int MapWinsockError(int os_error) { // There are numerous Winsock error codes, but these are the ones we thus far // find interesting. - switch (err) { + switch (os_error) { // connect fails with WSAEACCES when Windows Firewall blocks the // connection. case WSAEACCES: @@ -78,17 +78,18 @@ int MapWinsockError(int err) { case ERROR_SUCCESS: return OK; default: - LOG(WARNING) << "Unknown error " << err << " mapped to net::ERR_FAILED"; + LOG(WARNING) << "Unknown error " << os_error + << " mapped to net::ERR_FAILED"; return ERR_FAILED; } } -int MapConnectError(int err) { - switch (err) { +int MapConnectError(int os_error) { + switch (os_error) { case WSAETIMEDOUT: return ERR_CONNECTION_TIMED_OUT; default: { - int net_error = MapWinsockError(err); + int net_error = MapWinsockError(os_error); if (net_error == ERR_FAILED) return ERR_CONNECTION_FAILED; // More specific than ERR_FAILED. return net_error; @@ -96,10 +97,10 @@ int MapConnectError(int err) { } } -// Given err, a WSAGetLastError() error code from a connect() attempt, returns -// true if connect() should be retried with another address. -bool ShouldTryNextAddress(int err) { - switch (err) { +// Given os_error, a WSAGetLastError() error code from a connect() attempt, +// returns true if connect() should be retried with another address. +bool ShouldTryNextAddress(int os_error) { + switch (os_error) { case WSAEADDRNOTAVAIL: case WSAEAFNOSUPPORT: case WSAECONNREFUSED: @@ -368,10 +369,10 @@ int TCPClientSocketWin::DoConnect() { if (ResetEventIfSignaled(core_->read_overlapped_.hEvent)) return OK; } else { - int err = WSAGetLastError(); - if (err != WSAEWOULDBLOCK) { - LOG(ERROR) << "connect failed: " << err; - return MapConnectError(err); + int os_error = WSAGetLastError(); + if (os_error != WSAEWOULDBLOCK) { + LOG(ERROR) << "connect failed: " << os_error; + return MapConnectError(os_error); } } @@ -483,9 +484,9 @@ int TCPClientSocketWin::Read(IOBuffer* buf, return static_cast<int>(num); } } else { - int err = WSAGetLastError(); - if (err != WSA_IO_PENDING) - return MapWinsockError(err); + int os_error = WSAGetLastError(); + if (os_error != WSA_IO_PENDING) + return MapWinsockError(os_error); } core_->WatchForRead(); waiting_read_ = true; @@ -524,9 +525,9 @@ int TCPClientSocketWin::Write(IOBuffer* buf, return static_cast<int>(num); } } else { - int err = WSAGetLastError(); - if (err != WSA_IO_PENDING) - return MapWinsockError(err); + int os_error = WSAGetLastError(); + if (os_error != WSA_IO_PENDING) + return MapWinsockError(os_error); } core_->WatchForWrite(); waiting_write_ = true; @@ -553,9 +554,9 @@ int TCPClientSocketWin::CreateSocket(const struct addrinfo* ai) { socket_ = WSASocket(ai->ai_family, ai->ai_socktype, ai->ai_protocol, NULL, 0, WSA_FLAG_OVERLAPPED); if (socket_ == INVALID_SOCKET) { - int err = WSAGetLastError(); - LOG(ERROR) << "WSASocket failed: " << err; - return MapWinsockError(err); + int os_error = WSAGetLastError(); + LOG(ERROR) << "WSASocket failed: " << os_error; + return MapWinsockError(os_error); } // Increase the socket buffer sizes from the default sizes for WinXP. In @@ -646,8 +647,8 @@ void TCPClientSocketWin::DidCompleteConnect() { NOTREACHED(); result = MapWinsockError(WSAGetLastError()); } else if (events.lNetworkEvents & FD_CONNECT) { - DWORD error_code = static_cast<DWORD>(events.iErrorCode[FD_CONNECT_BIT]); - if (current_ai_->ai_next && ShouldTryNextAddress(error_code)) { + int os_error = events.iErrorCode[FD_CONNECT_BIT]; + if (current_ai_->ai_next && ShouldTryNextAddress(os_error)) { // Try using the next address. const struct addrinfo* next = current_ai_->ai_next; Disconnect(); @@ -658,7 +659,7 @@ void TCPClientSocketWin::DidCompleteConnect() { LoadLog::EndEvent(load_log, LoadLog::TYPE_TCP_CONNECT); result = Connect(read_callback_, load_log); } else { - result = MapConnectError(error_code); + result = MapConnectError(os_error); TRACE_EVENT_END("socket.connect", this, ""); LoadLog::EndEvent(load_log_, LoadLog::TYPE_TCP_CONNECT); load_log_ = NULL; |