Avi Drissman | 6459548 | 2022-09-14 20:52:29 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors |
[email protected] | be5a782 | 2012-08-06 15:36:10 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | a97ee92 | 2013-01-18 05:32:55 | [diff] [blame] | 5 | #include "net/websockets/websocket_errors.h" |
6 | |||||
[email protected] | be5a782 | 2012-08-06 15:36:10 | [diff] [blame] | 7 | |
8 | namespace net { | ||||
9 | |||||
10 | Error WebSocketErrorToNetError(WebSocketError error) { | ||||
11 | switch (error) { | ||||
[email protected] | 40e9c62f | 2013-05-07 14:59:21 | [diff] [blame] | 12 | case kWebSocketNormalClosure: |
[email protected] | be5a782 | 2012-08-06 15:36:10 | [diff] [blame] | 13 | return OK; |
[email protected] | 40e9c62f | 2013-05-07 14:59:21 | [diff] [blame] | 14 | |
15 | case kWebSocketErrorGoingAway: // TODO(ricea): More specific code? | ||||
16 | case kWebSocketErrorProtocolError: | ||||
17 | case kWebSocketErrorUnsupportedData: | ||||
18 | case kWebSocketErrorInvalidFramePayloadData: | ||||
19 | case kWebSocketErrorPolicyViolation: | ||||
20 | case kWebSocketErrorMandatoryExtension: | ||||
21 | case kWebSocketErrorInternalServerError: | ||||
[email protected] | be5a782 | 2012-08-06 15:36:10 | [diff] [blame] | 22 | return ERR_WS_PROTOCOL_ERROR; |
[email protected] | 40e9c62f | 2013-05-07 14:59:21 | [diff] [blame] | 23 | |
24 | case kWebSocketErrorNoStatusReceived: | ||||
25 | case kWebSocketErrorAbnormalClosure: | ||||
26 | return ERR_CONNECTION_CLOSED; | ||||
27 | |||||
28 | case kWebSocketErrorTlsHandshake: | ||||
29 | // This error will probably be reported with more detail at a lower layer; | ||||
30 | // this is the best we can do at this layer. | ||||
31 | return ERR_SSL_PROTOCOL_ERROR; | ||||
32 | |||||
33 | case kWebSocketErrorMessageTooBig: | ||||
[email protected] | be5a782 | 2012-08-06 15:36:10 | [diff] [blame] | 34 | return ERR_MSG_TOO_BIG; |
[email protected] | 40e9c62f | 2013-05-07 14:59:21 | [diff] [blame] | 35 | |
[email protected] | be5a782 | 2012-08-06 15:36:10 | [diff] [blame] | 36 | default: |
[email protected] | a97ee92 | 2013-01-18 05:32:55 | [diff] [blame] | 37 | return ERR_UNEXPECTED; |
[email protected] | be5a782 | 2012-08-06 15:36:10 | [diff] [blame] | 38 | } |
39 | } | ||||
40 | |||||
41 | } // namespace net |