Bug 1487390 - Notify when a channel is aborted because of fastblocking, r=ehsan
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 31 Aug 2018 11:02:33 +0200
changeset 492010 37133ece7ce2e9f8672fc8bea356ccaa17ce60cc
parent 492009 b9f1881a5854a260ab2d06d300f9f5b9be707755
child 492011 016e135dee84c8ce2bc30aa5cd0f13830415d5c8
child 492019 5d49aabdab5caae983f78a4bdab5fa117a2ce699
push id1815
push userffxbld-merge
push dateMon, 15 Oct 2018 10:40:45 +0000
treeherdermozilla-release@18d4c09e9378 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1487390
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 1487390 - Notify when a channel is aborted because of fastblocking, r=ehsan
netwerk/protocol/http/nsHttpChannel.cpp
toolkit/components/antitracking/AntiTrackingCommon.cpp
toolkit/components/antitracking/AntiTrackingCommon.h
uriloader/base/nsIWebProgressListener.idl
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -735,16 +735,18 @@ nsresult
 nsHttpChannel::ConnectOnTailUnblock()
 {
     nsresult rv;
 
     LOG(("nsHttpChannel::ConnectOnTailUnblock [this=%p]\n", this));
 
     bool isTrackingResource = mIsThirdPartyTrackingResource; // is atomic
     if (isTrackingResource && CheckFastBlocked()) {
+        AntiTrackingCommon::NotifyRejection(this,
+                                            nsIWebProgressListener::STATE_BLOCKED_SLOW_TRACKING_CONTENT);
         Unused << AsyncAbort(NS_ERROR_ABORT);
         CloseCacheEntry(false);
         return NS_OK;
     }
 
     // Consider opening a TCP connection right away.
     SpeculativeConnect();
 
--- a/toolkit/components/antitracking/AntiTrackingCommon.cpp
+++ b/toolkit/components/antitracking/AntiTrackingCommon.cpp
@@ -877,17 +877,18 @@ AntiTrackingCommon::IsOnContentBlockingA
 
 /* static */ void
 AntiTrackingCommon::NotifyRejection(nsIChannel* aChannel,
                                     uint32_t aRejectedReason)
 {
   MOZ_ASSERT(aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION ||
              aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER ||
              aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL ||
-             aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN);
+             aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN ||
+             aRejectedReason == nsIWebProgressListener::STATE_BLOCKED_SLOW_TRACKING_CONTENT);
 
   nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
   if (!httpChannel) {
     return;
   }
 
   // Can be called in EITHER the parent or child process.
   nsCOMPtr<nsIParentChannel> parentChannel;
@@ -920,17 +921,18 @@ AntiTrackingCommon::NotifyRejection(nsIC
 /* static */ void
 AntiTrackingCommon::NotifyRejection(nsPIDOMWindowInner* aWindow,
                                     uint32_t aRejectedReason)
 {
   MOZ_ASSERT(aWindow);
   MOZ_ASSERT(aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION ||
              aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER ||
              aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL ||
-             aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN);
+             aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN ||
+             aRejectedReason == nsIWebProgressListener::STATE_BLOCKED_SLOW_TRACKING_CONTENT);
 
   nsIDocument* document = aWindow->GetExtantDoc();
   if (!document) {
     return;
   }
 
   nsCOMPtr<nsIHttpChannel> httpChannel =
     do_QueryInterface(document->GetChannel());
--- a/toolkit/components/antitracking/AntiTrackingCommon.h
+++ b/toolkit/components/antitracking/AntiTrackingCommon.h
@@ -104,16 +104,17 @@ public:
   // The notification is propagated to the child channel if aChannel is a parent
   // channel proxy.
   //
   // aRejectedReason must be one of these values:
   //  * nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION
   //  * nsIWebProgressListener::STATE_COOKIES_BLOCKED_TRACKER
   //  * nsIWebProgressListener::STATE_COOKIES_BLOCKED_ALL
   //  * nsIWebProgressListener::STATE_COOKIES_BLOCKED_FOREIGN
+  //  * nsIWebProgressListener::STATE_BLOCKED_SLOW_TRACKING_CONTENT
   static void
   NotifyRejection(nsIChannel* aChannel, uint32_t aRejectedReason);
 
   static void
   NotifyRejection(nsPIDOMWindowInner* aWindow, uint32_t aRejectedReason);
 };
 
 } // namespace mozilla
--- a/uriloader/base/nsIWebProgressListener.idl
+++ b/uriloader/base/nsIWebProgressListener.idl
@@ -303,21 +303,25 @@ interface nsIWebProgressListener : nsISu
    *   Rejected because the resource is a tracker and cookie policy doesn't
    *   allow its loading.
    *
    * STATE_COOKIES_BLOCKED_ALL
    *   Rejected because cookie policy blocks all cookies.
    *
    * STATE_COOKIES_BLOCKED_FOREIGN
    *   Rejected because cookie policy blocks 3rd party cookies.
+   *
+   * STATE_BLOCKED_SLOW_TRACKING_CONTENT
+   *   Rejected because of the FastBlock feature.
    */
   const unsigned long STATE_COOKIES_BLOCKED_BY_PERMISSION = 0x10000000;
   const unsigned long STATE_COOKIES_BLOCKED_TRACKER       = 0x20000000;
   const unsigned long STATE_COOKIES_BLOCKED_ALL           = 0x40000000;
   const unsigned long STATE_COOKIES_BLOCKED_FOREIGN       = 0x80000000;
+  const unsigned long STATE_BLOCKED_SLOW_TRACKING_CONTENT = 0x00000040;
 
   /**
    * Notification indicating the state has changed for one of the requests
    * associated with aWebProgress.
    *
    * @param aWebProgress
    *        The nsIWebProgress instance that fired the notification
    * @param aRequest