| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "net/base/net_api.h" | 12 #include "net/base/net_export.h" |
| 13 #include "net/base/sys_byteorder.h" | 13 #include "net/base/sys_byteorder.h" |
| 14 #include "net/spdy/spdy_protocol.h" | 14 #include "net/spdy/spdy_protocol.h" |
| 15 | 15 |
| 16 namespace spdy { | 16 namespace spdy { |
| 17 | 17 |
| 18 // This class provides facilities for basic binary value packing and unpacking | 18 // This class provides facilities for basic binary value packing and unpacking |
| 19 // into Spdy frames. | 19 // into Spdy frames. |
| 20 // | 20 // |
| 21 // The SpdyFrameBuilder supports appending primitive values (int, string, etc) | 21 // The SpdyFrameBuilder supports appending primitive values (int, string, etc) |
| 22 // to a frame instance. The SpdyFrameBuilder grows its internal memory buffer | 22 // to a frame instance. The SpdyFrameBuilder grows its internal memory buffer |
| 23 // dynamically to hold the sequence of primitive values. The internal memory | 23 // dynamically to hold the sequence of primitive values. The internal memory |
| 24 // buffer is exposed as the "data" of the SpdyFrameBuilder. | 24 // buffer is exposed as the "data" of the SpdyFrameBuilder. |
| 25 // | 25 // |
| 26 // When reading from a SpdyFrameBuilder the consumer must know what value types | 26 // When reading from a SpdyFrameBuilder the consumer must know what value types |
| 27 // to read and in what order to read them as the SpdyFrameBuilder does not keep | 27 // to read and in what order to read them as the SpdyFrameBuilder does not keep |
| 28 // track of the type of data written to it. | 28 // track of the type of data written to it. |
| 29 class NET_TEST SpdyFrameBuilder { | 29 class NET_EXPORT_PRIVATE SpdyFrameBuilder { |
| 30 public: | 30 public: |
| 31 SpdyFrameBuilder(); | 31 SpdyFrameBuilder(); |
| 32 | 32 |
| 33 // Initializes a SpdyFrameBuilder from a const block of data. The data is | 33 // Initializes a SpdyFrameBuilder from a const block of data. The data is |
| 34 // not copied; instead the data is merely referenced by this | 34 // not copied; instead the data is merely referenced by this |
| 35 // SpdyFrameBuilder. Only const methods should be used when initialized | 35 // SpdyFrameBuilder. Only const methods should be used when initialized |
| 36 // this way. | 36 // this way. |
| 37 SpdyFrameBuilder(const char* data, int data_len); | 37 SpdyFrameBuilder(const char* data, int data_len); |
| 38 | 38 |
| 39 ~SpdyFrameBuilder(); | 39 ~SpdyFrameBuilder(); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 private: | 151 private: |
| 152 char* buffer_; | 152 char* buffer_; |
| 153 size_t capacity_; // Allocation size of payload (or -1 if buffer is const). | 153 size_t capacity_; // Allocation size of payload (or -1 if buffer is const). |
| 154 size_t length_; // current length of the buffer | 154 size_t length_; // current length of the buffer |
| 155 size_t variable_buffer_offset_; // IF non-zero, then offset to a buffer. | 155 size_t variable_buffer_offset_; // IF non-zero, then offset to a buffer. |
| 156 }; | 156 }; |
| 157 | 157 |
| 158 } // namespace spdy | 158 } // namespace spdy |
| 159 | 159 |
| 160 #endif // NET_SPDY_SPDY_FRAME_BUILDER_H_ | 160 #endif // NET_SPDY_SPDY_FRAME_BUILDER_H_ |
| OLD | NEW |