Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Side by Side Diff: net/socket/tcp_client_socket_win.cc

Issue 3976004: Adds a new error for cases where a firewall may be the issue. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/socket/tcp_client_socket_libevent.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/socket/tcp_client_socket_win.h" 5 #include "net/socket/tcp_client_socket_win.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory_debug.h" 9 #include "base/memory_debug.h"
10 #include "base/metrics/stats_counters.h" 10 #include "base/metrics/stats_counters.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 CHECK(ok); 57 CHECK(ok);
58 return true; 58 return true;
59 } 59 }
60 60
61 //----------------------------------------------------------------------------- 61 //-----------------------------------------------------------------------------
62 62
63 int MapWinsockError(int os_error) { 63 int MapWinsockError(int os_error) {
64 // There are numerous Winsock error codes, but these are the ones we thus far 64 // There are numerous Winsock error codes, but these are the ones we thus far
65 // find interesting. 65 // find interesting.
66 switch (os_error) { 66 switch (os_error) {
67 // connect fails with WSAEACCES when Windows Firewall blocks the
68 // connection.
69 case WSAEACCES: 67 case WSAEACCES:
70 return ERR_ACCESS_DENIED; 68 return ERR_ACCESS_DENIED;
71 case WSAENETDOWN: 69 case WSAENETDOWN:
72 return ERR_INTERNET_DISCONNECTED; 70 return ERR_INTERNET_DISCONNECTED;
73 case WSAETIMEDOUT: 71 case WSAETIMEDOUT:
74 return ERR_TIMED_OUT; 72 return ERR_TIMED_OUT;
75 case WSAECONNRESET: 73 case WSAECONNRESET:
76 case WSAENETRESET: // Related to keep-alive 74 case WSAENETRESET: // Related to keep-alive
77 return ERR_CONNECTION_RESET; 75 return ERR_CONNECTION_RESET;
78 case WSAECONNABORTED: 76 case WSAECONNABORTED:
(...skipping 18 matching lines...) Expand all
97 return OK; 95 return OK;
98 default: 96 default:
99 LOG(WARNING) << "Unknown error " << os_error 97 LOG(WARNING) << "Unknown error " << os_error
100 << " mapped to net::ERR_FAILED"; 98 << " mapped to net::ERR_FAILED";
101 return ERR_FAILED; 99 return ERR_FAILED;
102 } 100 }
103 } 101 }
104 102
105 int MapConnectError(int os_error) { 103 int MapConnectError(int os_error) {
106 switch (os_error) { 104 switch (os_error) {
105 // connect fails with WSAEACCES when Windows Firewall blocks the
106 // connection.
107 case WSAEACCES:
108 return ERR_NETWORK_ACCESS_DENIED;
107 case WSAETIMEDOUT: 109 case WSAETIMEDOUT:
108 return ERR_CONNECTION_TIMED_OUT; 110 return ERR_CONNECTION_TIMED_OUT;
109 default: { 111 default: {
110 int net_error = MapWinsockError(os_error); 112 int net_error = MapWinsockError(os_error);
111 if (net_error == ERR_FAILED) 113 if (net_error == ERR_FAILED)
112 return ERR_CONNECTION_FAILED; // More specific than ERR_FAILED. 114 return ERR_CONNECTION_FAILED; // More specific than ERR_FAILED.
113 115
114 // Give a more specific error when the user is offline. 116 // Give a more specific error when the user is offline.
115 if (net_error == ERR_ADDRESS_UNREACHABLE && 117 if (net_error == ERR_ADDRESS_UNREACHABLE &&
116 NetworkChangeNotifier::IsOffline()) { 118 NetworkChangeNotifier::IsOffline()) {
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 use_history_.set_was_used_to_convey_data(); 816 use_history_.set_was_used_to_convey_data();
815 LogByteTransfer(net_log_, NetLog::TYPE_SOCKET_BYTES_SENT, num_bytes, 817 LogByteTransfer(net_log_, NetLog::TYPE_SOCKET_BYTES_SENT, num_bytes,
816 core_->write_buffer_.buf); 818 core_->write_buffer_.buf);
817 } 819 }
818 } 820 }
819 core_->write_iobuffer_ = NULL; 821 core_->write_iobuffer_ = NULL;
820 DoWriteCallback(rv); 822 DoWriteCallback(rv);
821 } 823 }
822 824
823 } // namespace net 825 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/tcp_client_socket_libevent.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698