Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: net/websockets/websocket_frame.h

Issue 9956013: Add WebSocketFrameParser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef NET_WEBSOCKETS_WEBSOCKET_FRAME_H_
6 #define NET_WEBSOCKETS_WEBSOCKET_FRAME_H_
7 #pragma once
8
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h"
13 #include "net/base/net_export.h"
14
15 namespace net {
16
17 // Represents a WebSocket frame header which may be shared by multiple
18 // WebSocketPartialFrames.
19 struct NET_EXPORT_PRIVATE WebSocketFrameHeader
20 : public base::RefCounted<WebSocketFrameHeader> {
21 typedef int OpCode;
22 static const OpCode kOpCodeContinuation;
23 static const OpCode kOpCodeText;
24 static const OpCode kOpCodeBinary;
25 static const OpCode kOpCodeClose;
26 static const OpCode kOpCodePing;
27 static const OpCode kOpCodePong;
28
29 // This value must be a compile-time constant. "enum hack" is used here
30 // to make MSVC happy.
31 enum { kMaskingKeyLength = 4 };
32
33 // Members below correspond to each item in WebSocket frame header.
34 // See <http://tools.ietf.org/html/rfc6455#section-5.2> for details.
Takashi Toyoshima 2012/04/04 05:46:21 Usually, we don't use <> to refer URLs. I could no
Yuta Kitamura 2012/04/09 08:17:57 $ git grep "<http" |wc -l 197 To my understanding
Yuta Kitamura 2012/04/09 12:12:26 Counted the number of instances of "one space befo
35 bool final;
36 bool reserved1;
37 bool reserved2;
38 bool reserved3;
39 OpCode opcode;
40 bool masked;
41 uint64 payload_length;
42 };
43
44 // Contains payload data of a WebSocket frame.
45 //
46 // Payload of a WebSocket frame may be divided into multiple
47 // WebSocketPartialFrame objects. You need to look at |final_part| member
48 // variable to detect the end of a series of partial frame objects.
49 //
50 // Frame dissection is necessary to handle WebSocket frame stream containing
51 // abritrarily large frames in the browser process. Because the server may send
52 // a huge frame that doesn't fit in the memory, we cannot store the entire
53 // payload data in the memory.
54 //
55 // Users of this struct should treat WebSocket frames as a data stream; it's
56 // important to keep the frame data flowing, especially in the browser.
57 // Do not let the data stuck somewhere in the pipeline.
58 struct NET_EXPORT_PRIVATE WebSocketPartialFrame {
59 WebSocketPartialFrame();
60 ~WebSocketPartialFrame();
61
62 // |header| may be shared among multiple WebSocketPartialFrames.
63 scoped_refptr<const WebSocketFrameHeader> header;
64
65 // Indicates this part is the last of partial frames.
66 bool final_part;
67
68 // |data| is always unmasked even if the frame is masked.
69 std::vector<char> data;
70 };
71
72 } // namespace net
73
74 #endif // NET_WEBSOCKETS_WEBSOCKET_FRAME_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698