Bug 1509555 - Part 3: Remove reporting of tracker statistics to docshell which was added for fastblock r=valentin,baku
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 27 Nov 2018 08:55:36 +0000
changeset 507531 4374fb0c23357edfe09c1901fd745ec6393e77f2
parent 507530 dd23df519c7e68fda26bee823685cd2efe1f2a54
child 507532 52afd894ca9eb8bf0596c7ac318a0d4e93233f84
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin, baku
bugs1509555
milestone65.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 1509555 - Part 3: Remove reporting of tracker statistics to docshell which was added for fastblock r=valentin,baku Depends on D12829 Differential Revision: https://phabricator.services.mozilla.com/D12830
dom/base/nsDocument.cpp
dom/base/nsIDocument.h
dom/webidl/Document.webidl
ipc/glue/BackgroundUtils.cpp
netwerk/base/LoadInfo.cpp
netwerk/base/LoadInfo.h
netwerk/base/nsILoadInfo.idl
netwerk/ipc/NeckoChannelParams.ipdlh
netwerk/protocol/http/HttpBaseChannel.cpp
netwerk/protocol/http/HttpChannelChild.cpp
netwerk/protocol/http/nsHttpChannel.cpp
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -1491,18 +1491,16 @@ nsIDocument::nsIDocument()
     mHeaderData(nullptr),
     mFlashClassification(FlashClassification::Unclassified),
     mBoxObjectTable(nullptr),
     mCurrentOrientationAngle(0),
     mCurrentOrientationType(OrientationType::Portrait_primary),
     mServoRestyleRootDirtyBits(0),
     mThrowOnDynamicMarkupInsertionCounter(0),
     mIgnoreOpensDuringUnloadCounter(0),
