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

Side by Side Diff: net/websockets/websocket_errors.cc

Issue 14850012: Add missing status codes to WebSocketError enum. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 7 months 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/websockets/websocket_errors.h" 5 #include "net/websockets/websocket_errors.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace net { 9 namespace net {
10 namespace {
11
12 // Return true if "error" is one of the codes defined by the multiplexing
13 // extension known to Chromium.
14 bool IsWebSocketMuxErrorCode(WebSocketError error) {
15 switch (error) {
16 case kWebSocketErrorPhysicalConnectionFailed:
17 case kWebSocketErrorInvalidEncapsulatingMessage:
18 case kWebSocketErrorChannelIdTruncated:
19 case kWebSocketErrorEncapsulatedFrameIsTruncated:
20 case kWebSocketErrorUnknownMuxOpcode:
21 case kWebSocketErrorInvalidMuxControlBlock:
22 case kWebSocketErrorChannelAlreadyExists:
23 case kWebSocketErrorNewChannelSlotViolation:
24 case kWebSocketErrorNewChannelSlotOverFlow:
25 case kWebSocketErrorBadRequest:
26 case kWebSocketErrorUnknownRequestEncoding:
27 case kWebSocketErrorBadResponse:
28 case kWebSocketErrorUnknownResponseEncoding:
29 case kWebSocketErrorLogicalChannelFailed:
30 case kWebSocketErrorSendQuotaViolation:
31 case kWebSocketErrorSendQuotaOverflow:
32 case kWebSocketErrorIdleTimeout:
33 case kWebSocketErrorDropChannelAck:
34 case kWebSocketErrorBadFragmentation:
35 return true;
36
37 default:
38 return false;
39 }
40 }
41
42 } // namespace
10 43
11 Error WebSocketErrorToNetError(WebSocketError error) { 44 Error WebSocketErrorToNetError(WebSocketError error) {
12 switch (error) { 45 switch (error) {
13 case WEB_SOCKET_OK: 46 case kWebSocketNormalClosure:
14 return OK; 47 return OK;
15 case WEB_SOCKET_ERR_PROTOCOL_ERROR: 48
49 case kWebSocketErrorGoingAway: // TODO(ricea): More specific code?
50 case kWebSocketErrorProtocolError:
51 case kWebSocketErrorUnsupportedData:
52 case kWebSocketErrorInvalidFramePayloadData:
53 case kWebSocketErrorPolicyViolation:
54 case kWebSocketErrorMandatoryExtension:
55 case kWebSocketErrorInternalServerError:
16 return ERR_WS_PROTOCOL_ERROR; 56 return ERR_WS_PROTOCOL_ERROR;
17 case WEB_SOCKET_ERR_MESSAGE_TOO_BIG: 57
58 case kWebSocketErrorNoStatusReceived:
59 case kWebSocketErrorAbnormalClosure:
60 return ERR_CONNECTION_CLOSED;
61
62 case kWebSocketErrorTlsHandshake:
63 // This error will probably be reported with more detail at a lower layer;
64 // this is the best we can do at this layer.
65 return ERR_SSL_PROTOCOL_ERROR;
66
67 case kWebSocketErrorMessageTooBig:
18 return ERR_MSG_TOO_BIG; 68 return ERR_MSG_TOO_BIG;
69
19 default: 70 default:
20 NOTREACHED(); 71 // Check for extension error codes which we may be generating internally.
21 return ERR_UNEXPECTED; 72 return IsWebSocketMuxErrorCode(error) ? ERR_WS_PROTOCOL_ERROR
73 : ERR_UNEXPECTED;
22 } 74 }
23 } 75 }
24 76
25 } // namespace net 77 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698