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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 // Methods for adding to the payload. These values are appended to the end | 88 // Methods for adding to the payload. These values are appended to the end |
89 // of the SpdyFrameBuilder payload. Note - binary integers are converted from | 89 // of the SpdyFrameBuilder payload. Note - binary integers are converted from |
90 // host to network form. | 90 // host to network form. |
91 bool WriteUInt8(uint8 value) { | 91 bool WriteUInt8(uint8 value) { |
92 return WriteBytes(&value, sizeof(value)); | 92 return WriteBytes(&value, sizeof(value)); |
93 } | 93 } |
94 bool WriteUInt16(uint16 value) { | 94 bool WriteUInt16(uint16 value) { |
95 value = htons(value); | 95 value = htons(value); |
96 return WriteBytes(&value, sizeof(value)); | 96 return WriteBytes(&value, sizeof(value)); |
97 } | 97 } |
| 98 bool WriteUInt24(uint32 value) { |
| 99 value = htonl(value); |
| 100 return WriteBytes(reinterpret_cast<char*>(&value) + 1, |
| 101 sizeof(value) - 1); |
| 102 } |
98 bool WriteUInt32(uint32 value) { | 103 bool WriteUInt32(uint32 value) { |
99 value = htonl(value); | 104 value = htonl(value); |
100 return WriteBytes(&value, sizeof(value)); | 105 return WriteBytes(&value, sizeof(value)); |
101 } | 106 } |
102 bool WriteUInt64(uint64 value) { | 107 bool WriteUInt64(uint64 value) { |
103 uint32 upper = htonl(value >> 32); | 108 uint32 upper = htonl(value >> 32); |
104 uint32 lower = htonl(value); | 109 uint32 lower = htonl(value); |
105 return (WriteBytes(&upper, sizeof(upper)) && | 110 return (WriteBytes(&upper, sizeof(upper)) && |
106 WriteBytes(&lower, sizeof(lower))); | 111 WriteBytes(&lower, sizeof(lower))); |
107 } | 112 } |
(...skipping 30 matching lines...) Expand all Loading... |
138 size_t capacity_; // Allocation size of payload, set by constructor. | 143 size_t capacity_; // Allocation size of payload, set by constructor. |
139 size_t length_; // Length of the latest frame in the buffer. | 144 size_t length_; // Length of the latest frame in the buffer. |
140 size_t offset_; // Position at which the latest frame begins. | 145 size_t offset_; // Position at which the latest frame begins. |
141 | 146 |
142 const SpdyMajorVersion version_; | 147 const SpdyMajorVersion version_; |
143 }; | 148 }; |
144 | 149 |
145 } // namespace net | 150 } // namespace net |
146 | 151 |
147 #endif // NET_SPDY_SPDY_FRAME_BUILDER_H_ | 152 #endif // NET_SPDY_SPDY_FRAME_BUILDER_H_ |
OLD | NEW |