Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: net/spdy/spdy_framer.cc

Issue 637023002: Misc. cleanup, primarily removing unused locals. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove macros.h change Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_framer.h" 5 #include "net/spdy/spdy_framer.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/metrics/stats_counters.h" 9 #include "base/metrics/stats_counters.h"
10 #include "base/third_party/valgrind/memcheck.h" 10 #include "base/third_party/valgrind/memcheck.h"
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 // Not enough information to do anything meaningful. 668 // Not enough information to do anything meaningful.
669 return original_len - len; 669 return original_len - len;
670 } 670 }
671 671
672 // Using a scoped_ptr here since we may need to create a new SpdyFrameReader 672 // Using a scoped_ptr here since we may need to create a new SpdyFrameReader
673 // when processing DATA frames below. 673 // when processing DATA frames below.
674 scoped_ptr<SpdyFrameReader> reader( 674 scoped_ptr<SpdyFrameReader> reader(
675 new SpdyFrameReader(current_frame_buffer_.get(), 675 new SpdyFrameReader(current_frame_buffer_.get(),
676 current_frame_buffer_length_)); 676 current_frame_buffer_length_));
677 677
678 uint16 version = 0;
679 bool is_control_frame = false; 678 bool is_control_frame = false;
680 679
681 uint16 control_frame_type_field = 680 uint16 control_frame_type_field =
682 SpdyConstants::DataFrameType(protocol_version()); 681 SpdyConstants::DataFrameType(protocol_version());
683 // ProcessControlFrameHeader() will set current_frame_type_ to the 682 // ProcessControlFrameHeader() will set current_frame_type_ to the
684 // correct value if this is a valid control frame. 683 // correct value if this is a valid control frame.
685 current_frame_type_ = DATA; 684 current_frame_type_ = DATA;
686 if (protocol_version() <= SPDY3) { 685 if (protocol_version() <= SPDY3) {
686 uint16 version = 0;
687 bool successful_read = reader->ReadUInt16(&version); 687 bool successful_read = reader->ReadUInt16(&version);
688 DCHECK(successful_read); 688 DCHECK(successful_read);
689 is_control_frame = (version & kControlFlagMask) != 0; 689 is_control_frame = (version & kControlFlagMask) != 0;
690 version &= ~kControlFlagMask; // Only valid for control frames. 690 version &= ~kControlFlagMask; // Only valid for control frames.
691 if (is_control_frame) { 691 if (is_control_frame) {
692 // We check version before we check validity: version can never be 692 // We check version before we check validity: version can never be
693 // 'invalid', it can only be unsupported. 693 // 'invalid', it can only be unsupported.
694 if (version < SpdyConstants::SerializeMajorVersion(SPDY_MIN_VERSION) || 694 if (version < SpdyConstants::SerializeMajorVersion(SPDY_MIN_VERSION) ||
695 version > SpdyConstants::SerializeMajorVersion(SPDY_MAX_VERSION) || 695 version > SpdyConstants::SerializeMajorVersion(SPDY_MAX_VERSION) ||
696 SpdyConstants::ParseMajorVersion(version) != protocol_version()) { 696 SpdyConstants::ParseMajorVersion(version) != protocol_version()) {
697 // Version does not match the version the framer was initialized with. 697 // Version does not match the version the framer was initialized with.
698 DVLOG(1) << "Unsupported SPDY version " 698 DVLOG(1) << "Unsupported SPDY version "
699 << version 699 << version
700 << " (expected " << protocol_version() << ")"; 700 << " (expected " << protocol_version() << ")";
701 set_error(SPDY_UNSUPPORTED_VERSION); 701 set_error(SPDY_UNSUPPORTED_VERSION);
702 return 0; 702 return 0;
703 } else {
704 // Convert version from wire format to SpdyMajorVersion.
705 version = SpdyConstants::ParseMajorVersion(version);
706 } 703 }
707 // We check control_frame_type_field's validity in 704 // We check control_frame_type_field's validity in
708 // ProcessControlFrameHeader(). 705 // ProcessControlFrameHeader().
709 successful_read = reader->ReadUInt16(&control_frame_type_field); 706 successful_read = reader->ReadUInt16(&control_frame_type_field);
710 } else { 707 } else {
711 reader->Rewind(); 708 reader->Rewind();
712 successful_read = reader->ReadUInt31(&current_frame_stream_id_); 709 successful_read = reader->ReadUInt31(&current_frame_stream_id_);
713 } 710 }
714 DCHECK(successful_read); 711 DCHECK(successful_read);
715 712
716 successful_read = reader->ReadUInt8(&current_frame_flags_); 713 successful_read = reader->ReadUInt8(&current_frame_flags_);
717 DCHECK(successful_read); 714 DCHECK(successful_read);
718 715
719 uint32 length_field = 0; 716 uint32 length_field = 0;
720 successful_read = reader->ReadUInt24(&length_field); 717 successful_read = reader->ReadUInt24(&length_field);
721 DCHECK(successful_read); 718 DCHECK(successful_read);
722 remaining_data_length_ = length_field; 719 remaining_data_length_ = length_field;
723 current_frame_length_ = remaining_data_length_ + reader->GetBytesConsumed(); 720 current_frame_length_ = remaining_data_length_ + reader->GetBytesConsumed();
724 } else { 721 } else {
725 version = protocol_version();
726 uint32 length_field = 0; 722 uint32 length_field = 0;
727 bool successful_read = reader->ReadUInt24(&length_field); 723 bool successful_read = reader->ReadUInt24(&length_field);
728 DCHECK(successful_read); 724 DCHECK(successful_read);
729 725
730 uint8 control_frame_type_field_uint8 = 726 uint8 control_frame_type_field_uint8 =
731 SpdyConstants::DataFrameType(protocol_version()); 727 SpdyConstants::DataFrameType(protocol_version());
732 successful_read = reader->ReadUInt8(&control_frame_type_field_uint8); 728 successful_read = reader->ReadUInt8(&control_frame_type_field_uint8);
733 DCHECK(successful_read); 729 DCHECK(successful_read);
734 // We check control_frame_type_field's validity in 730 // We check control_frame_type_field's validity in
735 // ProcessControlFrameHeader(). 731 // ProcessControlFrameHeader().
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 total_length += length_of_name_size + it->first.size() + 1162 total_length += length_of_name_size + it->first.size() +
1167 length_of_value_size + it->second.size(); 1163 length_of_value_size + it->second.size();
1168 } 1164 }
1169 return total_length; 1165 return total_length;
1170 } 1166 }
1171 1167
1172 void SpdyFramer::WriteHeaderBlock(SpdyFrameBuilder* frame, 1168 void SpdyFramer::WriteHeaderBlock(SpdyFrameBuilder* frame,
1173 const SpdyMajorVersion spdy_version, 1169 const SpdyMajorVersion spdy_version,
1174 const SpdyHeaderBlock* headers) { 1170 const SpdyHeaderBlock* headers) {
1175 if (spdy_version < SPDY3) { 1171 if (spdy_version < SPDY3) {
1176 frame->WriteUInt16(headers->size()); // Number of headers. 1172 frame->WriteUInt16(headers->size());
1177 } else { 1173 } else {
1178 frame->WriteUInt32(headers->size()); // Number of headers. 1174 frame->WriteUInt32(headers->size());
1179 } 1175 }
1180 SpdyHeaderBlock::const_iterator it; 1176 SpdyHeaderBlock::const_iterator it;
1181 for (it = headers->begin(); it != headers->end(); ++it) { 1177 for (it = headers->begin(); it != headers->end(); ++it) {
1182 if (spdy_version < SPDY3) { 1178 if (spdy_version < SPDY3) {
1183 frame->WriteString(it->first); 1179 frame->WriteString(it->first);
1184 frame->WriteString(it->second); 1180 frame->WriteString(it->second);
1185 } else { 1181 } else {
1186 frame->WriteStringPiece32(it->first); 1182 frame->WriteStringPiece32(it->first);
1187 frame->WriteStringPiece32(it->second); 1183 frame->WriteStringPiece32(it->second);
1188 } 1184 }
(...skipping 2058 matching lines...) Expand 10 before | Expand all | Expand 10 after
3247 builder->Seek(compressed_size); 3243 builder->Seek(compressed_size);
3248 builder->RewriteLength(*this); 3244 builder->RewriteLength(*this);
3249 3245
3250 pre_compress_bytes.Add(uncompressed_len); 3246 pre_compress_bytes.Add(uncompressed_len);
3251 post_compress_bytes.Add(compressed_size); 3247 post_compress_bytes.Add(compressed_size);
3252 3248
3253 compressed_frames.Increment(); 3249 compressed_frames.Increment();
3254 } 3250 }
3255 3251
3256 } // namespace net 3252 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698