| OLD | NEW |
| 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 #ifndef NET_WEBSOCKETS_WEBSOCKET_FRAME_PARSER_H_ | 5 #ifndef NET_WEBSOCKETS_WEBSOCKET_FRAME_PARSER_H_ |
| 6 #define NET_WEBSOCKETS_WEBSOCKET_FRAME_PARSER_H_ | 6 #define NET_WEBSOCKETS_WEBSOCKET_FRAME_PARSER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 // If the parser encounters invalid payload length format, Decode() fails | 33 // If the parser encounters invalid payload length format, Decode() fails |
| 34 // and returns false. Once Decode() has failed, the parser refuses to decode | 34 // and returns false. Once Decode() has failed, the parser refuses to decode |
| 35 // any more data and future invocations of Decode() will simply return false. | 35 // any more data and future invocations of Decode() will simply return false. |
| 36 // | 36 // |
| 37 // Payload data of parsed WebSocket frames may be incomplete; see comments in | 37 // Payload data of parsed WebSocket frames may be incomplete; see comments in |
| 38 // websocket_frame.h for more details. | 38 // websocket_frame.h for more details. |
| 39 bool Decode(const char* data, | 39 bool Decode(const char* data, |
| 40 size_t length, | 40 size_t length, |
| 41 ScopedVector<WebSocketFrameChunk>* frame_chunks); | 41 ScopedVector<WebSocketFrameChunk>* frame_chunks); |
| 42 | 42 |
| 43 // Returns WEB_SOCKET_OK if the parser has not failed to decode WebSocket | 43 // Returns kWebSocketNormalClosure if the parser has not failed to decode |
| 44 // frames. Otherwise returns WebSocketError which is defined in | 44 // WebSocket frames. Otherwise returns WebSocketError which is defined in |
| 45 // websocket_errors.h. We can convert net::WebSocketError to net::Error by | 45 // websocket_errors.h. We can convert net::WebSocketError to net::Error by |
| 46 // using WebSocketErrorToNetError(). | 46 // using WebSocketErrorToNetError(). |
| 47 WebSocketError websocket_error() const { return websocket_error_; } | 47 WebSocketError websocket_error() const { return websocket_error_; } |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 // Tries to decode a frame header from |current_read_pos_|. | 50 // Tries to decode a frame header from |current_read_pos_|. |
| 51 // If successful, this function updates |current_read_pos_|, | 51 // If successful, this function updates |current_read_pos_|, |
| 52 // |current_frame_header_|, and |masking_key_| (if available). | 52 // |current_frame_header_|, and |masking_key_| (if available). |
| 53 // This function may set |failed_| to true if it observes a corrupt frame. | 53 // This function may set |failed_| to true if it observes a corrupt frame. |
| 54 // If there is not enough data in the remaining buffer to parse a frame | 54 // If there is not enough data in the remaining buffer to parse a frame |
| (...skipping 23 matching lines...) Expand all Loading... |
| 78 uint64 frame_offset_; | 78 uint64 frame_offset_; |
| 79 | 79 |
| 80 WebSocketError websocket_error_; | 80 WebSocketError websocket_error_; |
| 81 | 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(WebSocketFrameParser); | 82 DISALLOW_COPY_AND_ASSIGN(WebSocketFrameParser); |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 } // namespace net | 85 } // namespace net |
| 86 | 86 |
| 87 #endif // NET_WEBSOCKETS_WEBSOCKET_FRAME_PARSER_H_ | 87 #endif // NET_WEBSOCKETS_WEBSOCKET_FRAME_PARSER_H_ |
| OLD | NEW |