-    mNumTrackersFound(0),
-    mNumTrackersBlocked(0),
     mDocLWTheme(Doc_Theme_Uninitialized),
     mSavedResolution(1.0f)
 {
   SetIsInDocument();
   SetIsConnected(true);
 
   if (StaticPrefs::layout_css_use_counters_enabled()) {
     mStyleUseCounters.reset(Servo_UseCounters_Create());
--- a/dom/base/nsIDocument.h
+++ b/dom/base/nsIDocument.h
@@ -3767,42 +3767,16 @@ public:
   }
 
   void DecrementIgnoreOpensDuringUnloadCounter()
   {
     MOZ_ASSERT(mIgnoreOpensDuringUnloadCounter);
     --mIgnoreOpensDuringUnloadCounter;
   }
 
-  void IncrementTrackerCount()
-  {
-    MOZ_ASSERT(!GetSameTypeParentDocument());
-    ++mNumTrackersFound;
-  }
-
-  void IncrementTrackerBlockedCount()
-  {
-    MOZ_ASSERT(!GetSameTypeParentDocument());
-    ++mNumTrackersBlocked;
-  }
-
-  uint32_t NumTrackersFound()
-  {
-    MOZ_ASSERT(!GetSameTypeParentDocument() || mNumTrackersFound == 0);
-
-    return mNumTrackersFound;
-  }
-
-  uint32_t NumTrackersBlocked()
-  {
-    MOZ_ASSERT(!GetSameTypeParentDocument() || mNumTrackersBlocked == 0);
-
-    return mNumTrackersBlocked;
-  }
-
   bool AllowPaymentRequest() const
   {
     return mAllowPaymentRequest;
   }
 
   void SetAllowPaymentRequest(bool aAllowPaymentRequest)
   {
     mAllowPaymentRequest = aAllowPaymentRequest;
@@ -4757,22 +4731,16 @@ protected:
   // Count of unload/beforeunload/pagehide operations in progress.
   uint32_t mIgnoreOpensDuringUnloadCounter;
 
   nsCOMPtr<nsIDOMXULCommandDispatcher> mCommandDispatcher; // [OWNER] of the focus tracker
 
   RefPtr<mozilla::dom::XULBroadcastManager> mXULBroadcastManager;
   RefPtr<mozilla::dom::XULPersist> mXULPersist;
 
-  // At the moment, trackers might be blocked by Tracking Protection or FastBlock.
-  // In order to know the numbers of trackers detected and blocked, we add
-  // these two values here and those are shared by TP and FB.
-  uint32_t mNumTrackersFound;
-  uint32_t mNumTrackersBlocked;
-
   // document lightweight theme for use with :-moz-lwtheme, :-moz-lwtheme-brighttext
   // and :-moz-lwtheme-darktext
   DocumentTheme                         mDocLWTheme;
 
   // Pres shell resolution saved before entering fullscreen mode.
   float mSavedResolution;
 };
 
--- a/dom/webidl/Document.webidl
+++ b/dom/webidl/Document.webidl
@@ -522,23 +522,16 @@ enum FlashClassification {
   "allowed",        // Site is on the Flash whitelist
   "denied"          // Site is on the Flash blacklist
 };
 partial interface Document {
   [ChromeOnly]
   readonly attribute FlashClassification documentFlashClassification;
 };
 
-// Extension to obtain the number of trackers are detected and blocked in the
-// Document (and it's corresponding docshell sub-tree)
-partial interface Document {
-  [ChromeOnly] readonly attribute unsigned long numTrackersFound;
-  [ChromeOnly] readonly attribute unsigned long numTrackersBlocked;
-};
-
 partial interface Document {
   [Func="nsDocument::DocumentSupportsL10n"] readonly attribute DocumentL10n? l10n;
 };
 
 Document implements XPathEvaluator;
 Document implements GlobalEventHandlers;
 Document implements DocumentAndElementEventHandlers;
 Document implements TouchEventHandlers;
--- a/ipc/glue/BackgroundUtils.cpp
+++ b/ipc/glue/BackgroundUtils.cpp
@@ -631,18 +631,16 @@ LoadInfoArgsToLoadInfo(const OptionalLoa
 void
 LoadInfoToParentLoadInfoForwarder(nsILoadInfo* aLoadInfo,
                                   ParentLoadInfoForwarderArgs* aForwarderArgsOut)
 {
   if (!aLoadInfo) {
     *aForwarderArgsOut = ParentLoadInfoForwarderArgs(false, void_t(),
                                                      nsILoadInfo::TAINTING_BASIC,
                                                      false, // serviceWorkerTaintingSynthesized
-                                                     false, // isTracker
-                                                     false, // isTrackerBlocked
                                                      false, // documentHasUserInteracted
                                                      false  // documentHasLoaded
                                                     );
     return;
   }
 
   OptionalIPCServiceWorkerDescriptor ipcController = void_t();
   Maybe<ServiceWorkerDescriptor> controller(aLoadInfo->GetController());
@@ -653,18 +651,16 @@ LoadInfoToParentLoadInfoForwarder(nsILoa
   uint32_t tainting = nsILoadInfo::TAINTING_BASIC;
   Unused << aLoadInfo->GetTainting(&tainting);
 
   *aForwarderArgsOut = ParentLoadInfoForwarderArgs(
     aLoadInfo->GetAllowInsecureRedirectToDataURI(),
     ipcController,
     tainting,
     aLoadInfo->GetServiceWorkerTaintingSynthesized(),
-    aLoadInfo->GetIsTracker(),
-    aLoadInfo->GetIsTrackerBlocked(),
     aLoadInfo->GetDocumentHasUserInteracted(),
     aLoadInfo->GetDocumentHasLoaded()
   );
 }
 
 nsresult
 MergeParentLoadInfoForwarder(ParentLoadInfoForwarderArgs const& aForwarderArgs,
                              nsILoadInfo* aLoadInfo)
@@ -688,18 +684,16 @@ MergeParentLoadInfoForwarder(ParentLoadI
 
   if (aForwarderArgs.serviceWorkerTaintingSynthesized()) {
     aLoadInfo->SynthesizeServiceWorkerTainting(
       static_cast<LoadTainting>(aForwarderArgs.tainting()));
   } else {
     aLoadInfo->MaybeIncreaseTainting(aForwarderArgs.tainting());
   }
 
-  MOZ_ALWAYS_SUCCEEDS(aLoadInfo->SetIsTracker(aForwarderArgs.isTracker()));
-  MOZ_ALWAYS_SUCCEEDS(aLoadInfo->SetIsTrackerBlocked(aForwarderArgs.isTrackerBlocked()));
   MOZ_ALWAYS_SUCCEEDS(aLoadInfo->SetDocumentHasUserInteracted(aForwarderArgs.documentHasUserInteracted()));
   MOZ_ALWAYS_SUCCEEDS(aLoadInfo->SetDocumentHasLoaded(aForwarderArgs.documentHasLoaded()));
 
   return NS_OK;
 }
 
 void
 LoadInfoToChildLoadInfoForwarder(nsILoadInfo* aLoadInfo,
--- a/netwerk/base/LoadInfo.cpp
+++ b/netwerk/base/LoadInfo.cpp
@@ -84,18 +84,16 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadin
   , mInitialSecurityCheckDone(false)
   , mIsThirdPartyContext(false)
   , mIsDocshellReload(false)
   , mSendCSPViolationEvents(true)
   , mForcePreflight(false)
   , mIsPreflight(false)
   , mLoadTriggeredFromExternal(false)
   , mServiceWorkerTaintingSynthesized(false)
-  , mIsTracker(false)
-  , mIsTrackerBlocked(false)
   , mDocumentHasUserInteracted(false)
   , mDocumentHasLoaded(false)
   , mIsFromProcessingFrameAttributes(false)
 {
   MOZ_ASSERT(mLoadingPrincipal);
   MOZ_ASSERT(mTriggeringPrincipal);
 
 #ifdef DEBUG
@@ -356,18 +354,16 @@ LoadInfo::LoadInfo(nsPIDOMWindowOuter* a
   , mInitialSecurityCheckDone(false)
   , mIsThirdPartyContext(false) // NB: TYPE_DOCUMENT implies not third-party.
   , mIsDocshellReload(false)
   , mSendCSPViolationEvents(true)
   , mForcePreflight(false)
   , mIsPreflight(false)
   , mLoadTriggeredFromExternal(false)
   , mServiceWorkerTaintingSynthesized(false)
-  , mIsTracker(false)
-  , mIsTrackerBlocked(false)
   , mDocumentHasUserInteracted(false)
   , mDocumentHasLoaded(false)
   , mIsFromProcessingFrameAttributes(false)
 {
   // Top-level loads are never third-party
   // Grab the information we can out of the window.
   MOZ_ASSERT(aOuterWindow);
   MOZ_ASSERT(mTriggeringPrincipal);
@@ -458,18 +454,16 @@ LoadInfo::LoadInfo(const LoadInfo& rhs)
   , mAncestorPrincipals(rhs.mAncestorPrincipals)
   , mAncestorOuterWindowIDs(rhs.mAncestorOuterWindowIDs)
   , mCorsUnsafeHeaders(rhs.mCorsUnsafeHeaders)
   , mForcePreflight(rhs.mForcePreflight)
   , mIsPreflight(rhs.mIsPreflight)
   , mLoadTriggeredFromExternal(rhs.mLoadTriggeredFromExternal)
   // mServiceWorkerTaintingSynthesized must be handled specially during redirect
   , mServiceWorkerTaintingSynthesized(false)
-  , mIsTracker(rhs.mIsTracker)
-  , mIsTrackerBlocked(rhs.mIsTrackerBlocked)
   , mDocumentHasUserInteracted(rhs.mDocumentHasUserInteracted)
   , mDocumentHasLoaded(rhs.mDocumentHasLoaded)
   , mIsFromProcessingFrameAttributes(rhs.mIsFromProcessingFrameAttributes)
 {
 }
 
 LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
                    nsIPrincipal* aTriggeringPrincipal,
@@ -552,18 +546,16 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadin
   , mOriginAttributes(aOriginAttributes)
   , mAncestorPrincipals(std::move(aAncestorPrincipals))
   , mAncestorOuterWindowIDs(aAncestorOuterWindowIDs)
   , mCorsUnsafeHeaders(aCorsUnsafeHeaders)
   , mForcePreflight(aForcePreflight)
   , mIsPreflight(aIsPreflight)
   , mLoadTriggeredFromExternal(aLoadTriggeredFromExternal)
   , mServiceWorkerTaintingSynthesized(aServiceWorkerTaintingSynthesized)
-  , mIsTracker(false)
-  , mIsTrackerBlocked(false)
   , mDocumentHasUserInteracted(aDocumentHasUserInteracted)
   , mDocumentHasLoaded(aDocumentHasLoaded)
   , mIsFromProcessingFrameAttributes(false)
 {
   // Only top level TYPE_DOCUMENT loads can have a null loadingPrincipal
   MOZ_ASSERT(mLoadingPrincipal || aContentPolicyType == nsIContentPolicy::TYPE_DOCUMENT);
   MOZ_ASSERT(mTriggeringPrincipal);
 
@@ -1363,46 +1355,16 @@ LoadInfo::SynthesizeServiceWorkerTaintin
   MOZ_DIAGNOSTIC_ASSERT(aTainting <= LoadTainting::Opaque);
   mTainting = aTainting;
 
   // Flag to prevent the tainting from being increased.
   mServiceWorkerTaintingSynthesized = true;
 }
 
 NS_IMETHODIMP
-LoadInfo::GetIsTracker(bool *aIsTracker)
-{
-  MOZ_ASSERT(aIsTracker);
-  *aIsTracker = mIsTracker;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-LoadInfo::SetIsTracker(bool aIsTracker)
-{
-  mIsTracker = aIsTracker;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-LoadInfo::GetIsTrackerBlocked(bool *aIsTrackerBlocked)
-{
-  MOZ_ASSERT(aIsTrackerBlocked);
-  *aIsTrackerBlocked = mIsTrackerBlocked;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-LoadInfo::SetIsTrackerBlocked(bool aIsTrackerBlocked)
-{
-  mIsTrackerBlocked = aIsTrackerBlocked;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
 LoadInfo::GetDocumentHasUserInteracted(bool *aDocumentHasUserInteracted)
 {
   MOZ_ASSERT(aDocumentHasUserInteracted);
   *aDocumentHasUserInteracted = mDocumentHasUserInteracted;
   return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/netwerk/base/LoadInfo.h
+++ b/netwerk/base/LoadInfo.h
@@ -207,19 +207,16 @@ private:
   RedirectHistoryArray             mRedirectChain;
   nsTArray<nsCOMPtr<nsIPrincipal>> mAncestorPrincipals;
   nsTArray<uint64_t>               mAncestorOuterWindowIDs;
   nsTArray<nsCString>              mCorsUnsafeHeaders;
   bool                             mForcePreflight;
   bool                             mIsPreflight;
   bool                             mLoadTriggeredFromExternal;
   bool                             mServiceWorkerTaintingSynthesized;
-
-  bool                             mIsTracker;
-  bool                             mIsTrackerBlocked;
   bool                             mDocumentHasUserInteracted;
   bool                             mDocumentHasLoaded;
 
   // Is true if this load was triggered by processing the attributes of the
   // browsing context container.
   // See nsILoadInfo.isFromProcessingFrameAttributes
   bool                             mIsFromProcessingFrameAttributes;
 };
--- a/netwerk/base/nsILoadInfo.idl
+++ b/netwerk/base/nsILoadInfo.idl
@@ -1037,23 +1037,16 @@ interface nsILoadInfo : nsISupports
     *
     * NOTE: This should not be used outside of service worker code! Use
     *       nsILoadInfo::MaybeIncreaseTainting() instead.
    */
   [noscript, nostdcall, notxpcom]
   void SynthesizeServiceWorkerTainting(in LoadTainting aTainting);
 
   /**
-    * These flags are used for FastBlock statistics to see if a resource is a
-    * tracker and whether it was blocked by the FastBlock mechanism or not.
-    */
-  [infallible] attribute boolean isTracker;
-  [infallible] attribute boolean isTrackerBlocked;
-
-  /**
     * The top-level document has been user-interacted.
     */
   [infallible] attribute boolean documentHasUserInteracted;
 
   /**
     * This attribute represents whether the document to which this
     * load belongs had finished loading when the load was initiated.
     */
--- a/netwerk/ipc/NeckoChannelParams.ipdlh
+++ b/netwerk/ipc/NeckoChannelParams.ipdlh
@@ -142,19 +142,16 @@ struct ParentLoadInfoForwarderArgs
   // The service worker may synthesize a Response with a particular
   // tainting value.
   uint32_t tainting;
 
   // We must also note that the tainting value was explicitly set
   // by the service worker.
   bool serviceWorkerTaintingSynthesized;
 
-  // Tracker information, currently used by FastBlock
-  bool isTracker;
-  bool isTrackerBlocked;
   bool documentHasUserInteracted;
   bool documentHasLoaded;
 
   // IMPORTANT: when you add new properites here you must also update
   // LoadInfoToParentLoadInfoForwarder and MergeParentLoadInfoForwarder
   // in BackgroundUtils.cpp/.h!
 };
 
--- a/netwerk/protocol/http/HttpBaseChannel.cpp
+++ b/netwerk/protocol/http/HttpBaseChannel.cpp
@@ -327,20 +327,16 @@ HttpBaseChannel::SetIsTrackingResource(b
 
   if (aIsThirdParty) {
     MOZ_ASSERT(!mIsFirstPartyTrackingResource);
     mIsThirdPartyTrackingResource = true;
   } else {
     MOZ_ASSERT(!mIsThirdPartyTrackingResource);
     mIsFirstPartyTrackingResource = true;
   }
-
-  if (mLoadInfo) {
-    MOZ_ALWAYS_SUCCEEDS(mLoadInfo->SetIsTracker(true));
-  }
 }
 
 nsresult
 HttpBaseChannel::Init(nsIURI *aURI,
                       uint32_t aCaps,
                       nsProxyInfo *aProxyInfo,
                       uint32_t aProxyResolveFlags,
                       nsIURI *aProxyURI,
--- a/netwerk/protocol/http/HttpChannelChild.cpp
+++ b/netwerk/protocol/http/HttpChannelChild.cpp
@@ -696,48 +696,16 @@ public:
     return NS_OK;
   }
 
   NS_DECL_ISUPPORTS
 };
 
 NS_IMPL_ISUPPORTS(SyntheticDiversionListener, nsIStreamListener);
 
-static nsresult
-GetTopDocument(nsIChannel* aChannel, nsIDocument** aResult)
-{
-  nsresult rv;
-
-  nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil = services::GetThirdPartyUtil();
-  if (NS_WARN_IF(!thirdPartyUtil)) {
-    return NS_ERROR_FAILURE;
-  }
-
-  nsCOMPtr<mozIDOMWindowProxy> win;
-  rv = thirdPartyUtil->GetTopWindowForChannel(aChannel,
-                                              getter_AddRefs(win));
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return rv;
-  }
-
-  auto* pwin = nsPIDOMWindowOuter::From(win);
-  nsCOMPtr<nsIDocShell> docShell = pwin->GetDocShell();
-  if (!docShell) {
-    return NS_ERROR_FAILURE;
-  }
-
-  nsCOMPtr<nsIDocument> doc = docShell->GetDocument();
-  if (!doc) {
-    return NS_ERROR_FAILURE;
-  }
-
-  doc.forget(aResult);
-  return NS_OK;
-}
-
 void
 HttpChannelChild::DoOnStartRequest(nsIRequest* aRequest, nsISupports* aContext)
 {
   LOG(("HttpChannelChild::DoOnStartRequest [this=%p]\n", this));
 
   // In theory mListener should not be null, but in practice sometimes it is.
   MOZ_ASSERT(mListener);
   if (!mListener) {
@@ -745,35 +713,16 @@ HttpChannelChild::DoOnStartRequest(nsIRe
     return;
   }
 
   if (mSynthesizedResponsePump && mLoadFlags & LOAD_CALL_CONTENT_SNIFFERS) {
     mSynthesizedResponsePump->PeekStream(CallTypeSniffers,
                                          static_cast<nsIChannel*>(this));
   }
 
-  bool isTracker;
-  MOZ_ALWAYS_SUCCEEDS(mLoadInfo->GetIsTracker(&isTracker));
-  if (isTracker) {
-    bool isTrackerBlocked;
-    MOZ_ALWAYS_SUCCEEDS(mLoadInfo->GetIsTrackerBlocked(&isTrackerBlocked));
-    LOG(("HttpChannelChild::DoOnStartRequest FastBlock %d [this=%p]\n",
-         isTrackerBlocked,
-         this));
-
-    nsCOMPtr<nsIDocument> doc;
-    if (!NS_WARN_IF(NS_FAILED(GetTopDocument(this,
-                                             getter_AddRefs(doc))))) {
-      doc->IncrementTrackerCount();
-      if (isTrackerBlocked) {
-        doc->IncrementTrackerBlockedCount();
-      }
-    }
-  }
-
   nsresult rv = mListener->OnStartRequest(aRequest, aContext);
   if (NS_FAILED(rv)) {
     Cancel(rv);
     return;
   }
 
   if (mDivertingToParent) {
     mListener = nullptr;
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -6058,20 +6058,16 @@ nsHttpChannel::ContinueCancelledByTracki
 
 nsresult
 nsHttpChannel::CancelInternal(nsresult status)
 {
     bool trackingProtectionCancellationPending =
       !!mTrackingProtectionCancellationPending;
     if (status == NS_ERROR_TRACKING_URI) {
       mTrackingProtectionCancellationPending = 0;
-      if (mLoadInfo) {
-        MOZ_ALWAYS_SUCCEEDS(mLoadInfo->SetIsTracker(true));
-        MOZ_ALWAYS_SUCCEEDS(mLoadInfo->SetIsTrackerBlocked(true));
-      }
     }
 
     mCanceled = true;
     mStatus = status;
     if (mProxyRequest)
         mProxyRequest->Cancel(status);
     CancelNetworkRequest(status);
     mCacheInputStream.CloseAndRelease();