Bug 1383234 - Don't throttle Blocking/Unblocked marked HTTP responses. r=mcmanus
authorHonza Bambas <honzab.moz@firemni.cz>
Fri, 28 Jul 2017 08:10:00 -0400
changeset 420439 8af1672af38de64375e3baa23c8bc2d1c4c97606
parent 420438 af9a5f0846e62b1e37bbb8a0218cd10e87eef2e5
child 420440 1a4b6ccab14b146078951856ae0259cfb4c6ed8f
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs1383234
milestone56.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 1383234 - Don't throttle Blocking/Unblocked marked HTTP responses. r=mcmanus
netwerk/protocol/http/nsHttpTransaction.cpp
netwerk/protocol/http/nsHttpTransaction.h
--- a/netwerk/protocol/http/nsHttpTransaction.cpp
+++ b/netwerk/protocol/http/nsHttpTransaction.cpp
@@ -168,23 +168,29 @@ void nsHttpTransaction::ResumeReading()
     if (mConnection) {
         nsresult rv = mConnection->ResumeRecv();
         if (NS_FAILED(rv)) {
             LOG(("  resume failed with rv=%" PRIx32, static_cast<uint32_t>(rv)));
         }
     }
 }
 
+bool nsHttpTransaction::EligibleForThrottling()
+{
+  return (mClassOfService & (nsIClassOfService::Throttleable |
+                             nsIClassOfService::Leader |
+                             nsIClassOfService::Unblocked)) ==
+    nsIClassOfService::Throttleable;
+}
+
 void nsHttpTransaction::SetClassOfService(uint32_t cos)
 {
-    bool wasThrottling = mClassOfService & nsIClassOfService::Throttleable;
-
+    bool wasThrottling = EligibleForThrottling();
     mClassOfService = cos;
-
-    bool isThrottling = mClassOfService & nsIClassOfService::Throttleable;
+    bool isThrottling = EligibleForThrottling();
 
     if (mConnection && wasThrottling != isThrottling) {
         // Do nothing until we are actually activated.  For now
         // only remember the throttle flag.  Call to MoveActiveTransaction
         // would add this transaction to the list too early.
         gHttpHandler->ConnMgr()->MoveActiveTransaction(this, isThrottling);
 
         if (mReadingStopped && !isThrottling) {
@@ -833,18 +839,17 @@ bool nsHttpTransaction::ShouldStopReadin
 {
     if (mActivatedAsH2) {
         // Throttling feature is now disabled for http/2 transactions
         // because of bug 1367861.  The logic around mActivatedAsH2
         // will be removed when that is fixed
         return false;
     }
 
-    if (!gHttpHandler->ConnMgr()->ShouldStopReading(
-            this, mClassOfService & nsIClassOfService::Throttleable)) {
+    if (!gHttpHandler->ConnMgr()->ShouldStopReading(this, EligibleForThrottling())) {
         // We are not obligated to throttle
         return false;
     }
 
     if (mContentRead < 16000) {
         // Let the first bytes go, it may also well be all the content we get
         LOG(("nsHttpTransaction::ShouldStopReading too few content (%" PRIi64 ") this=%p", mContentRead, this));
         return false;
--- a/netwerk/protocol/http/nsHttpTransaction.h
+++ b/netwerk/protocol/http/nsHttpTransaction.h
@@ -388,16 +388,20 @@ public:
     // transaction is believed to be HTTP/1 (and thus subject to rate pacing)
     // but later can be dispatched via spdy (not subject to rate pacing).
     void CancelPacing(nsresult reason);
 
     // Called by the connetion manager on the socket thread when reading for this
     // previously throttled transaction has to be resumed.
     void ResumeReading();
 
+    // This examins classification of this transaction whether the Throttleable class
+    // has been set while Leader or Unblocked are not.
+    bool EligibleForThrottling();
+
 private:
     bool mSubmittedRatePacing;
     bool mPassedRatePacing;
     bool mSynchronousRatePaceRequest;
     nsCOMPtr<nsICancelable> mTokenBucketCancel;
 public:
     void     SetClassOfService(uint32_t cos);
     uint32_t ClassOfService() { return mClassOfService; }