Index: net/spdy/spdy_framer.cc |
diff --git a/net/spdy/spdy_framer.cc b/net/spdy/spdy_framer.cc |
index 7a926ce00b5ca47ae40966b3f0018abcd1eec58d..a02cb2e30ece9b31838a60eced37929a2a33592d 100644 |
--- a/net/spdy/spdy_framer.cc |
+++ b/net/spdy/spdy_framer.cc |
@@ -158,16 +158,16 @@ SpdyFramer::SpdyFramer(SpdyMajorVersion version) |
visitor_(NULL), |
debug_visitor_(NULL), |
display_protocol_("SPDY"), |
- spdy_version_(version), |
+ protocol_version_(version), |
syn_frame_processed_(false), |
probable_http_response_(false), |
expect_continuation_(0), |
end_stream_when_done_(false) { |
- DCHECK_GE(spdy_version_, SPDY_MIN_VERSION); |
- DCHECK_LE(spdy_version_, SPDY_MAX_VERSION); |
+ DCHECK_GE(protocol_version_, SPDY_MIN_VERSION); |
+ DCHECK_LE(protocol_version_, SPDY_MAX_VERSION); |
DCHECK_LE(kMaxControlFrameSize, |
- SpdyConstants::GetFrameMaximumSize(spdy_version_) + |
- SpdyConstants::GetControlFrameHeaderSize(spdy_version_)); |
+ SpdyConstants::GetFrameMaximumSize(protocol_version_) + |
+ SpdyConstants::GetControlFrameHeaderSize(protocol_version_)); |
Reset(); |
} |
@@ -1060,7 +1060,8 @@ void SpdyFramer::ProcessControlFrameHeader(int control_frame_type_field) { |
if (current_frame_length_ > |
SpdyConstants::GetFrameMaximumSize(protocol_version()) + |
SpdyConstants::GetControlFrameHeaderSize(protocol_version())) { |
- DLOG(WARNING) << "Received control frame with way too big of a payload: " |
+ DLOG(WARNING) << "Received control frame of type " << current_frame_type_ |
+ << " with way too big of a payload: " |
<< current_frame_length_; |
set_error(SPDY_CONTROL_PAYLOAD_TOO_LARGE); |
return; |
@@ -1281,7 +1282,7 @@ static void WriteLengthZ(size_t n, |
void SpdyFramer::WriteHeaderBlockToZ(const SpdyHeaderBlock* headers, |
z_stream* z) const { |
unsigned length_length = 4; |
- if (spdy_version_ < 3) |
+ if (protocol_version() < 3) |
length_length = 2; |
WriteLengthZ(headers->size(), length_length, kZStandardData, z); |
@@ -2976,54 +2977,50 @@ void SpdyFramer::WritePayloadWithContinuation(SpdyFrameBuilder* builder, |
SpdyStreamId stream_id, |
SpdyFrameType type, |
int padding_payload_len) { |
- uint8 end_flag = 0; |
- uint8 flags = 0; |
- if (type == HEADERS) { |
- end_flag = HEADERS_FLAG_END_HEADERS; |
- } else if (type == PUSH_PROMISE) { |
- end_flag = PUSH_PROMISE_FLAG_END_PUSH_PROMISE; |
- } else { |
- DLOG(FATAL) << "CONTINUATION frames cannot be used with frame type " |
- << FrameTypeToString(type); |
- } |
- |
- // Write all the padding payload and as much of the data payload as possible |
- // into the initial frame. |
- size_t bytes_remaining = 0; |
- bytes_remaining = hpack_encoding.size() - |
- std::min(hpack_encoding.size(), |
- kMaxControlFrameSize - builder->length() - |
- padding_payload_len); |
- builder->WriteBytes(&hpack_encoding[0], |
- hpack_encoding.size() - bytes_remaining); |
- if (padding_payload_len > 0) { |
- string padding = string(padding_payload_len, 0); |
- builder->WriteBytes(padding.data(), padding.length()); |
- } |
- if (bytes_remaining > 0) { |
- builder->OverwriteLength(*this, |
- kMaxControlFrameSize - GetControlFrameHeaderSize()); |
- } |
- |
- // Tack on CONTINUATION frames for the overflow. |
- while (bytes_remaining > 0) { |
- size_t bytes_to_write = std::min(bytes_remaining, |
- kMaxControlFrameSize - |
- GetContinuationMinimumSize()); |
- // Write CONTINUATION frame prefix. |
- if (bytes_remaining == bytes_to_write) { |
- flags |= end_flag; |
- } |
- builder->BeginNewFrame(*this, |
- CONTINUATION, |
- flags, |
- stream_id); |
- // Write payload fragment. |
- builder->WriteBytes(&hpack_encoding[hpack_encoding.size() - |
- bytes_remaining], |
- bytes_to_write); |
- bytes_remaining -= bytes_to_write; |
+ uint8 end_flag = 0; |
+ uint8 flags = 0; |
+ if (type == HEADERS) { |
+ end_flag = HEADERS_FLAG_END_HEADERS; |
+ } else if (type == PUSH_PROMISE) { |
+ end_flag = PUSH_PROMISE_FLAG_END_PUSH_PROMISE; |
+ } else { |
+ DLOG(FATAL) << "CONTINUATION frames cannot be used with frame type " |
+ << FrameTypeToString(type); |
+ } |
+ |
+ // Write all the padding payload and as much of the data payload as possible |
+ // into the initial frame. |
+ size_t bytes_remaining = 0; |
+ bytes_remaining = |
+ hpack_encoding.size() - |
+ std::min(hpack_encoding.size(), |
+ kMaxControlFrameSize - builder->length() - padding_payload_len); |
+ builder->WriteBytes(&hpack_encoding[0], |
+ hpack_encoding.size() - bytes_remaining); |
+ if (padding_payload_len > 0) { |
+ string padding = string(padding_payload_len, 0); |
+ builder->WriteBytes(padding.data(), padding.length()); |
+ } |
+ if (bytes_remaining > 0) { |
+ builder->OverwriteLength( |
+ *this, kMaxControlFrameSize - GetControlFrameHeaderSize()); |
+ } |
+ |
+ // Tack on CONTINUATION frames for the overflow. |
+ while (bytes_remaining > 0) { |
+ size_t bytes_to_write = std::min( |
+ bytes_remaining, kMaxControlFrameSize - GetContinuationMinimumSize()); |
+ // Write CONTINUATION frame prefix. |
+ if (bytes_remaining == bytes_to_write) { |
+ flags |= end_flag; |
} |
+ builder->BeginNewFrame(*this, CONTINUATION, flags, stream_id); |
+ // Write payload fragment. |
+ builder->WriteBytes( |
+ &hpack_encoding[hpack_encoding.size() - bytes_remaining], |
+ bytes_to_write); |
+ bytes_remaining -= bytes_to_write; |
+ } |
} |
// The following compression setting are based on Brian Olson's analysis. See |
@@ -3087,16 +3084,16 @@ z_stream* SpdyFramer::GetHeaderDecompressor() { |
} |
HpackEncoder* SpdyFramer::GetHpackEncoder() { |
- DCHECK_LT(SPDY3, spdy_version_); |
- if (hpack_encoder_.get() == NULL) { |
+ DCHECK_LT(SPDY3, protocol_version()); |
+ if (hpack_encoder_.get() == nullptr) { |
hpack_encoder_.reset(new HpackEncoder(ObtainHpackHuffmanTable())); |
} |
return hpack_encoder_.get(); |
} |
HpackDecoder* SpdyFramer::GetHpackDecoder() { |
- DCHECK_LT(SPDY3, spdy_version_); |
- if (hpack_decoder_.get() == NULL) { |
+ DCHECK_LT(SPDY3, protocol_version()); |
+ if (hpack_decoder_.get() == nullptr) { |
hpack_decoder_.reset(new HpackDecoder(ObtainHpackHuffmanTable())); |
} |
return hpack_decoder_.get(); |