Bug 1341266 - create http/2 stream for urgent-start; r=mcmanus
authorLiang-Heng Chen <xeonchen@gmail.com>
Fri, 19 May 2017 00:50:15 +0800
changeset 410255 2639c72118b44ff7efa56d2d2fa906188c270ef4
parent 410254 2a51ed1fc84064779ddfaf5b8ab1f9e7dd91774e
child 410256 ec5dcacaf5a9637a321fdc5afbee0ec21a40655e
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs1341266
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
@@ -959,16 +959,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();
 }
 
@@ -2421,17 +2424,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
@@ -164,21 +164,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));
 }