Chromium Code Reviews| Index: net/websockets/websocket_frame.h |
| diff --git a/net/websockets/websocket_frame.h b/net/websockets/websocket_frame.h |
| index 8c04f7dce44476a8820d17fd549eaab26b9439bf..935b35b593dd267603f9abab48ec54460051f24c 100644 |
| --- a/net/websockets/websocket_frame.h |
| +++ b/net/websockets/websocket_frame.h |
| @@ -14,6 +14,7 @@ |
| namespace net { |
| +class IOBuffer; |
| class IOBufferWithSize; |
| // Represents a WebSocket frame header. |
| @@ -69,7 +70,10 @@ struct NET_EXPORT WebSocketFrameHeader { |
| payload_length(0) {} |
| // Create a clone of this object on the heap. |
| - scoped_ptr<WebSocketFrameHeader> Clone(); |
| + scoped_ptr<WebSocketFrameHeader> Clone() const; |
| + |
| + // Overwrite this object with the fields from |source|. |
| + void CopyFrom(const WebSocketFrameHeader& source); |
| // Members below correspond to each item in WebSocket frame header. |
| // See <http://tools.ietf.org/html/rfc6455#section-5.2> for details. |
| @@ -85,16 +89,32 @@ struct NET_EXPORT WebSocketFrameHeader { |
| DISALLOW_COPY_AND_ASSIGN(WebSocketFrameHeader); |
| }; |
| -// Contains payload data of part of a WebSocket frame. |
| +// Contains an entire WebSocket frame including payload. This is used by APIs |
| +// that are not concerned about retaining the original frame boundaries (because |
| +// frames may need to be split in order for the data to fit in memory). |
| +struct NET_EXPORT_PRIVATE WebSocketFrame { |
| + // A frame must always have an opcode, so this parameter is compulsory. |
| + WebSocketFrame(WebSocketFrameHeader::OpCode opcode); |
|
yhirano
2013/09/13 10:03:17
explicit
Adam Rice
2013/09/13 14:09:53
Sorry. It looks like I forgot to run cpplint.
|
| + ~WebSocketFrame(); |
| + |
| + // |header| is always present. |
| + WebSocketFrameHeader header; |
| + |
| + // |data| is always unmasked even if the frame is masked. The size of |data| |
| + // |is given by |header.payload_length|. |
| + scoped_refptr<IOBuffer> data; |
| +}; |
| + |
| +// Structure describing one chunk of a WebSocket frame. |
| // |
| -// Payload of a WebSocket frame may be divided into multiple chunks. |
| +// The payload of a WebSocket frame may be divided into multiple chunks. |
| // You need to look at |final_chunk| member variable to detect the end of a |
| // series of chunk objects of a WebSocket frame. |
| // |
| -// Frame dissection is necessary to handle WebSocket frame stream containing |
| -// abritrarily large frames in the browser process. Because the server may send |
| -// a huge frame that doesn't fit in the memory, we cannot store the entire |
| -// payload data in the memory. |
| +// Frame dissection is necessary to handle frames that are too large to store in |
| +// the browser memory without losing information about the frame boundaries. In |
| +// practice, most code does not need to worry about the original frame |
| +// boundaries and can use the WebSocketFrame type declared above. |
| // |
| // Users of this struct should treat WebSocket frames as a data stream; it's |
| // important to keep the frame data flowing, especially in the browser process. |