Move priority frame's exclusive bit from bit #7 to bit #4. gfe-relnote: v99 only, not protected. PiperOrigin-RevId: 258589446 Change-Id: I48c9ed6c09135a6e08fdc5df4b70ff7af8aee498
diff --git a/quic/core/http/http_decoder.cc b/quic/core/http/http_decoder.cc index 90df506..faffdc9 100644 --- a/quic/core/http/http_decoder.cc +++ b/quic/core/http/http_decoder.cc
@@ -4,6 +4,9 @@ #include "net/third_party/quiche/src/quic/core/http/http_decoder.h" +#include <cstdint> + +#include "net/third_party/quiche/src/quic/core/http/http_frames.h" #include "net/third_party/quiche/src/quic/core/quic_data_reader.h" #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" #include "net/third_party/quiche/src/quic/platform/api/quic_fallthrough.h" @@ -11,17 +14,6 @@ namespace quic { namespace { - -// Create a mask that sets the last |num_bits| to 1 and the rest to 0. -inline uint8_t GetMaskFromNumBits(uint8_t num_bits) { - return (1u << num_bits) - 1; -} - -// Extract |num_bits| from |flags| offset by |offset|. -uint8_t ExtractBits(uint8_t flags, uint8_t num_bits, uint8_t offset) { - return (flags >> offset) & GetMaskFromNumBits(num_bits); -} - // Length of the weight field of a priority frame. static const size_t kPriorityWeightLength = 1; // Length of a priority frame's first byte. @@ -468,12 +460,11 @@ return false; } - frame->prioritized_type = - static_cast<PriorityElementType>(ExtractBits(flags, 2, 6)); - frame->dependency_type = - static_cast<PriorityElementType>(ExtractBits(flags, 2, 4)); - // TODO(b/137662729): Update bitmask for exclusive flag. - frame->exclusive = flags % 2 == 1; + // Assign two most significant bits to prioritized_type. + frame->prioritized_type = static_cast<PriorityElementType>((flags >> 6) & 3); + // Assign the next two most significant bits to dependency type. + frame->dependency_type = static_cast<PriorityElementType>((flags >> 4) & 3); + frame->exclusive = flags >> 3 & 1; // TODO(b/137359636): Handle partial delivery. if (frame->prioritized_type != ROOT_OF_TREE && !reader->ReadVarInt62(&frame->prioritized_element_id)) {
diff --git a/quic/core/http/http_decoder_test.cc b/quic/core/http/http_decoder_test.cc index 1c245d0..cf32171 100644 --- a/quic/core/http/http_decoder_test.cc +++ b/quic/core/http/http_decoder_test.cc
@@ -306,7 +306,7 @@ std::string input = "\x02" // type (PRIORITY) "\x04" // length - "\x01" // request stream, request stream, exclusive + "\x08" // request stream, request stream, exclusive "\x03" // prioritized_element_id "\x04" // element_dependency_id "\xFF"; // weight @@ -351,7 +351,7 @@ std::string input2 = "\x02" // type (PRIORITY) "\x02" // length - "\xf1" // root of tree, root of tree, exclusive + "\xf8" // root of tree, root of tree, exclusive "\xFF"; // weight PriorityFrame frame2; frame2.prioritized_type = ROOT_OF_TREE;
diff --git a/quic/core/http/http_encoder.cc b/quic/core/http/http_encoder.cc index 2b8be8e..2306b8e 100644 --- a/quic/core/http/http_encoder.cc +++ b/quic/core/http/http_encoder.cc
@@ -45,7 +45,7 @@ // Length of a priority frame's first byte. static const size_t kPriorityFirstByteLength = 1; // The bit that indicates Priority frame is exclusive. -static const uint8_t kPriorityExclusiveBit = 1; +static const uint8_t kPriorityExclusiveBit = 8; } // namespace
diff --git a/quic/core/http/http_encoder_test.cc b/quic/core/http/http_encoder_test.cc index d0696ed..eb5e574 100644 --- a/quic/core/http/http_encoder_test.cc +++ b/quic/core/http/http_encoder_test.cc
@@ -56,7 +56,7 @@ // length 0x4, // request stream, request stream, exclusive - 0x01, + 0x08, // prioritized_element_id 0x03, // element_dependency_id @@ -81,7 +81,7 @@ // length 0x3, // root of tree, request stream, exclusive - 0xc1, + 0xc8, // element_dependency_id 0x04, // weight @@ -101,7 +101,7 @@ // length 0x2, // root of tree, root of tree, exclusive - 0xf1, + 0xf8, // weight 0xff}; length = encoder_.SerializePriorityFrame(priority3, &buffer);
diff --git a/quic/core/http/http_frames.h b/quic/core/http/http_frames.h index cf282ee..b84b658 100644 --- a/quic/core/http/http_frames.h +++ b/quic/core/http/http_frames.h
@@ -5,6 +5,7 @@ #ifndef QUICHE_QUIC_CORE_HTTP_HTTP_FRAMES_H_ #define QUICHE_QUIC_CORE_HTTP_HTTP_FRAMES_H_ +#include <cstdint> #include <map> #include <ostream> @@ -48,7 +49,7 @@ // // The PRIORITY (type=0x02) frame specifies the sender-advised priority // of a stream -enum PriorityElementType { +enum PriorityElementType : uint8_t { REQUEST_STREAM = 0, PUSH_STREAM = 1, PLACEHOLDER = 2,