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" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
14 #include "net/base/net_export.h" | 14 #include "net/base/net_export.h" |
15 #include "net/websockets/websocket_frame.h" | 15 #include "net/websockets/websocket_frame.h" |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 | 18 |
19 // Parses WebSocket frames from byte stream. | 19 // Parses WebSocket frames from byte stream. |
20 // | 20 // |
21 // Specification of WebSocket frame format is available at | 21 // Specification of WebSocket frame format is available at |
22 // <http://tools.ietf.org/html/rfc6455#section-5>. | 22 // <http://tools.ietf.org/html/rfc6455#section-5>. |
23 | 23 |
24 class NET_EXPORT_PRIVATE WebSocketFrameParser { | 24 class NET_EXPORT_PRIVATE WebSocketFrameParser { |
25 public: | 25 public: |
26 WebSocketFrameParser(); | 26 WebSocketFrameParser(); |
27 ~WebSocketFrameParser(); | 27 ~WebSocketFrameParser(); |
28 | 28 |
29 // Decodes the given byte stream and stores parsed WebSocket frames in | 29 // Decodes the given byte stream and stores parsed WebSocket frames in |
30 // |frames|. | 30 // |frame_chunks|. |
31 // | 31 // |
32 // If the parser encounters invalid payload length format, Decode() fails | 32 // If the parser encounters invalid payload length format, Decode() fails |
33 // and returns false. Once Decode() has failed, the parser refuses to decode | 33 // and returns false. Once Decode() has failed, the parser refuses to decode |
34 // any more data and future invocations of Decode() will simply return false. | 34 // any more data and future invocations of Decode() will simply return false. |
35 // | 35 // |
36 // Payload data of parsed WebSocket frames may be incomplete; see comments in | 36 // Payload data of parsed WebSocket frames may be incomplete; see comments in |
37 // websocket_frame.h for more details. | 37 // websocket_frame.h for more details. |
38 bool Decode(const char* data, | 38 bool Decode(const char* data, |
39 size_t length, | 39 size_t length, |
40 ScopedVector<WebSocketFrameChunk>* frame_chunks); | 40 ScopedVector<WebSocketFrameChunk>* frame_chunks); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 uint64 frame_offset_; | 75 uint64 frame_offset_; |
76 | 76 |
77 bool failed_; | 77 bool failed_; |
78 | 78 |
79 DISALLOW_COPY_AND_ASSIGN(WebSocketFrameParser); | 79 DISALLOW_COPY_AND_ASSIGN(WebSocketFrameParser); |
80 }; | 80 }; |
81 | 81 |
82 } // namespace net | 82 } // namespace net |
83 | 83 |
84 #endif // NET_WEBSOCKETS_WEBSOCKET_FRAME_PARSER_H_ | 84 #endif // NET_WEBSOCKETS_WEBSOCKET_FRAME_PARSER_H_ |
OLD | NEW |