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 <algorithm> | 7 #include <algorithm> |
8 #include <cstdint> | 8 #include <cstdint> |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 return success; | 124 return success; |
125 } | 125 } |
126 | 126 |
127 bool SpdyFrameBuilder::BeginNewFrame(const SpdyFramer& framer, | 127 bool SpdyFrameBuilder::BeginNewFrame(const SpdyFramer& framer, |
128 SpdyFrameType type, | 128 SpdyFrameType type, |
129 uint8_t flags, | 129 uint8_t flags, |
130 SpdyStreamId stream_id, | 130 SpdyStreamId stream_id, |
131 size_t length) { | 131 size_t length) { |
132 uint8_t raw_frame_type = SerializeFrameType(type); | 132 uint8_t raw_frame_type = SerializeFrameType(type); |
133 DCHECK(IsDefinedFrameType(raw_frame_type)); | 133 DCHECK(IsDefinedFrameType(raw_frame_type)); |
| 134 return BeginNewFrameInternal(framer, raw_frame_type, flags, stream_id, |
| 135 length); |
| 136 } |
| 137 |
| 138 bool SpdyFrameBuilder::BeginNewExtensionFrame(const SpdyFramer& framer, |
| 139 uint8_t raw_frame_type, |
| 140 uint8_t flags, |
| 141 SpdyStreamId stream_id, |
| 142 size_t length) { |
| 143 DCHECK(!IsDefinedFrameType(raw_frame_type)); |
| 144 return BeginNewFrameInternal(framer, raw_frame_type, flags, stream_id, |
| 145 length); |
| 146 } |
| 147 |
| 148 bool SpdyFrameBuilder::BeginNewFrameInternal(const SpdyFramer& framer, |
| 149 uint8_t raw_frame_type, |
| 150 uint8_t flags, |
| 151 SpdyStreamId stream_id, |
| 152 size_t length) { |
134 DCHECK_EQ(0u, stream_id & ~kStreamIdMask); | 153 DCHECK_EQ(0u, stream_id & ~kStreamIdMask); |
135 bool success = true; | 154 bool success = true; |
136 SPDY_BUG_IF(framer.GetFrameMaximumSize() < length_) | 155 SPDY_BUG_IF(framer.GetFrameMaximumSize() < length_) |
137 << "Frame length " << length_ | 156 << "Frame length " << length_ |
138 << " is longer than the maximum allowed length."; | 157 << " is longer than the maximum allowed length."; |
139 | 158 |
140 offset_ += length_; | 159 offset_ += length_; |
141 length_ = 0; | 160 length_ = 0; |
142 | 161 |
143 success &= WriteUInt24(length); | 162 success &= WriteUInt24(length); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 } else { | 271 } else { |
253 if (length > output_->BytesFree()) { | 272 if (length > output_->BytesFree()) { |
254 return false; | 273 return false; |
255 } | 274 } |
256 } | 275 } |
257 | 276 |
258 return true; | 277 return true; |
259 } | 278 } |
260 | 279 |
261 } // namespace net | 280 } // namespace net |
OLD | NEW |