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 IOBuffer; | |
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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. |
77 std::vector<char> data; | 80 scoped_refptr<IOBuffer> data; |
81 | |
82 // |size| represents size of |data| in bytes. | |
83 uint64_t size; | |
mmenke
2012/07/26 14:44:45
Do we really need a 64-bit unsigned integer for si
Yuta Kitamura
2012/07/27 08:01:08
Agreed, at least |size| should be an int.
I think
Takashi Toyoshima
2012/07/27 10:28:43
This payload data represents a object in JavaScrip
| |
78 }; | 84 }; |
79 | 85 |
80 // Contains four-byte data representing "masking key" of WebSocket frames. | 86 // Contains four-byte data representing "masking key" of WebSocket frames. |
81 struct WebSocketMaskingKey { | 87 struct WebSocketMaskingKey { |
82 char key[WebSocketFrameHeader::kMaskingKeyLength]; | 88 char key[WebSocketFrameHeader::kMaskingKeyLength]; |
83 }; | 89 }; |
84 | 90 |
85 // Writes wire format of a WebSocket frame header into |output|, and returns | 91 // Writes wire format of a WebSocket frame header into |output|, and returns |
86 // the number of bytes written. | 92 // the number of bytes written. |
87 // | 93 // |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 // used for unmasking a WebSocket frame. | 127 // used for unmasking a WebSocket frame. |
122 NET_EXPORT_PRIVATE void MaskWebSocketFramePayload( | 128 NET_EXPORT_PRIVATE void MaskWebSocketFramePayload( |
123 const WebSocketMaskingKey& masking_key, | 129 const WebSocketMaskingKey& masking_key, |
124 uint64 frame_offset, | 130 uint64 frame_offset, |
125 char* data, | 131 char* data, |
126 int data_size); | 132 int data_size); |
127 | 133 |
128 } // namespace net | 134 } // namespace net |
129 | 135 |
130 #endif // NET_WEBSOCKETS_WEBSOCKET_FRAME_H_ | 136 #endif // NET_WEBSOCKETS_WEBSOCKET_FRAME_H_ |
OLD | NEW |