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

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

Issue 1776373003: Consolidate SpdyFramer::WriteHeaderBlock() and SerializeHeaderBlockWithoutCompression(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « net/spdy/spdy_framer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <iterator> 10 #include <iterator>
(...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 size_t total_length = num_name_value_pairs_size; 1167 size_t total_length = num_name_value_pairs_size;
1168 for (const auto& header : *headers) { 1168 for (const auto& header : *headers) {
1169 // We add space for the length of the name and the length of the value as 1169 // We add space for the length of the name and the length of the value as
1170 // well as the length of the name and the length of the value. 1170 // well as the length of the name and the length of the value.
1171 total_length += length_of_name_size + header.first.size() + 1171 total_length += length_of_name_size + header.first.size() +
1172 length_of_value_size + header.second.size(); 1172 length_of_value_size + header.second.size();
1173 } 1173 }
1174 return total_length; 1174 return total_length;
1175 } 1175 }
1176 1176
1177 void SpdyFramer::WriteHeaderBlock(SpdyFrameBuilder* frame,
1178 const SpdyMajorVersion spdy_version,
1179 const SpdyHeaderBlock* headers) {
1180 frame->WriteUInt32(headers->size());
1181 SpdyHeaderBlock::const_iterator it;
1182 for (it = headers->begin(); it != headers->end(); ++it) {
1183 frame->WriteStringPiece32(it->first);
1184 frame->WriteStringPiece32(it->second);
1185 }
1186 }
1187
1188 // TODO(phajdan.jr): Clean up after we no longer need 1177 // TODO(phajdan.jr): Clean up after we no longer need
1189 // to workaround http://crbug.com/139744. 1178 // to workaround http://crbug.com/139744.
1190 #if !defined(USE_SYSTEM_ZLIB) 1179 #if !defined(USE_SYSTEM_ZLIB)
1191 1180
1192 // These constants are used by zlib to differentiate between normal data and 1181 // These constants are used by zlib to differentiate between normal data and
1193 // cookie data. Cookie data is handled specially by zlib when compressing. 1182 // cookie data. Cookie data is handled specially by zlib when compressing.
1194 enum ZDataClass { 1183 enum ZDataClass {
1195 // kZStandardData is compressed normally, save that it will never match 1184 // kZStandardData is compressed normally, save that it will never match
1196 // against any other class of data in the window. 1185 // against any other class of data in the window.
1197 kZStandardData = Z_CLASS_STANDARD, 1186 kZStandardData = Z_CLASS_STANDARD,
(...skipping 1939 matching lines...) Expand 10 before | Expand all | Expand 10 after
3137 #else 3126 #else
3138 WriteHeaderBlockToZ(&frame.header_block(), compressor); 3127 WriteHeaderBlockToZ(&frame.header_block(), compressor);
3139 #endif // defined(USE_SYSTEM_ZLIB) 3128 #endif // defined(USE_SYSTEM_ZLIB)
3140 3129
3141 int compressed_size = compressed_max_size - compressor->avail_out; 3130 int compressed_size = compressed_max_size - compressor->avail_out;
3142 builder->Seek(compressed_size); 3131 builder->Seek(compressed_size);
3143 builder->RewriteLength(*this); 3132 builder->RewriteLength(*this);
3144 } 3133 }
3145 3134
3146 } // namespace net 3135 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_framer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698