OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifdef WIN32 | 9 #ifdef WIN32 |
10 #include <winsock2.h> // for htonl() functions | 10 #include <winsock2.h> // for htonl() functions |
(...skipping 15 matching lines...) Expand all Loading... |
26 // to a frame instance. The SpdyFrameBuilder grows its internal memory buffer | 26 // to a frame instance. The SpdyFrameBuilder grows its internal memory buffer |
27 // dynamically to hold the sequence of primitive values. The internal memory | 27 // dynamically to hold the sequence of primitive values. The internal memory |
28 // buffer is exposed as the "data" of the SpdyFrameBuilder. | 28 // buffer is exposed as the "data" of the SpdyFrameBuilder. |
29 // | 29 // |
30 // When reading from a SpdyFrameBuilder the consumer must know what value types | 30 // When reading from a SpdyFrameBuilder the consumer must know what value types |
31 // to read and in what order to read them as the SpdyFrameBuilder does not keep | 31 // to read and in what order to read them as the SpdyFrameBuilder does not keep |
32 // track of the type of data written to it. | 32 // track of the type of data written to it. |
33 class SpdyFrameBuilder { | 33 class SpdyFrameBuilder { |
34 public: | 34 public: |
35 SpdyFrameBuilder(); | 35 SpdyFrameBuilder(); |
36 ~SpdyFrameBuilder(); | |
37 | 36 |
38 // Initializes a SpdyFrameBuilder from a const block of data. The data is | 37 // Initializes a SpdyFrameBuilder from a const block of data. The data is |
39 // not copied; instead the data is merely referenced by this | 38 // not copied; instead the data is merely referenced by this |
40 // SpdyFrameBuilder. Only const methods should be used when initialized | 39 // SpdyFrameBuilder. Only const methods should be used when initialized |
41 // this way. | 40 // this way. |
42 SpdyFrameBuilder(const char* data, int data_len); | 41 SpdyFrameBuilder(const char* data, int data_len); |
43 | 42 |
| 43 ~SpdyFrameBuilder(); |
| 44 |
44 // Returns the size of the SpdyFrameBuilder's data. | 45 // Returns the size of the SpdyFrameBuilder's data. |
45 int length() const { return length_; } | 46 int length() const { return length_; } |
46 | 47 |
47 // Takes the buffer from the SpdyFrameBuilder. | 48 // Takes the buffer from the SpdyFrameBuilder. |
48 SpdyFrame* take() { | 49 SpdyFrame* take() { |
49 SpdyFrame* rv = new SpdyFrame(buffer_, true); | 50 SpdyFrame* rv = new SpdyFrame(buffer_, true); |
50 buffer_ = NULL; | 51 buffer_ = NULL; |
51 capacity_ = 0; | 52 capacity_ = 0; |
52 length_ = 0; | 53 length_ = 0; |
53 return rv; | 54 return rv; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 private: | 155 private: |
155 char* buffer_; | 156 char* buffer_; |
156 size_t capacity_; // Allocation size of payload (or -1 if buffer is const). | 157 size_t capacity_; // Allocation size of payload (or -1 if buffer is const). |
157 size_t length_; // current length of the buffer | 158 size_t length_; // current length of the buffer |
158 size_t variable_buffer_offset_; // IF non-zero, then offset to a buffer. | 159 size_t variable_buffer_offset_; // IF non-zero, then offset to a buffer. |
159 }; | 160 }; |
160 | 161 |
161 } // namespace spdy | 162 } // namespace spdy |
162 | 163 |
163 #endif // NET_SPDY_SPDY_FRAME_BUILDER_H_ | 164 #endif // NET_SPDY_SPDY_FRAME_BUILDER_H_ |
OLD | NEW |