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

Unified Diff: net/spdy/spdy_framer.cc

Issue 287003011: Initial support for HTTP/2 dependencies and weights (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment tweaks. Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/spdy/spdy_framer.h ('k') | net/spdy/spdy_framer_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_framer.cc
diff --git a/net/spdy/spdy_framer.cc b/net/spdy/spdy_framer.cc
index 79a529f5724f172ffb4d9e07718dbd3087f8582c..48923244af7e54bd67157540558adf964d885800 100644
--- a/net/spdy/spdy_framer.cc
+++ b/net/spdy/spdy_framer.cc
@@ -184,8 +184,8 @@ size_t SpdyFramer::GetSynStreamMinimumSize() const {
return GetControlFrameHeaderSize() + 10;
} else {
// Calculated as:
- // frame prefix + 4 (priority)
- return GetControlFrameHeaderSize() + 4;
+ // frame prefix + 5 (priority)
+ return GetControlFrameHeaderSize() + 5;
Ryan Hamilton 2014/05/19 22:56:41 I'm not terribly in love with the magic number her
Johnny 2014/05/19 23:27:17 Done. Though, now this particularly calls attentio
}
}
@@ -1047,7 +1047,7 @@ void SpdyFramer::ProcessControlFrameHeader(uint16 control_frame_type_field) {
frame_size_without_variable_data = GetHeadersMinimumSize();
if (protocol_version() > SPDY3 &&
current_frame_flags_ & HEADERS_FLAG_PRIORITY) {
- frame_size_without_variable_data += 4; // priority
+ frame_size_without_variable_data += 5; // priority
}
break;
case PUSH_PROMISE:
@@ -1414,8 +1414,13 @@ size_t SpdyFramer::ProcessControlFrameBeforeHeaderBlock(const char* data,
(current_frame_flags_ & HEADERS_FLAG_PRIORITY) != 0;
uint32 priority = 0;
if (protocol_version() > SPDY3 && has_priority) {
- successful_read = reader.ReadUInt31(&priority);
- DCHECK(successful_read);
+ // TODO(jgraettinger): Process dependency rather than ignoring it.
+ reader.Seek(4);
+ uint8 weight = 0;
+ successful_read = reader.ReadUInt8(&weight);
+ if (successful_read) {
+ priority = MapWeightToPriority(weight);
+ }
}
DCHECK(reader.IsDoneReading());
if (debug_visitor_) {
@@ -2376,7 +2381,9 @@ SpdySerializedFrame* SpdyFramer::SerializeSynStream(
HEADERS,
flags,
syn_stream.stream_id());
- builder.WriteUInt32(priority);
+ // TODO(jgraettinger): Plumb priorities and stream dependencies.
+ builder.WriteUInt32(0); // Non-exclusive bit and root stream ID.
+ builder.WriteUInt8(MapPriorityToWeight(priority));
}
DCHECK_EQ(GetSynStreamMinimumSize(), builder.length());
if (protocol_version() > SPDY3) {
@@ -2664,7 +2671,9 @@ SpdySerializedFrame* SpdyFramer::SerializeHeaders(
flags,
headers.stream_id());
if (headers.has_priority()) {
- builder.WriteUInt32(priority);
+ // TODO(jgraettinger): Plumb priorities and stream dependencies.
+ builder.WriteUInt32(0); // Non-exclusive bit and root stream ID.
+ builder.WriteUInt8(MapPriorityToWeight(priority));
}
}
if (protocol_version() <= SPDY2) {
@@ -3055,6 +3064,16 @@ HpackDecoder* SpdyFramer::GetHpackDecoder() {
return hpack_decoder_.get();
}
+uint8 SpdyFramer::MapPriorityToWeight(SpdyPriority priority) {
+ const float kSteps = 255.9f / 7.f;
+ return static_cast<uint8>(kSteps * (7.f - priority));
+}
+
+SpdyPriority SpdyFramer::MapWeightToPriority(uint8 weight) {
+ const float kSteps = 255.9f / 7.f;
+ return static_cast<SpdyPriority>(7.f - weight / kSteps);
+}
+
// Incrementally decompress the control frame's header block, feeding the
// result to the visitor in chunks. Continue this until the visitor
// indicates that it cannot process any more data, or (more commonly) we
« no previous file with comments | « net/spdy/spdy_framer.h ('k') | net/spdy/spdy_framer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698