15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef NET_WEBSOCKETS_WEBSOCKET_ERRORS_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define NET_WEBSOCKETS_WEBSOCKET_ERRORS_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/base/net_errors.h"
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace net {
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
12b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)// Reason codes used with close messages. NoStatusReceived,
13b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)// AbnormalClosure and TlsHandshake are special in that they
14b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)// should never be sent on the wire; they are only used within the
15b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)// implementation.
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)enum WebSocketError {
17b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  // Status codes in the range 0 to 999 are not used.
18b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)
19b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  // The following are defined by RFC6455.
20b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  kWebSocketNormalClosure = 1000,
21b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  kWebSocketErrorGoingAway = 1001,
22b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  kWebSocketErrorProtocolError = 1002,
23b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  kWebSocketErrorUnsupportedData = 1003,
24b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  kWebSocketErrorNoStatusReceived = 1005,
25b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  kWebSocketErrorAbnormalClosure = 1006,
26b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  kWebSocketErrorInvalidFramePayloadData = 1007,
27b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  kWebSocketErrorPolicyViolation = 1008,
28b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  kWebSocketErrorMessageTooBig = 1009,
29b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  kWebSocketErrorMandatoryExtension = 1010,
30b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  kWebSocketErrorInternalServerError = 1011,
31b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  kWebSocketErrorTlsHandshake = 1015,
32b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)
33b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  // The range 1000-2999 is reserved by RFC6455 for use by the WebSocket
34b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  // protocol and public extensions.
35b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  kWebSocketErrorProtocolReservedMax = 2999,
36b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)
37b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  // The range 3000-3999 is reserved by RFC6455 for registered use by libraries,
38b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  // frameworks and applications.
39b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  kWebSocketErrorRegisteredReservedMin = 3000,
40b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  kWebSocketErrorRegisteredReservedMax = 3999,
41b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)
42b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  // The range 4000-4999 is reserved by RFC6455 for private use by prior
43b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  // agreement of the endpoints.
44b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  kWebSocketErrorPrivateReservedMin = 4000,
45b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)  kWebSocketErrorPrivateReservedMax = 4999,
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Convert WebSocketError to net::Error defined in net/base/net_errors.h.
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)NET_EXPORT_PRIVATE Error WebSocketErrorToNetError(WebSocketError error);
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace net
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
53b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)#endif  // NET_WEBSOCKETS_WEBSOCKET_ERRORS_H_
54