Bug 1482117 - Part 1: Make FastBlock happen after tailing; r=mayhemer
authorLiang-Heng Chen <xeonchen@gmail.com>
Wed, 15 Aug 2018 16:32:34 +0000
changeset 487217 804d903755f6290f253e4526b1341ee4f5e2cab8
parent 487216 bb09f2ec0d284f79b4a49df1db8b455c53430be4
child 487218 32d94a3cc7afd8a09bf182d10932a0ee84407191
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer
bugs1482117
milestone63.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 1482117 - Part 1: Make FastBlock happen after tailing; r=mayhemer move the FastBlock checking block to |TriggerNetwork| Differential Revision: https://phabricator.services.mozilla.com/D3199
netwerk/protocol/http/nsHttpChannel.cpp
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -633,21 +633,16 @@ nsHttpChannel::Connect()
     if (isTrackingResource) {
         nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil =
           services::GetThirdPartyUtil();
         bool result = false;
         if (thirdPartyUtil &&
             NS_SUCCEEDED(thirdPartyUtil->IsThirdPartyChannel(this, nullptr,
                                                              &result)) &&
             result) {
-            if (CheckFastBlocked()) {
-                Unused << AsyncAbort(NS_ERROR_ABORT);
-                CloseCacheEntry(false);
-                return NS_OK;
-            }
 
             AddClassFlags(nsIClassOfService::Tail);
         }
     }
 
     if (WaitingForTailUnblock()) {
         MOZ_DIAGNOSTIC_ASSERT(!mOnTailUnblock);
         mOnTailUnblock = &nsHttpChannel::ConnectOnTailUnblock;
@@ -694,16 +689,24 @@ nsHttpChannel::CheckFastBlocked()
 
     if (!sFastBlockInited) {
         sFastBlockInited = true;
         Preferences::AddBoolVarCache(&sIsContentBlockingEnabled, "browser.contentblocking.enabled");
         Preferences::AddBoolVarCache(&sIsFastBlockEnabled, "browser.fastblock.enabled");
         Preferences::AddUintVarCache(&sFastBlockTimeout, "browser.fastblock.timeout");
     }
 
+    nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil = services::GetThirdPartyUtil();
+    bool result = false;
+    if (!thirdPartyUtil ||
+        NS_FAILED(thirdPartyUtil->IsThirdPartyChannel(this, nullptr, &result)) ||
+        !result) {
+        return false;
+    }
+
     TimeStamp timestamp;
     if (NS_FAILED(GetNavigationStartTimeStamp(&timestamp))) {
         return false;
     }
 
     if (!sIsContentBlockingEnabled || !sIsFastBlockEnabled ||
         IsContentPolicyTypeWhitelistedForFastBlock(mLoadInfo) ||
         !timestamp) {
@@ -721,16 +724,23 @@ nsHttpChannel::CheckFastBlocked()
 
 nsresult
 nsHttpChannel::ConnectOnTailUnblock()
 {
     nsresult rv;
 
     LOG(("nsHttpChannel::ConnectOnTailUnblock [this=%p]\n", this));
 
+    bool isTrackingResource = mIsTrackingResource; // is atomic
+    if (isTrackingResource && CheckFastBlocked()) {
+        Unused << AsyncAbort(NS_ERROR_ABORT);
+        CloseCacheEntry(false);
+        return NS_OK;
+    }
+
     // Consider opening a TCP connection right away.
     SpeculativeConnect();
 
     // open a cache entry for this channel...
     bool isHttps = false;
     rv = mURI->SchemeIs("https", &isHttps);
     NS_ENSURE_SUCCESS(rv,rv);
     rv = OpenCacheEntry(isHttps);