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); |
} |
} |