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

Unified Diff: net/spdy/spdy_http_utils.cc

Issue 10185007: [net] Change order of RequestPriority to natural: higher > lower (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Responded to review Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: net/spdy/spdy_http_utils.cc
diff --git a/net/spdy/spdy_http_utils.cc b/net/spdy/spdy_http_utils.cc
index f029a994081425ce2cebb80d2312b88ad007109e..6f87faad80345c4367f62e7d96a43dac98d7c739 100644
--- a/net/spdy/spdy_http_utils.cc
+++ b/net/spdy/spdy_http_utils.cc
@@ -125,21 +125,25 @@ void CreateSpdyHeadersFromHttpRequest(const HttpRequestInfo& info,
}
+COMPILE_ASSERT(HIGHEST - LOWEST < 4 &&
+ HIGHEST - MINIMUM_PRIORITY < 5,
+ request_priority_incompatible_with_spdy);
szym 2012/04/24 18:15:25 Please, take a look at this assert and the mapping
Ryan Hamilton 2012/04/24 18:45:35 NICE! Love this assert.
+
SpdyPriority ConvertRequestPriorityToSpdyPriority(
const RequestPriority priority,
int protocol_version) {
- DCHECK(HIGHEST <= priority && priority < NUM_PRIORITIES);
+ DCHECK_GE(priority, MINIMUM_PRIORITY);
+ DCHECK_LT(priority, NUM_PRIORITIES);
if (protocol_version == 2) {
// SPDY 2 only has 2 bits of priority, but we have 5 RequestPriorities.
- if (priority < LOWEST) {
- return priority;
+ // Map IDLE => 3, LOWEST => 2, LOW => 2, MEDIUM => 1, HIGHEST => 0.
+ if (priority > LOWEST) {
+ return static_cast<SpdyPriority>(HIGHEST - priority);
} else {
- DCHECK_GE(4, priority);
- return priority - 1;
+ return static_cast<SpdyPriority>(HIGHEST - priority - 1);
}
- } else {
- DCHECK_GE(7, priority);
- return priority;
+ } else { // only valid
+ return static_cast<SpdyPriority>(HIGHEST - priority);
}
}

Powered by Google App Engine
This is Rietveld 408576698