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_H_ | 5 #ifndef NET_WEBSOCKETS_WEBSOCKET_FRAME_H_ |
6 #define NET_WEBSOCKETS_WEBSOCKET_FRAME_H_ | 6 #define NET_WEBSOCKETS_WEBSOCKET_FRAME_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/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
12 #include "net/base/net_export.h" | 13 #include "net/base/net_export.h" |
13 | 14 |
14 namespace net { | 15 namespace net { |
15 | 16 |
| 17 class IOBufferWithSize; |
| 18 |
16 // Represents a WebSocket frame header. | 19 // Represents a WebSocket frame header. |
17 // | 20 // |
18 // Members of this class correspond to each element in WebSocket frame header | 21 // Members of this class correspond to each element in WebSocket frame header |
19 // (see http://tools.ietf.org/html/rfc6455#section-5.2). | 22 // (see http://tools.ietf.org/html/rfc6455#section-5.2). |
20 struct NET_EXPORT_PRIVATE WebSocketFrameHeader { | 23 struct NET_EXPORT_PRIVATE WebSocketFrameHeader { |
21 typedef int OpCode; | 24 typedef int OpCode; |
22 static const OpCode kOpCodeContinuation; | 25 static const OpCode kOpCodeContinuation; |
23 static const OpCode kOpCodeText; | 26 static const OpCode kOpCodeText; |
24 static const OpCode kOpCodeBinary; | 27 static const OpCode kOpCodeBinary; |
25 static const OpCode kOpCodeClose; | 28 static const OpCode kOpCodeClose; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 WebSocketFrameChunk(); | 69 WebSocketFrameChunk(); |
67 ~WebSocketFrameChunk(); | 70 ~WebSocketFrameChunk(); |
68 | 71 |
69 // Non-null |header| is provided only if this chunk is the first part of | 72 // Non-null |header| is provided only if this chunk is the first part of |
70 // a series of chunks. | 73 // a series of chunks. |
71 scoped_ptr<WebSocketFrameHeader> header; | 74 scoped_ptr<WebSocketFrameHeader> header; |
72 | 75 |
73 // Indicates this part is the last chunk of a frame. | 76 // Indicates this part is the last chunk of a frame. |
74 bool final_chunk; | 77 bool final_chunk; |
75 | 78 |
76 // |data| is always unmasked even if the frame is masked. | 79 // |data| is always unmasked even if the frame is masked. |data| might be |
77 std::vector<char> data; | 80 // null in the first chunk. |
| 81 scoped_refptr<IOBufferWithSize> data; |
78 }; | 82 }; |
79 | 83 |
80 // Contains four-byte data representing "masking key" of WebSocket frames. | 84 // Contains four-byte data representing "masking key" of WebSocket frames. |
81 struct WebSocketMaskingKey { | 85 struct WebSocketMaskingKey { |
82 char key[WebSocketFrameHeader::kMaskingKeyLength]; | 86 char key[WebSocketFrameHeader::kMaskingKeyLength]; |
83 }; | 87 }; |
84 | 88 |
85 // Writes wire format of a WebSocket frame header into |output|, and returns | 89 // Writes wire format of a WebSocket frame header into |output|, and returns |
86 // the number of bytes written. | 90 // the number of bytes written. |
87 // | 91 // |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 // used for unmasking a WebSocket frame. | 125 // used for unmasking a WebSocket frame. |
122 NET_EXPORT_PRIVATE void MaskWebSocketFramePayload( | 126 NET_EXPORT_PRIVATE void MaskWebSocketFramePayload( |
123 const WebSocketMaskingKey& masking_key, | 127 const WebSocketMaskingKey& masking_key, |
124 uint64 frame_offset, | 128 uint64 frame_offset, |
125 char* data, | 129 char* data, |
126 int data_size); | 130 int data_size); |
127 | 131 |
128 } // namespace net | 132 } // namespace net |
129 | 133 |
130 #endif // NET_WEBSOCKETS_WEBSOCKET_FRAME_H_ | 134 #endif // NET_WEBSOCKETS_WEBSOCKET_FRAME_H_ |
OLD | NEW |