| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/base/net_errors.h" | 5 #include "net/base/net_errors.h" |
| 6 | 6 |
| 7 #include <winsock2.h> | 7 #include <winsock2.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 | 10 |
| 11 namespace net { | 11 namespace net { |
| 12 | 12 |
| 13 // Map winsock and system errors to Chromium errors. | 13 // Map winsock and system errors to Chromium errors. |
| 14 Error MapSystemError(int os_error) { | 14 Error MapSystemError(int os_error) { |
| 15 if (os_error != 0) | 15 if (os_error != 0) |
| 16 DVLOG(2) << "Error " << os_error; | 16 DVLOG(2) << "Error " << os_error; |
| 17 | 17 |
| 18 // There are numerous Winsock error codes, but these are the ones we thus far | 18 // There are numerous Winsock error codes, but these are the ones we thus far |
| 19 // find interesting. | 19 // find interesting. |
| 20 switch (os_error) { | 20 switch (os_error) { |
| 21 case WSAEWOULDBLOCK: | 21 case WSAEWOULDBLOCK: |
| 22 case WSA_IO_PENDING: |
| 22 return ERR_IO_PENDING; | 23 return ERR_IO_PENDING; |
| 23 case WSAEACCES: | 24 case WSAEACCES: |
| 24 return ERR_ACCESS_DENIED; | 25 return ERR_ACCESS_DENIED; |
| 25 case WSAENETDOWN: | 26 case WSAENETDOWN: |
| 26 return ERR_INTERNET_DISCONNECTED; | 27 return ERR_INTERNET_DISCONNECTED; |
| 27 case WSAETIMEDOUT: | 28 case WSAETIMEDOUT: |
| 28 return ERR_TIMED_OUT; | 29 return ERR_TIMED_OUT; |
| 29 case WSAECONNRESET: | 30 case WSAECONNRESET: |
| 30 case WSAENETRESET: // Related to keep-alive | 31 case WSAENETRESET: // Related to keep-alive |
| 31 return ERR_CONNECTION_RESET; | 32 return ERR_CONNECTION_RESET; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 case ERROR_SUCCESS: | 112 case ERROR_SUCCESS: |
| 112 return OK; | 113 return OK; |
| 113 default: | 114 default: |
| 114 LOG(WARNING) << "Unknown error " << os_error | 115 LOG(WARNING) << "Unknown error " << os_error |
| 115 << " mapped to net::ERR_FAILED"; | 116 << " mapped to net::ERR_FAILED"; |
| 116 return ERR_FAILED; | 117 return ERR_FAILED; |
| 117 } | 118 } |
| 118 } | 119 } |
| 119 | 120 |
| 120 } // namespace net | 121 } // namespace net |
| OLD | NEW |