Bug 1493563 - Part 1: Make ReportBlockingToConsole() accept an nsIURI* argument instead of an nsIHttpChannel*; r=baku
☠☠ backed out by 1681bd622c63 ☠ ☠
authorEhsan Akhgari <ehsan@mozilla.com>
Sat, 22 Sep 2018 15:01:30 -0400
changeset 494512 932b41e211e04744ced36241c7469356f552a0bd
parent 494511 98c531e6f8d4fb623ced2afbda23f13d72b31dc1
child 494513 a1ff0cd6256391045da570fd8f48eeaf27b6c443
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1493563
milestone64.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 1493563 - Part 1: Make ReportBlockingToConsole() accept an nsIURI* argument instead of an nsIHttpChannel*; r=baku Differential Revision: https://phabricator.services.mozilla.com/D6591
toolkit/components/antitracking/AntiTrackingCommon.cpp
--- a/toolkit/components/antitracking/AntiTrackingCommon.cpp
+++ b/toolkit/components/antitracking/AntiTrackingCommon.cpp
@@ -194,20 +194,20 @@ CheckContentBlockingAllowList(nsIHttpCha
   }
 
   LOG(("Could not check the content blocking allow list because the top "
        "window wasn't accessible"));
   return false;
 }
 
 void
-ReportBlockingToConsole(nsPIDOMWindowOuter* aWindow, nsIHttpChannel* aChannel,
+ReportBlockingToConsole(nsPIDOMWindowOuter* aWindow, nsIURI* aURI,
                         uint32_t aRejectedReason)
 {
-  MOZ_ASSERT(aWindow && aChannel);
+  MOZ_ASSERT(aWindow && aURI);
   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_BLOCKED_SLOW_TRACKING_CONTENT);
 
   if (!AntiTrackingCommon::ShouldHonorContentBlockingCookieRestrictions()) {
     return;
@@ -246,19 +246,17 @@ ReportBlockingToConsole(nsPIDOMWindowOut
       break;
 
     default:
       return;
   }
 
   MOZ_ASSERT(message);
 
-  nsCOMPtr<nsIURI> uri;
-  aChannel->GetURI(getter_AddRefs(uri));
-  NS_ConvertUTF8toUTF16 spec(uri->GetSpecOrDefault());
+  NS_ConvertUTF8toUTF16 spec(aURI->GetSpecOrDefault());
   const char16_t* params[] = { spec.get() };
 
   nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
                                   NS_LITERAL_CSTRING("Content Blocking"),
                                   doc,
                                   nsContentUtils::eNECKO_PROPERTIES,
                                   message,
                                   params, ArrayLength(params));
@@ -1053,18 +1051,17 @@ AntiTrackingCommon::NotifyRejection(nsIC
                                     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_BLOCKED_SLOW_TRACKING_CONTENT);
 
-  nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
-  if (!httpChannel) {
+  if (!aChannel) {
     return;
   }
 
   // Can be called in EITHER the parent or child process.
   nsCOMPtr<nsIParentChannel> parentChannel;
   NS_QueryNotificationCallbacks(aChannel, parentChannel);
   if (parentChannel) {
     // This channel is a parent-process proxy for a child process request.
@@ -1074,28 +1071,31 @@ AntiTrackingCommon::NotifyRejection(nsIC
   }
 
   nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil = services::GetThirdPartyUtil();
   if (!thirdPartyUtil) {
     return;
   }
 
   nsCOMPtr<mozIDOMWindowProxy> win;
-  nsresult rv = thirdPartyUtil->GetTopWindowForChannel(httpChannel,
+  nsresult rv = thirdPartyUtil->GetTopWindowForChannel(aChannel,
                                                        getter_AddRefs(win));
   NS_ENSURE_SUCCESS_VOID(rv);
 
   nsCOMPtr<nsPIDOMWindowOuter> pwin = nsPIDOMWindowOuter::From(win);
   if (!pwin) {
     return;
   }
 
+  nsCOMPtr<nsIURI> uri;
+  aChannel->GetURI(getter_AddRefs(uri));
+
   pwin->NotifyContentBlockingState(aRejectedReason, aChannel);
 
-  ReportBlockingToConsole(pwin, httpChannel, aRejectedReason);
+  ReportBlockingToConsole(pwin, uri, aRejectedReason);
 }
 
 /* static */ void
 AntiTrackingCommon::NotifyRejection(nsPIDOMWindowInner* aWindow,
                                     uint32_t aRejectedReason)
 {
   MOZ_ASSERT(aWindow);
   MOZ_ASSERT(aRejectedReason == nsIWebProgressListener::STATE_COOKIES_BLOCKED_BY_PERMISSION ||
@@ -1104,35 +1104,37 @@ AntiTrackingCommon::NotifyRejection(nsPI
              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());
-  if (!httpChannel) {
+  nsIChannel* channel = document->GetChannel();
+  if (!channel) {
     return;
   }
 
   nsCOMPtr<nsPIDOMWindowOuter> pwin;
   auto* outer = nsGlobalWindowOuter::Cast(aWindow->GetOuterWindow());
   if (outer) {
     pwin = outer->GetTopOuter();
   }
 
   if (!pwin) {
     return;
   }
 
-  pwin->NotifyContentBlockingState(aRejectedReason, httpChannel);
+  nsCOMPtr<nsIURI> uri;
+  channel->GetURI(getter_AddRefs(uri));
 
-  ReportBlockingToConsole(pwin, httpChannel, aRejectedReason);
+  pwin->NotifyContentBlockingState(aRejectedReason, channel);
+
+  ReportBlockingToConsole(pwin, uri, aRejectedReason);
 }
 
 /* static */ void
 AntiTrackingCommon::StoreUserInteractionFor(nsIPrincipal* aPrincipal)
 {
   if (XRE_IsParentProcess()) {
     nsCOMPtr<nsIURI> uri;
     Unused << aPrincipal->GetURI(getter_AddRefs(uri));