| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 // actual frame length. | 123 // actual frame length. |
| 124 success &= WriteUInt24(capacity_ - offset_ - framer.GetPrefixLength(type)); | 124 success &= WriteUInt24(capacity_ - offset_ - framer.GetPrefixLength(type)); |
| 125 success &= WriteUInt8( | 125 success &= WriteUInt8( |
| 126 SpdyConstants::SerializeFrameType(version_, type)); | 126 SpdyConstants::SerializeFrameType(version_, type)); |
| 127 success &= WriteUInt8(flags); | 127 success &= WriteUInt8(flags); |
| 128 success &= WriteUInt32(stream_id); | 128 success &= WriteUInt32(stream_id); |
| 129 DCHECK_EQ(framer.GetDataFrameMinimumSize(), length_); | 129 DCHECK_EQ(framer.GetDataFrameMinimumSize(), length_); |
| 130 return success; | 130 return success; |
| 131 } | 131 } |
| 132 | 132 |
| 133 bool SpdyFrameBuilder::WriteString(const std::string& value) { | 133 bool SpdyFrameBuilder::WriteStringPiece16(const base::StringPiece& value) { |
| 134 if (value.size() > 0xffff) { | 134 if (value.size() > 0xffff) { |
| 135 DCHECK(false) << "Tried to write string with length > 16bit."; | 135 DCHECK(false) << "Tried to write string with length > 16bit."; |
| 136 return false; | 136 return false; |
| 137 } | 137 } |
| 138 | 138 |
| 139 if (!WriteUInt16(static_cast<uint16>(value.size()))) | 139 if (!WriteUInt16(static_cast<uint16>(value.size()))) |
| 140 return false; | 140 return false; |
| 141 | 141 |
| 142 return WriteBytes(value.data(), static_cast<uint16>(value.size())); | 142 return WriteBytes(value.data(), static_cast<uint16>(value.size())); |
| 143 } | 143 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 216 |
| 217 if (offset_ + length_ + length > capacity_) { | 217 if (offset_ + length_ + length > capacity_) { |
| 218 DCHECK(false); | 218 DCHECK(false); |
| 219 return false; | 219 return false; |
| 220 } | 220 } |
| 221 | 221 |
| 222 return true; | 222 return true; |
| 223 } | 223 } |
| 224 | 224 |
| 225 } // namespace net | 225 } // namespace net |
| OLD | NEW |