| OLD | NEW |
| 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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 // Returns NULL on failure. | 43 // Returns NULL on failure. |
| 44 char* GetWritableBuffer(size_t length); | 44 char* GetWritableBuffer(size_t length); |
| 45 | 45 |
| 46 // Seeks forward by the given number of bytes. Useful in conjunction with | 46 // Seeks forward by the given number of bytes. Useful in conjunction with |
| 47 // GetWriteableBuffer() above. | 47 // GetWriteableBuffer() above. |
| 48 bool Seek(size_t length); | 48 bool Seek(size_t length); |
| 49 | 49 |
| 50 // Populates this frame with a SPDY control frame header using | 50 // Populates this frame with a SPDY control frame header using |
| 51 // version-specific information from the |framer| and length information from | 51 // version-specific information from the |framer| and length information from |
| 52 // capacity_. The given type must be a control frame type. | 52 // capacity_. The given type must be a control frame type. |
| 53 // Used only for SPDY versions <4. |
| 53 bool WriteControlFrameHeader(const SpdyFramer& framer, | 54 bool WriteControlFrameHeader(const SpdyFramer& framer, |
| 54 SpdyFrameType type, | 55 SpdyFrameType type, |
| 55 uint8 flags); | 56 uint8 flags); |
| 56 | 57 |
| 57 // Populates this frame with a SPDY data frame header using version-specific | 58 // Populates this frame with a SPDY data frame header using version-specific |
| 58 // information from the |framer| and length information from capacity_. | 59 // information from the |framer| and length information from capacity_. |
| 59 bool WriteDataFrameHeader(const SpdyFramer& framer, | 60 bool WriteDataFrameHeader(const SpdyFramer& framer, |
| 60 SpdyStreamId stream_id, | 61 SpdyStreamId stream_id, |
| 61 SpdyDataFlags flags); | 62 SpdyDataFlags flags); |
| 62 | 63 |
| 64 // Populates this frame with a SPDY4/HTTP2 frame prefix using |
| 65 // version-specific information from the |framer| and length information from |
| 66 // capacity_. The given type must be a control frame type. |
| 67 // Used only for SPDY versions >=4. |
| 68 bool WriteFramePrefix(const SpdyFramer& framer, |
| 69 SpdyFrameType type, |
| 70 uint8 flags, |
| 71 SpdyStreamId stream_id); |
| 72 |
| 63 // Takes the buffer from the SpdyFrameBuilder. | 73 // Takes the buffer from the SpdyFrameBuilder. |
| 64 SpdyFrame* take() { | 74 SpdyFrame* take() { |
| 65 SpdyFrame* rv = new SpdyFrame(buffer_.release(), length_, true); | 75 SpdyFrame* rv = new SpdyFrame(buffer_.release(), length_, true); |
| 66 capacity_ = 0; | 76 capacity_ = 0; |
| 67 length_ = 0; | 77 length_ = 0; |
| 68 return rv; | 78 return rv; |
| 69 } | 79 } |
| 70 | 80 |
| 71 // Methods for adding to the payload. These values are appended to the end | 81 // Methods for adding to the payload. These values are appended to the end |
| 72 // of the SpdyFrameBuilder payload. Note - binary integers are converted from | 82 // of the SpdyFrameBuilder payload. Note - binary integers are converted from |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 bool CanWrite(size_t length) const; | 120 bool CanWrite(size_t length) const; |
| 111 | 121 |
| 112 scoped_ptr<char[]> buffer_; | 122 scoped_ptr<char[]> buffer_; |
| 113 size_t capacity_; // Allocation size of payload, set by constructor. | 123 size_t capacity_; // Allocation size of payload, set by constructor. |
| 114 size_t length_; // Current length of the buffer. | 124 size_t length_; // Current length of the buffer. |
| 115 }; | 125 }; |
| 116 | 126 |
| 117 } // namespace net | 127 } // namespace net |
| 118 | 128 |
| 119 #endif // NET_SPDY_SPDY_FRAME_BUILDER_H_ | 129 #endif // NET_SPDY_SPDY_FRAME_BUILDER_H_ |
| OLD | NEW |