| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 bool WriteUInt32(uint32 value) { | 103 bool WriteUInt32(uint32 value) { |
| 104 value = htonl(value); | 104 value = htonl(value); |
| 105 return WriteBytes(&value, sizeof(value)); | 105 return WriteBytes(&value, sizeof(value)); |
| 106 } | 106 } |
| 107 bool WriteUInt64(uint64 value) { | 107 bool WriteUInt64(uint64 value) { |
| 108 uint32 upper = htonl(value >> 32); | 108 uint32 upper = htonl(value >> 32); |
| 109 uint32 lower = htonl(static_cast<uint32>(value)); | 109 uint32 lower = htonl(static_cast<uint32>(value)); |
| 110 return (WriteBytes(&upper, sizeof(upper)) && | 110 return (WriteBytes(&upper, sizeof(upper)) && |
| 111 WriteBytes(&lower, sizeof(lower))); | 111 WriteBytes(&lower, sizeof(lower))); |
| 112 } | 112 } |
| 113 // TODO(hkhalil) Rename to WriteStringPiece16(). | 113 bool WriteStringPiece16(const base::StringPiece& value); |
| 114 bool WriteString(const std::string& value); | |
| 115 bool WriteStringPiece32(const base::StringPiece& value); | 114 bool WriteStringPiece32(const base::StringPiece& value); |
| 116 bool WriteBytes(const void* data, uint32 data_len); | 115 bool WriteBytes(const void* data, uint32 data_len); |
| 117 | 116 |
| 118 // Update (in-place) the length field in the frame being built to reflect the | 117 // Update (in-place) the length field in the frame being built to reflect the |
| 119 // current actual length of bytes written to said frame through this builder. | 118 // current actual length of bytes written to said frame through this builder. |
| 120 // The framer parameter is used to determine version-specific location and | 119 // The framer parameter is used to determine version-specific location and |
| 121 // size information of the length field to be written, and must be initialized | 120 // size information of the length field to be written, and must be initialized |
| 122 // with the correct version for the frame being written. | 121 // with the correct version for the frame being written. |
| 123 bool RewriteLength(const SpdyFramer& framer); | 122 bool RewriteLength(const SpdyFramer& framer); |
| 124 | 123 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 143 size_t capacity_; // Allocation size of payload, set by constructor. | 142 size_t capacity_; // Allocation size of payload, set by constructor. |
| 144 size_t length_; // Length of the latest frame in the buffer. | 143 size_t length_; // Length of the latest frame in the buffer. |
| 145 size_t offset_; // Position at which the latest frame begins. | 144 size_t offset_; // Position at which the latest frame begins. |
| 146 | 145 |
| 147 const SpdyMajorVersion version_; | 146 const SpdyMajorVersion version_; |
| 148 }; | 147 }; |
| 149 | 148 |
| 150 } // namespace net | 149 } // namespace net |
| 151 | 150 |
| 152 #endif // NET_SPDY_SPDY_FRAME_BUILDER_H_ | 151 #endif // NET_SPDY_SPDY_FRAME_BUILDER_H_ |
| OLD | NEW |