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 #include "net/spdy/spdy_frame_builder.h" | 5 #include "net/spdy/spdy_frame_builder.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "net/spdy/spdy_framer.h" | 10 #include "net/spdy/spdy_framer.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 sizeof(flags_length) - 1); | 175 sizeof(flags_length) - 1); |
176 } else { | 176 } else { |
177 length_ = 0; | 177 length_ = 0; |
178 success = WriteUInt16(length); | 178 success = WriteUInt16(length); |
179 } | 179 } |
180 | 180 |
181 length_ = old_length; | 181 length_ = old_length; |
182 return success; | 182 return success; |
183 } | 183 } |
184 | 184 |
| 185 bool SpdyFrameBuilder::OverwriteFlags(const SpdyFramer& framer, |
| 186 uint8 flags) { |
| 187 DCHECK_LE(SPDY4, framer.protocol_version()); |
| 188 bool success = false; |
| 189 const size_t old_length = length_; |
| 190 // Flags are the fourth octet in the frame prefix. |
| 191 length_ = 3; |
| 192 success = WriteUInt8(flags); |
| 193 length_ = old_length; |
| 194 return success; |
| 195 } |
| 196 |
185 bool SpdyFrameBuilder::CanWrite(size_t length) const { | 197 bool SpdyFrameBuilder::CanWrite(size_t length) const { |
186 if (length > kLengthMask) { | 198 if (length > kLengthMask) { |
187 DCHECK(false); | 199 DCHECK(false); |
188 return false; | 200 return false; |
189 } | 201 } |
190 | 202 |
191 if (length_ + length > capacity_) { | 203 if (length_ + length > capacity_) { |
192 DCHECK(false); | 204 DCHECK(false); |
193 return false; | 205 return false; |
194 } | 206 } |
195 | 207 |
196 return true; | 208 return true; |
197 } | 209 } |
198 | 210 |
199 } // namespace net | 211 } // namespace net |
OLD | NEW |