Bug 1482950 - Backed out changeset 32d94a3cc7af. r=xeonchen!
authorFrancois Marier <francois@mozilla.com>
Sun, 19 Aug 2018 09:00:44 +0000
changeset 432462 fe91a0b8bb4c6fd0a73bde4c95754d82a1c1fb97
parent 432461 e1eca7377c4eaaf4fadb666646414ca45b2984ae
child 432463 0e95533b40e12ec879aa6fcfd0c1c735c42f443a
push id34477
push userdluca@mozilla.com
push dateTue, 21 Aug 2018 09:53:37 +0000
treeherdermozilla-central@6cc53c0f6efe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersxeonchen
bugs1482950
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 1482950 - Backed out changeset 32d94a3cc7af. r=xeonchen! This refactoring is now unnecessary since the third-party check is getting removed. Differential Revision: https://phabricator.services.mozilla.com/D3720
netwerk/protocol/http/nsHttpChannel.cpp
netwerk/protocol/http/nsHttpChannel.h
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -625,18 +625,27 @@ nsHttpChannel::Connect()
     if (ShouldIntercept()) {
         return RedirectToInterceptedChannel();
     }
 
     bool isTrackingResource = mIsTrackingResource; // is atomic
     LOG(("nsHttpChannel %p tracking resource=%d, cos=%u",
           this, isTrackingResource, mClassOfService));
 
-    if (isTrackingResource && IsThirdPartyChannel()) {
-        AddClassFlags(nsIClassOfService::Tail);
+    if (isTrackingResource) {
+        nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil =
+          services::GetThirdPartyUtil();
+        bool result = false;
+        if (thirdPartyUtil &&
+            NS_SUCCEEDED(thirdPartyUtil->IsThirdPartyChannel(this, nullptr,
+                                                             &result)) &&
+            result) {
+
+            AddClassFlags(nsIClassOfService::Tail);
+        }
     }
 
     if (WaitingForTailUnblock()) {
         MOZ_DIAGNOSTIC_ASSERT(!mOnTailUnblock);
         mOnTailUnblock = &nsHttpChannel::ConnectOnTailUnblock;
         return NS_OK;
     }
 
@@ -680,17 +689,21 @@ nsHttpChannel::CheckFastBlocked()
 
     if (!sFastBlockInited) {
         sFastBlockInited = true;
         Preferences::AddBoolVarCache(&sIsContentBlockingEnabled, "browser.contentblocking.enabled");
         Preferences::AddBoolVarCache(&sIsFastBlockEnabled, "browser.fastblock.enabled");
         Preferences::AddUintVarCache(&sFastBlockTimeout, "browser.fastblock.timeout");
     }
 
-    if (!IsThirdPartyChannel()) {
+    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;
     }
 
@@ -710,39 +723,16 @@ nsHttpChannel::CheckFastBlocked()
 
     LOG(("FastBlock %s (%lf) [this=%p]\n",
          isFastBlocking ? "timeout" : "passed",
          duration.ToMilliseconds(),
          this));
     return isFastBlocking;
 }
 
-bool
-nsHttpChannel::IsThirdPartyChannel()
-{
-    if (mIsThirdPartyChannel) {
-        return *mIsThirdPartyChannel;
-    }
-
-    nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil = services::GetThirdPartyUtil();
-    if (!thirdPartyUtil) {
-        return false;
-    }
-
-    bool isThirdPartyChannel;
-    if (NS_FAILED(thirdPartyUtil->IsThirdPartyChannel(this,
-                                                      nullptr,
-                                                      &isThirdPartyChannel))) {
-        return false;
-    }
-
-    mIsThirdPartyChannel.emplace(isThirdPartyChannel);
-    return *mIsThirdPartyChannel;
-}
-
 nsresult
 nsHttpChannel::ConnectOnTailUnblock()
 {
     nsresult rv;
 
     LOG(("nsHttpChannel::ConnectOnTailUnblock [this=%p]\n", this));
 
     bool isTrackingResource = mIsTrackingResource; // is atomic
@@ -2336,18 +2326,23 @@ nsHttpChannel::ProcessResponse()
     nsCOMPtr<nsIURI> referrer = GetReferringPage();
     if (!referrer) {
         referrer = mReferrer;
     }
 
     // We consider top-level tracking resource as non-tracking if not in 3rd
     // party context.
     bool isThirdPartyAndTrackingResource = false;
-    if (mIsTrackingResource) {
-        isThirdPartyAndTrackingResource = IsThirdPartyChannel();
+    if(mIsTrackingResource) {
+        nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil =
+          services::GetThirdPartyUtil();
+        if (thirdPartyUtil) {
+            thirdPartyUtil->IsThirdPartyChannel(this, nullptr,
+                                                &isThirdPartyAndTrackingResource);
+        }
     }
 
     if (referrer) {
         nsCOMPtr<nsILoadContextInfo> lci = GetLoadContextInfo(this);
         mozilla::net::Predictor::UpdateCacheability(referrer, mURI, httpStatus,
                                                     mRequestHead, mResponseHead,
                                                     lci,
                                                     isThirdPartyAndTrackingResource);
--- a/netwerk/protocol/http/nsHttpChannel.h
+++ b/netwerk/protocol/http/nsHttpChannel.h
@@ -27,17 +27,16 @@
 #include "AutoClose.h"
 #include "nsIStreamListener.h"
 #include "nsISupportsPrimitives.h"
 #include "nsICorsPreflightCallback.h"
 #include "AlternateServices.h"
 #include "nsIRaceCacheWithNetwork.h"
 #include "mozilla/extensions/PStreamFilterParent.h"
 #include "mozilla/Mutex.h"
-#include "mozilla/Maybe.h"
 
 class nsDNSPrefetch;
 class nsICancelable;
 class nsIHttpChannelAuthProvider;
 class nsInputStreamPump;
 class nsISSLStatus;
 
 namespace mozilla { namespace net {
@@ -656,20 +655,16 @@ private:
     // Called on untail when tailed during AsyncOpen execution.
     nsresult AsyncOpenOnTailUnblock();
     // Called on untail when tailed because of being a tracking resource.
     nsresult ConnectOnTailUnblock();
 
     // Check if current channel should be canceled by FastBlock rules.
     bool CheckFastBlocked();
 
-    // This caches the result of mozIThirdPartyUtil::IsThirdPartyChannel.
-    bool IsThirdPartyChannel();
-    Maybe<bool> mIsThirdPartyChannel;
-
     nsCString mUsername;
 
     // If non-null, warnings should be reported to this object.
     RefPtr<HttpChannelSecurityWarningReporter> mWarningReporter;
 
     RefPtr<ADivertableParentChannel> mParentChannel;
 
     // True if the channel is reading from cache.