Index: net/spdy/spdy_framer.cc |
diff --git a/net/spdy/spdy_framer.cc b/net/spdy/spdy_framer.cc |
index 4049e100f19690be484a625a17e3d6ab5eae6a7b..2e8d6b33bcabcd0a88413efb01427a9333b13640 100644 |
--- a/net/spdy/spdy_framer.cc |
+++ b/net/spdy/spdy_framer.cc |
@@ -1789,9 +1789,21 @@ size_t SpdyFramer::ProcessControlFramePayload(const char* data, size_t len) { |
break; |
case PRIORITY: { |
DCHECK_LT(SPDY3, protocol_version()); |
- // TODO(hkhalil): Process PRIORITY frames rather than ignore them. |
- reader.Seek(5); |
+ uint32 parent_stream_id; |
+ uint8 weight; |
+ bool exclusive; |
+ bool successful_read = true; |
+ successful_read = reader.ReadUInt32(&parent_stream_id); |
+ DCHECK(successful_read); |
+ // Exclusivity is indicated by a single bit flag. |
+ exclusive = (parent_stream_id >> 31) != 0; |
+ // Zero out the highest-order bit to get the parent stream id. |
+ parent_stream_id &= 0x7fffffff; |
+ successful_read = reader.ReadUInt8(&weight); |
+ DCHECK(successful_read); |
DCHECK(reader.IsDoneReading()); |
+ visitor_->OnPriority( |
+ current_frame_stream_id_, parent_stream_id, weight, exclusive); |
} |
break; |
default: |
@@ -2819,6 +2831,24 @@ SpdyFrame* SpdyFramer::SerializeAltSvc(const SpdyAltSvcIR& altsvc) { |
return builder.take(); |
} |
+SpdyFrame* SpdyFramer::SerializePriority(const SpdyPriorityIR& priority) { |
+ DCHECK_LT(SPDY3, protocol_version()); |
+ size_t size = GetPrioritySize(); |
+ |
+ SpdyFrameBuilder builder(size, protocol_version()); |
+ builder.BeginNewFrame(*this, PRIORITY, kNoFlags, priority.stream_id()); |
+ |
+ // Make sure the highest-order bit in the parent stream id is zeroed out. |
+ uint32 parent_stream_id = priority.parent_stream_id() & 0x7fffffff; |
+ uint32 exclusive = priority.exclusive() ? 0x80000000 : 0; |
+ // Set the one-bit exclusivity flag. |
+ uint32 flag_and_parent_id = parent_stream_id | exclusive; |
+ builder.WriteUInt32(flag_and_parent_id); |
+ builder.WriteUInt8(priority.weight()); |
+ DCHECK_EQ(GetPrioritySize(), builder.length()); |
+ return builder.take(); |
+} |
+ |
namespace { |
class FrameSerializationVisitor : public SpdyFrameVisitor { |
@@ -2870,6 +2900,9 @@ class FrameSerializationVisitor : public SpdyFrameVisitor { |
virtual void VisitAltSvc(const SpdyAltSvcIR& altsvc) OVERRIDE { |
frame_.reset(framer_->SerializeAltSvc(altsvc)); |
} |
+ virtual void VisitPriority(const SpdyPriorityIR& priority) OVERRIDE { |
+ frame_.reset(framer_->SerializePriority(priority)); |
+ } |
private: |
SpdyFramer* framer_; |