Bug 1341266 - create http/2 stream for urgent-start; r?mcmanus draft
authorLiang-Heng Chen <xeonchen@gmail.com>
Fri, 19 May 2017 00:50:15 +0800
changeset 583630 ce4fbda21baec0a184275863a13f00a20e787c72
parent 583306 748bee7648bcdba8623eaf75408fc8ab6a566d4e
child 630141 3c8dca49ad129fc38740921a391b66fc68ad85df
push id60481
push userbmo:xeonchen@mozilla.com
push dateWed, 24 May 2017 10:29:41 +0000
reviewersmcmanus
bugs1341266
milestone55.0a1
Bug 1341266 - create http/2 stream for urgent-start; r?mcmanus MozReview-Commit-ID: GIZuAmigK9n
netwerk/protocol/http/Http2Session.cpp
netwerk/protocol/http/Http2Session.h
netwerk/protocol/http/Http2Stream.cpp
--- a/netwerk/protocol/http/Http2Session.cpp
+++ b/netwerk/protocol/http/Http2Session.cpp
@@ -958,16 +958,19 @@ Http2Session::SendHello()
     CreatePriorityNode(kBackgroundGroupID, 0, 0, "background");
     mNextStreamID += 2;
     MOZ_ASSERT(mNextStreamID == kSpeculativeGroupID);
     CreatePriorityNode(kSpeculativeGroupID, kBackgroundGroupID, 0, "speculative");
     mNextStreamID += 2;
     MOZ_ASSERT(mNextStreamID == kFollowerGroupID);
     CreatePriorityNode(kFollowerGroupID, kLeaderGroupID, 0, "follower");
     mNextStreamID += 2;
+    MOZ_ASSERT(mNextStreamID == kUrgentStartGroupID);
+    CreatePriorityNode(kUrgentStartGroupID, 0, 240, "urgentStart");
+    mNextStreamID += 2;
     // Hey, you! YES YOU! If you add/remove any groups here, you almost
     // certainly need to change the lookup of the stream/ID hash in
     // Http2Session::OnTransportStatus. Yeah, that's right. YOU!
   }
 
   FlushOutputQueue();
 }
 
@@ -2419,17 +2422,17 @@ Http2Session::OnTransportStatus(nsITrans
     // transaction on the session.
   case NS_NET_STATUS_RESOLVING_HOST:
   case NS_NET_STATUS_RESOLVED_HOST:
   case NS_NET_STATUS_CONNECTING_TO:
   case NS_NET_STATUS_CONNECTED_TO:
   case NS_NET_STATUS_TLS_HANDSHAKE_STARTING:
   case NS_NET_STATUS_TLS_HANDSHAKE_ENDED:
   {
-    Http2Stream *target = mStreamIDHash.Get(mUseH2Deps ? 0xD : 0x3);
+    Http2Stream *target = mStreamIDHash.Get(mUseH2Deps ? 0xF : 0x3);
     nsAHttpTransaction *transaction = target ? target->Transaction() : nullptr;
     if (transaction)
       transaction->OnTransportStatus(aTransport, aStatus, aProgress);
     break;
   }
 
   default:
     // The other transport events are ignored here because there is no good
--- a/netwerk/protocol/http/Http2Session.h
+++ b/netwerk/protocol/http/Http2Session.h
@@ -165,21 +165,22 @@ public:
   const static uint8_t kFrameLengthBytes = 3;
   const static uint8_t kFrameStreamIDBytes = 4;
   const static uint8_t kFrameFlagBytes = 1;
   const static uint8_t kFrameTypeBytes = 1;
   const static uint8_t kFrameHeaderBytes = kFrameLengthBytes + kFrameFlagBytes +
     kFrameTypeBytes + kFrameStreamIDBytes;
 
   enum {
-    kLeaderGroupID =     0x3,
+    kLeaderGroupID =      0x3,
     kOtherGroupID =       0x5,
     kBackgroundGroupID =  0x7,
     kSpeculativeGroupID = 0x9,
-    kFollowerGroupID =    0xB
+    kFollowerGroupID =    0xB,
+    kUrgentStartGroupID = 0xD
     // Hey, you! YES YOU! If you add/remove any groups here, you almost
     // certainly need to change the lookup of the stream/ID hash in
     // Http2Session::OnTransportStatus. Yeah, that's right. YOU!
   };
 
   static nsresult RecvHeaders(Http2Session *);
   static nsresult RecvPriority(Http2Session *);
   static nsresult RecvRstStream(Http2Session *);
--- a/netwerk/protocol/http/Http2Stream.cpp
+++ b/netwerk/protocol/http/Http2Stream.cpp
@@ -1208,42 +1208,46 @@ Http2Stream::UpdatePriorityDependency()
     return;
   }
 
   nsHttpTransaction *trans = mTransaction->QueryHttpTransaction();
   if (!trans) {
     return;
   }
 
-  // we create 5 fake dependency streams per session,
+  // we create 6 fake dependency streams per session,
   // these streams are never opened with HEADERS. our first opened stream is 0xd
   // 3 depends 0, weight 200, leader class (kLeaderGroupID)
   // 5 depends 0, weight 100, other (kOtherGroupID)
   // 7 depends 0, weight 0, background (kBackgroundGroupID)
   // 9 depends 7, weight 0, speculative (kSpeculativeGroupID)
   // b depends 3, weight 0, follower class (kFollowerGroupID)
+  // d depends 0, weight 240, urgent-start class (kUrgentStartGroupID)
   //
   // streams for leaders (html, js, css) depend on 3
   // streams for folowers (images) depend on b
   // default streams (xhr, async js) depend on 5
   // explicit bg streams (beacon, etc..) depend on 7
   // spculative bg streams depend on 9
+  // urgent-start streams depend on d
 
   uint32_t classFlags = trans->ClassOfService();
 
   if (classFlags & nsIClassOfService::Leader) {
     mPriorityDependency = Http2Session::kLeaderGroupID;
   } else if (classFlags & nsIClassOfService::Follower) {
     mPriorityDependency = Http2Session::kFollowerGroupID;
   } else if (classFlags & nsIClassOfService::Speculative) {
     mPriorityDependency = Http2Session::kSpeculativeGroupID;
   } else if (classFlags & nsIClassOfService::Background) {
     mPriorityDependency = Http2Session::kBackgroundGroupID;
   } else if (classFlags & nsIClassOfService::Unblocked) {
     mPriorityDependency = Http2Session::kOtherGroupID;
+  } else if (classFlags & nsIClassOfService::UrgentStart) {
+    mPriorityDependency = Http2Session::kUrgentStartGroupID;
   } else {
     mPriorityDependency = Http2Session::kFollowerGroupID; // unmarked followers
   }
 
   LOG3(("Http2Stream::UpdatePriorityDependency %p "
         "classFlags %X depends on stream 0x%X\n",
         this, classFlags, mPriorityDependency));
 }