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

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

Issue 1866483002: Add a new priority level, THROTTLED, below IDLE. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync'd to p390110 Created 4 years, 7 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_http_utils.h" 5 #include "net/spdy/spdy_http_utils.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 (*headers)[status_key] = std::string(after_version + 1, after_status); 166 (*headers)[status_key] = std::string(after_version + 1, after_status);
167 167
168 size_t iter = 0; 168 size_t iter = 0;
169 std::string raw_name, value; 169 std::string raw_name, value;
170 while (response_headers.EnumerateHeaderLines(&iter, &raw_name, &value)) { 170 while (response_headers.EnumerateHeaderLines(&iter, &raw_name, &value)) {
171 std::string name = base::ToLowerASCII(raw_name); 171 std::string name = base::ToLowerASCII(raw_name);
172 AddSpdyHeader(name, value, headers); 172 AddSpdyHeader(name, value, headers);
173 } 173 }
174 } 174 }
175 175
176 static_assert(HIGHEST - LOWEST < 4 && HIGHEST - MINIMUM_PRIORITY < 5, 176 static_assert(HIGHEST - LOWEST < 4 && HIGHEST - MINIMUM_PRIORITY < 6,
177 "request priority incompatible with spdy"); 177 "request priority incompatible with spdy");
178 178
179 SpdyPriority ConvertRequestPriorityToSpdyPriority( 179 SpdyPriority ConvertRequestPriorityToSpdyPriority(
mmenke 2016/05/09 19:25:42 Need to have the QUIC/SPDY teams weigh in on chang
Randy Smith (Not in Mondays) 2016/05/11 21:30:25 Ryan, are you willing to play a SPDY expert on TV,
180 const RequestPriority priority, 180 const RequestPriority priority,
181 SpdyMajorVersion protocol_version) { 181 SpdyMajorVersion protocol_version) {
182 DCHECK_GE(priority, MINIMUM_PRIORITY); 182 DCHECK_GE(priority, MINIMUM_PRIORITY);
183 DCHECK_LE(priority, MAXIMUM_PRIORITY); 183 DCHECK_LE(priority, MAXIMUM_PRIORITY);
184 return static_cast<SpdyPriority>(MAXIMUM_PRIORITY - priority); 184 return static_cast<SpdyPriority>(MAXIMUM_PRIORITY - priority);
185 } 185 }
186 186
187 NET_EXPORT_PRIVATE RequestPriority ConvertSpdyPriorityToRequestPriority( 187 NET_EXPORT_PRIVATE RequestPriority ConvertSpdyPriorityToRequestPriority(
188 SpdyPriority priority, 188 SpdyPriority priority,
189 SpdyMajorVersion protocol_version) { 189 SpdyMajorVersion protocol_version) {
190 // Handle invalid values gracefully. 190 // Handle invalid values gracefully.
191 // Note that SpdyPriority is not an enum, hence the magic constants. 191 return (priority > (MAXIMUM_PRIORITY - MINIMUM_PRIORITY))
mmenke 2016/05/09 19:25:42 This maps IDLE priority to 4, THROTTLED to 5, and
Randy Smith (Not in Mondays) 2016/05/11 21:30:25 Because of ">" rather than ">="? Because the QUIC
Ryan Hamilton 2016/05/12 22:25:46 Because QuicPriority != SpdyPriority ... except th
192 return (priority >= 5) ? 192 ? IDLE
193 IDLE : static_cast<RequestPriority>(4 - priority); 193 : static_cast<RequestPriority>(MAXIMUM_PRIORITY - priority);
194 } 194 }
195 195
196 NET_EXPORT_PRIVATE void ConvertHeaderBlockToHttpRequestHeaders( 196 NET_EXPORT_PRIVATE void ConvertHeaderBlockToHttpRequestHeaders(
197 const SpdyHeaderBlock& spdy_headers, 197 const SpdyHeaderBlock& spdy_headers,
198 HttpRequestHeaders* http_headers) { 198 HttpRequestHeaders* http_headers) {
199 for (const auto& it : spdy_headers) { 199 for (const auto& it : spdy_headers) {
200 base::StringPiece key = it.first; 200 base::StringPiece key = it.first;
201 if (key[0] == ':') { 201 if (key[0] == ':') {
202 key.remove_prefix(1); 202 key.remove_prefix(1);
203 } 203 }
(...skipping 19 matching lines...) Expand all
223 url.append(it->second.as_string()); 223 url.append(it->second.as_string());
224 224
225 it = headers.find(":path"); 225 it = headers.find(":path");
226 if (it == headers.end()) 226 if (it == headers.end())
227 return GURL(); 227 return GURL();
228 url.append(it->second.as_string()); 228 url.append(it->second.as_string());
229 return GURL(url); 229 return GURL(url);
230 } 230 }
231 231
232 } // namespace net 232 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698