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

Side by Side Diff: net/spdy/spdy_frame_builder.h

Issue 10053029: Factor out the code to write control frame headers into a new constructor of SpdyFrameBuilder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add Data frame constructor 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
« no previous file with comments | « no previous file | net/spdy/spdy_frame_builder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_SPDY_SPDY_FRAME_BUILDER_H_ 5 #ifndef NET_SPDY_SPDY_FRAME_BUILDER_H_
6 #define NET_SPDY_SPDY_FRAME_BUILDER_H_ 6 #define NET_SPDY_SPDY_FRAME_BUILDER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/string_piece.h" 12 #include "base/string_piece.h"
13 #include "base/sys_byteorder.h" 13 #include "base/sys_byteorder.h"
14 #include "net/base/net_export.h" 14 #include "net/base/net_export.h"
15 #include "net/spdy/spdy_protocol.h" 15 #include "net/spdy/spdy_protocol.h"
16 16
17 namespace net { 17 namespace net {
18 18
19 // This class provides facilities for basic binary value packing and unpacking 19 // This class provides facilities for basic binary value packing and unpacking
20 // into Spdy frames. 20 // into Spdy frames.
21 // 21 //
22 // The SpdyFrameBuilder supports appending primitive values (int, string, etc) 22 // The SpdyFrameBuilder supports appending primitive values (int, string, etc)
23 // to a frame instance. The SpdyFrameBuilder grows its internal memory buffer 23 // to a frame instance. The SpdyFrameBuilder grows its internal memory buffer
24 // dynamically to hold the sequence of primitive values. The internal memory 24 // dynamically to hold the sequence of primitive values. The internal memory
25 // buffer is exposed as the "data" of the SpdyFrameBuilder. 25 // buffer is exposed as the "data" of the SpdyFrameBuilder.
26 class NET_EXPORT_PRIVATE SpdyFrameBuilder { 26 class NET_EXPORT_PRIVATE SpdyFrameBuilder {
27 public: 27 public:
28 ~SpdyFrameBuilder(); 28 ~SpdyFrameBuilder();
29 29
30 SpdyFrameBuilder(); 30 // Initializes a SpdyFrameBuilder with a buffer of given size,
31 // populate with a SPDY control frame header based
32 // on |type|, |flags|, and |spdy_version|.
33 SpdyFrameBuilder(SpdyControlType type, SpdyControlFlags flags,
34 int spdy_version, size_t size);
31 35
32 // Initiailizes a SpdyFrameBuilder with a buffer of given size. 36 // Initiailizes a SpdyFrameBuilder with a buffer of given size,
33 explicit SpdyFrameBuilder(size_t size); 37 // populated with a SPDY data frame header based on
38 // |stream_id| and |flags|.
39 SpdyFrameBuilder(SpdyStreamId stream_id, SpdyDataFlags flags, size_t size);
34 40
35 // Returns the size of the SpdyFrameBuilder's data. 41 // Returns the size of the SpdyFrameBuilder's data.
36 int length() const { return length_; } 42 int length() const { return length_; }
37 43
38 // Takes the buffer from the SpdyFrameBuilder. 44 // Takes the buffer from the SpdyFrameBuilder.
39 SpdyFrame* take() { 45 SpdyFrame* take() {
40 SpdyFrame* rv = new SpdyFrame(buffer_, true); 46 SpdyFrame* rv = new SpdyFrame(buffer_, true);
41 buffer_ = NULL; 47 buffer_ = NULL;
42 capacity_ = 0; 48 capacity_ = 0;
43 length_ = 0; 49 length_ = 0;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 char* BeginWrite(size_t length); 124 char* BeginWrite(size_t length);
119 125
120 char* buffer_; 126 char* buffer_;
121 size_t capacity_; // Allocation size of payload (or -1 if buffer is const). 127 size_t capacity_; // Allocation size of payload (or -1 if buffer is const).
122 size_t length_; // current length of the buffer 128 size_t length_; // current length of the buffer
123 }; 129 };
124 130
125 } // namespace net 131 } // namespace net
126 132
127 #endif // NET_SPDY_SPDY_FRAME_BUILDER_H_ 133 #endif // NET_SPDY_SPDY_FRAME_BUILDER_H_
OLDNEW
« no previous file with comments | « no previous file | net/spdy/spdy_frame_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698