Bug 1588241 - P4. Remove nsIClassifiedChannel implementation from DocumentChannelChild. r=mattwoodrow
☠☠ backed out by 2f19e7b646e0 ☠ ☠
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 12 Nov 2019 23:35:20 +0000
changeset 501694 48362412c9d583393fc81a551543499b4bf31039
parent 501693 a21cd1c41c6cbea911d0039764bdab6bc523cbf5
child 501695 c9a6203582acc7285034ab684d1f844e2ddda108
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1588241
milestone72.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 1588241 - P4. Remove nsIClassifiedChannel implementation from DocumentChannelChild. r=mattwoodrow The information is now passed to the parent channel once replacement is completed. Depends on D52262 Differential Revision: https://phabricator.services.mozilla.com/D52263
netwerk/ipc/DocumentChannelChild.cpp
netwerk/ipc/DocumentChannelChild.h
netwerk/ipc/DocumentChannelParent.cpp
netwerk/ipc/DocumentChannelParent.h
netwerk/ipc/PDocumentChannel.ipdl
--- a/netwerk/ipc/DocumentChannelChild.cpp
+++ b/netwerk/ipc/DocumentChannelChild.cpp
@@ -38,17 +38,16 @@ NS_INTERFACE_MAP_BEGIN(DocumentChannelCh
     // internally, but doesn't implement the interface. Everything
     // before AsyncOpen should be duplicated in the parent process
     // on the real http channel, but anything trying to QI to nsIHttpChannel
     // after that will be failing and get confused.
     NS_WARNING(
         "Trying to request nsIHttpChannel from DocumentChannelChild, this is "
         "likely broken");
   }
-  NS_INTERFACE_MAP_ENTRY(nsIClassifiedChannel)
   NS_INTERFACE_MAP_ENTRY(nsITraceableChannel)
   NS_INTERFACE_MAP_ENTRY_CONCRETE(DocumentChannelChild)
 NS_INTERFACE_MAP_END_INHERITING(nsBaseChannel)
 
 NS_IMPL_ADDREF_INHERITED(DocumentChannelChild, nsBaseChannel)
 NS_IMPL_RELEASE_INHERITED(DocumentChannelChild, nsBaseChannel)
 
 DocumentChannelChild::DocumentChannelChild(
@@ -465,67 +464,16 @@ IPCResult DocumentChannelChild::RecvConf
 
   Maybe<nsresult> cancelCode;
   rv = CSPService::ConsultCSPForRedirect(originalUri, aNewUri, mLoadInfo,
                                          cancelCode);
   aResolve(Tuple<const nsresult&, const Maybe<nsresult>&>(rv, cancelCode));
   return IPC_OK();
 }
 
-IPCResult DocumentChannelChild::RecvNotifyClassificationFlags(
-    const uint32_t& aClassificationFlags, const bool& aIsThirdParty) {
-  if (aIsThirdParty) {
-    mThirdPartyClassificationFlags |= aClassificationFlags;
-  } else {
-    mFirstPartyClassificationFlags |= aClassificationFlags;
-  }
-  return IPC_OK();
-}
-
-IPCResult DocumentChannelChild::RecvNotifyChannelClassifierProtectionDisabled(
-    const uint32_t& aAcceptedReason) {
-  UrlClassifierCommon::NotifyChannelClassifierProtectionDisabled(
-      this, aAcceptedReason);
-  return IPC_OK();
-}
-
-IPCResult DocumentChannelChild::RecvNotifyCookieAllowed() {
-  AntiTrackingCommon::NotifyBlockingDecision(
-      this, AntiTrackingCommon::BlockingDecision::eAllow, 0);
-  return IPC_OK();
-}
-
-IPCResult DocumentChannelChild::RecvNotifyCookieBlocked(
-    const uint32_t& aRejectedReason) {
-  AntiTrackingCommon::NotifyBlockingDecision(
-      this, AntiTrackingCommon::BlockingDecision::eBlock, aRejectedReason);
-  return IPC_OK();
-}
-
-IPCResult DocumentChannelChild::RecvSetClassifierMatchedInfo(
-    const nsCString& aList, const nsCString& aProvider,
-    const nsCString& aFullHash) {
-  SetMatchedInfo(aList, aProvider, aFullHash);
-  return IPC_OK();
-}
-
-IPCResult DocumentChannelChild::RecvSetClassifierMatchedTrackingInfo(
-    const nsCString& aLists, const nsCString& aFullHash) {
-  nsTArray<nsCString> lists, fullhashes;
-  for (const nsACString& token : aLists.Split(',')) {
-    lists.AppendElement(token);
-  }
-  for (const nsACString& token : aFullHash.Split(',')) {
-    fullhashes.AppendElement(token);
-  }
-
-  SetMatchedTrackingInfo(lists, fullhashes);
-  return IPC_OK();
-}
-
 mozilla::ipc::IPCResult DocumentChannelChild::RecvAttachStreamFilter(
     Endpoint<extensions::PStreamFilterParent>&& aEndpoint) {
   extensions::StreamFilterParent::Attach(this, std::move(aEndpoint));
   return IPC_OK();
 }
 
 //-----------------------------------------------------------------------------
 // DocumentChannelChild::nsITraceableChannel
@@ -538,74 +486,16 @@ DocumentChannelChild::SetNewListener(nsI
 
   nsCOMPtr<nsIStreamListener> wrapper = new nsStreamListenerWrapper(mListener);
 
   wrapper.forget(_retval);
   mListener = aListener;
   return NS_OK;
 }
 
-//-----------------------------------------------------------------------------
-// DocumentChannelChild::nsIClassifiedChannel
-
-NS_IMETHODIMP
-DocumentChannelChild::GetMatchedList(nsACString& aList) {
-  aList = mMatchedList;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-DocumentChannelChild::GetMatchedProvider(nsACString& aProvider) {
-  aProvider = mMatchedProvider;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-DocumentChannelChild::GetMatchedFullHash(nsACString& aFullHash) {
-  aFullHash = mMatchedFullHash;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-DocumentChannelChild::SetMatchedInfo(const nsACString& aList,
-                                     const nsACString& aProvider,
-                                     const nsACString& aFullHash) {
-  NS_ENSURE_ARG(!aList.IsEmpty());
-
-  mMatchedList = aList;
-  mMatchedProvider = aProvider;
-  mMatchedFullHash = aFullHash;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-DocumentChannelChild::GetMatchedTrackingLists(nsTArray<nsCString>& aLists) {
-  aLists = mMatchedTrackingLists;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-DocumentChannelChild::GetMatchedTrackingFullHashes(
-    nsTArray<nsCString>& aFullHashes) {
-  aFullHashes = mMatchedTrackingFullHashes;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-DocumentChannelChild::SetMatchedTrackingInfo(
-    const nsTArray<nsCString>& aLists, const nsTArray<nsCString>& aFullHashes) {
-  NS_ENSURE_ARG(!aLists.IsEmpty());
-  // aFullHashes can be empty for non hash-matching algorithm, for example,
-  // host based test entries in preference.
-
-  mMatchedTrackingLists = aLists;
-  mMatchedTrackingFullHashes = aFullHashes;
-  return NS_OK;
-}
-
 NS_IMETHODIMP
 DocumentChannelChild::Cancel(nsresult aStatusCode) {
   if (mCanceled) {
     return NS_OK;
   }
 
   mCanceled = true;
   if (CanSend()) {
@@ -637,70 +527,10 @@ DocumentChannelChild::Resume() {
   if (!--mSuspendCount) {
     SendResume();
   }
 
   mEventQueue->Resume();
   return NS_OK;
 }
 
-NS_IMETHODIMP
-DocumentChannelChild::IsTrackingResource(bool* aIsTrackingResource) {
-  MOZ_ASSERT(!mFirstPartyClassificationFlags ||
-             !mThirdPartyClassificationFlags);
-  *aIsTrackingResource = UrlClassifierCommon::IsTrackingClassificationFlag(
-                             mThirdPartyClassificationFlags) ||
-                         UrlClassifierCommon::IsTrackingClassificationFlag(
-                             mFirstPartyClassificationFlags);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-DocumentChannelChild::IsThirdPartyTrackingResource(bool* aIsTrackingResource) {
-  MOZ_ASSERT(
-      !(mFirstPartyClassificationFlags && mThirdPartyClassificationFlags));
-  *aIsTrackingResource = UrlClassifierCommon::IsTrackingClassificationFlag(
-      mThirdPartyClassificationFlags);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-DocumentChannelChild::IsSocialTrackingResource(
-    bool* aIsSocialTrackingResource) {
-  MOZ_ASSERT(!mFirstPartyClassificationFlags ||
-             !mThirdPartyClassificationFlags);
-  *aIsSocialTrackingResource =
-      UrlClassifierCommon::IsSocialTrackingClassificationFlag(
-          mThirdPartyClassificationFlags) ||
-      UrlClassifierCommon::IsSocialTrackingClassificationFlag(
-          mFirstPartyClassificationFlags);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-DocumentChannelChild::GetClassificationFlags(uint32_t* aClassificationFlags) {
-  MOZ_ASSERT(aClassificationFlags);
-  if (mThirdPartyClassificationFlags) {
-    *aClassificationFlags = mThirdPartyClassificationFlags;
-  } else {
-    *aClassificationFlags = mFirstPartyClassificationFlags;
-  }
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-DocumentChannelChild::GetFirstPartyClassificationFlags(
-    uint32_t* aClassificationFlags) {
-  MOZ_ASSERT(aClassificationFlags);
-  *aClassificationFlags = mFirstPartyClassificationFlags;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-DocumentChannelChild::GetThirdPartyClassificationFlags(
-    uint32_t* aClassificationFlags) {
-  MOZ_ASSERT(aClassificationFlags);
-  *aClassificationFlags = mThirdPartyClassificationFlags;
-  return NS_OK;
-}
-
 }  // namespace net
 }  // namespace mozilla
--- a/netwerk/ipc/DocumentChannelChild.h
+++ b/netwerk/ipc/DocumentChannelChild.h
@@ -7,43 +7,40 @@
 
 #ifndef mozilla_net_DocumentChannelChild_h
 #define mozilla_net_DocumentChannelChild_h
 
 #include "mozilla/net/ChannelEventQueue.h"
 #include "mozilla/net/PDocumentChannelChild.h"
 #include "nsBaseChannel.h"
 #include "nsIChildChannel.h"
-#include "nsIClassifiedChannel.h"
 #include "nsITraceableChannel.h"
 
 #define DOCUMENT_CHANNEL_CHILD_IID                   \
   {                                                  \
     0x6977bc44, 0xb1db, 0x41b7, {                    \
       0xb5, 0xc5, 0xe2, 0x13, 0x68, 0x22, 0xc9, 0x8f \
     }                                                \
   }
 
 namespace mozilla {
 namespace net {
 
 class DocumentChannelChild final : public PDocumentChannelChild,
                                    public nsBaseChannel,
-                                   public nsIClassifiedChannel,
                                    public nsITraceableChannel {
  public:
   DocumentChannelChild(nsDocShellLoadState* aLoadState,
                        class LoadInfo* aLoadInfo,
                        const nsString* aInitiatorType, nsLoadFlags aLoadFlags,
                        uint32_t aLoadType, uint32_t aCacheKey, bool aIsActive,
                        bool aIsTopLevelDoc, bool aHasNonEmptySandboxingFlags);
 
   NS_DECL_ISUPPORTS_INHERITED;
   NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK
-  NS_DECL_NSICLASSIFIEDCHANNEL
   NS_DECL_NSITRACEABLECHANNEL
 
   NS_DECLARE_STATIC_IID_ACCESSOR(DOCUMENT_CHANNEL_CHILD_IID)
 
   // nsIRequest
   NS_IMETHOD Cancel(nsresult status) override;
   NS_IMETHOD Suspend() override;
   NS_IMETHOD Resume() override;
@@ -70,30 +67,16 @@ class DocumentChannelChild final : publi
       const uint32_t& aRedirectMode, const uint32_t& aRedirectFlags,
       const Maybe<uint32_t>& aContentDisposition,
       const Maybe<nsString>& aContentDispositionFilename,
       RedirectToRealChannelResolver&& aResolve);
 
   mozilla::ipc::IPCResult RecvAttachStreamFilter(
       Endpoint<extensions::PStreamFilterParent>&& aEndpoint);
 
-  mozilla::ipc::IPCResult RecvNotifyClassificationFlags(
-      const uint32_t& aClassificationFlags, const bool& aIsThirdParty);
-  mozilla::ipc::IPCResult RecvNotifyChannelClassifierProtectionDisabled(
-      const uint32_t& aAcceptedReason);
-  mozilla::ipc::IPCResult RecvNotifyCookieAllowed();
-  mozilla::ipc::IPCResult RecvNotifyCookieBlocked(
-      const uint32_t& aRejectedReason);
-
-  mozilla::ipc::IPCResult RecvSetClassifierMatchedInfo(
-      const nsCString& aList, const nsCString& aProvider,
-      const nsCString& aFullHash);
-  mozilla::ipc::IPCResult RecvSetClassifierMatchedTrackingInfo(
-      const nsCString& aLists, const nsCString& aFullHash);
-
   mozilla::ipc::IPCResult RecvConfirmRedirect(
       const LoadInfoArgs& aLoadInfo, nsIURI* aNewUri,
       ConfirmRedirectResolver&& aResolve);
 
   void DoFailedAsyncOpen(const nsresult& aStatusCode);
 
   const nsTArray<DocumentChannelRedirect>& GetRedirectChain() const {
     return mRedirects;
@@ -105,25 +88,16 @@ class DocumentChannelChild final : publi
   void ShutdownListeners(nsresult aStatusCode);
 
   ~DocumentChannelChild() = default;
 
   RefPtr<ChannelEventQueue> mEventQueue;
   nsCOMPtr<nsIChannel> mRedirectChannel;
   nsTArray<DocumentChannelRedirect> mRedirects;
 
-  // Classified channel's matched information
-  uint32_t mFirstPartyClassificationFlags = 0;
-  uint32_t mThirdPartyClassificationFlags = 0;
-  nsCString mMatchedList;
-  nsCString mMatchedProvider;
-  nsCString mMatchedFullHash;
-  nsTArray<nsCString> mMatchedTrackingLists;
-  nsTArray<nsCString> mMatchedTrackingFullHashes;
-
   RedirectToRealChannelResolver mRedirectResolver;
 
   TimeStamp mAsyncOpenTime;
   const RefPtr<nsDocShellLoadState> mLoadState;
   const Maybe<nsString> mInitiatorType;
   const uint32_t mLoadType;
   const uint32_t mCacheKey;
   const bool mIsActive;
--- a/netwerk/ipc/DocumentChannelParent.cpp
+++ b/netwerk/ipc/DocumentChannelParent.cpp
@@ -284,16 +284,27 @@ void DocumentChannelParent::FinishReplac
         },
         [redirectChannel](const ClassifierMatchedTrackingInfoParams& aParams) {
           redirectChannel->SetClassifierMatchedTrackingInfo(
               aParams.mLists, aParams.mFullHashes);
         },
         [redirectChannel](const ClassificationFlagsParams& aParams) {
           redirectChannel->NotifyClassificationFlags(
               aParams.mClassificationFlags, aParams.mIsThirdParty);
+        },
+        [redirectChannel](
+            const NotifyChannelClassifierProtectionDisabledParams& aParams) {
+          redirectChannel->NotifyChannelClassifierProtectionDisabled(
+              aParams.mAcceptedReason);
+        },
+        [redirectChannel](const NotifyCookieAllowedParams&) {
+          redirectChannel->NotifyCookieAllowed();
+        },
+        [redirectChannel](const NotifyCookieBlockedParams& aParams) {
+          redirectChannel->NotifyCookieBlocked(aParams.mRejectedReason);
         });
   }
 
   RefPtr<HttpChannelParent> httpParent = do_QueryObject(redirectChannel);
   if (httpParent) {
     RefPtr<HttpChannelSecurityWarningReporter> reporter = httpParent;
     for (auto& variant : mSecurityWarningFunctions) {
       variant.match(
@@ -687,99 +698,82 @@ DocumentChannelParent::GetInterface(cons
 
   return QueryInterface(aIID, result);
 }
 
 // Rather than forwarding all these nsIParentChannel functions to the child, we
 // cache a list of them, and then ask the 'real' channel to forward them for us
 // after it's created.
 NS_IMETHODIMP
-DocumentChannelParent::NotifyChannelClassifierProtectionDisabled(
-    uint32_t aAcceptedReason) {
-  if (CanSend()) {
-    Unused << SendNotifyChannelClassifierProtectionDisabled(aAcceptedReason);
-  }
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-DocumentChannelParent::NotifyCookieAllowed() {
-  if (CanSend()) {
-    Unused << SendNotifyCookieAllowed();
-  }
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-DocumentChannelParent::NotifyCookieBlocked(uint32_t aRejectedReason) {
-  if (CanSend()) {
-    Unused << SendNotifyCookieBlocked(aRejectedReason);
-  }
-  return NS_OK;
-}
-
-NS_IMETHODIMP
 DocumentChannelParent::NotifyFlashPluginStateChanged(
     nsIHttpChannel::FlashPluginState aState) {
   mIParentChannelFunctions.AppendElement(
       IParentChannelFunction{VariantIndex<0>{}, aState});
   return NS_OK;
 }
 
 NS_IMETHODIMP
 DocumentChannelParent::SetClassifierMatchedInfo(const nsACString& aList,
                                                 const nsACString& aProvider,
                                                 const nsACString& aFullHash) {
   ClassifierMatchedInfoParams params;
   params.mList = aList;
   params.mProvider = aProvider;
   params.mFullHash = aFullHash;
 
-  if (CanSend()) {
-    Unused << SendSetClassifierMatchedInfo(params.mList, params.mProvider,
-                                           params.mFullHash);
-  }
-
   mIParentChannelFunctions.AppendElement(
       IParentChannelFunction{VariantIndex<1>{}, std::move(params)});
   return NS_OK;
 }
 
 NS_IMETHODIMP
 DocumentChannelParent::SetClassifierMatchedTrackingInfo(
     const nsACString& aLists, const nsACString& aFullHash) {
   ClassifierMatchedTrackingInfoParams params;
   params.mLists = aLists;
   params.mFullHashes = aFullHash;
 
-  if (CanSend()) {
-    Unused << SendSetClassifierMatchedTrackingInfo(params.mLists,
-                                                   params.mFullHashes);
-  }
-
   mIParentChannelFunctions.AppendElement(
       IParentChannelFunction{VariantIndex<2>{}, std::move(params)});
   return NS_OK;
 }
 
 NS_IMETHODIMP
 DocumentChannelParent::NotifyClassificationFlags(uint32_t aClassificationFlags,
                                                  bool aIsThirdParty) {
-  if (CanSend()) {
-    Unused << SendNotifyClassificationFlags(aClassificationFlags,
-                                            aIsThirdParty);
-  }
-
   mIParentChannelFunctions.AppendElement(IParentChannelFunction{
       VariantIndex<3>{},
       ClassificationFlagsParams{aClassificationFlags, aIsThirdParty}});
   return NS_OK;
 }
 
 NS_IMETHODIMP
+DocumentChannelParent::NotifyChannelClassifierProtectionDisabled(
+    uint32_t aAcceptedReason) {
+  mIParentChannelFunctions.AppendElement(IParentChannelFunction{
+      VariantIndex<4>{},
+      NotifyChannelClassifierProtectionDisabledParams{aAcceptedReason}});
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+DocumentChannelParent::NotifyCookieAllowed() {
+  mIParentChannelFunctions.AppendElement(
+      IParentChannelFunction{VariantIndex<5>{}, NotifyCookieAllowedParams()});
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+DocumentChannelParent::NotifyCookieBlocked(uint32_t aRejectedReason) {
+  mIParentChannelFunctions.AppendElement(IParentChannelFunction{
+      VariantIndex<6>{}, NotifyCookieBlockedParams{aRejectedReason}});
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 DocumentChannelParent::Delete() {
   // TODO - not sure we need it, but should delete the child or call on the
   // child to release the parent.
   if (!CanSend()) {
     return NS_ERROR_UNEXPECTED;
   }
   Unused << SendDeleteSelf();
   return NS_OK;
--- a/netwerk/ipc/DocumentChannelParent.h
+++ b/netwerk/ipc/DocumentChannelParent.h
@@ -125,19 +125,32 @@ class DocumentChannelParent : public nsI
   struct ClassifierMatchedTrackingInfoParams {
     nsCString mLists;
     nsCString mFullHashes;
   };
   struct ClassificationFlagsParams {
     uint32_t mClassificationFlags;
     bool mIsThirdParty;
   };
+
+  struct NotifyChannelClassifierProtectionDisabledParams {
+    uint32_t mAcceptedReason;
+  };
+
+  struct NotifyCookieAllowedParams {};
+
+  struct NotifyCookieBlockedParams {
+    uint32_t mRejectedReason;
+  };
+
   typedef mozilla::Variant<
       nsIHttpChannel::FlashPluginState, ClassifierMatchedInfoParams,
-      ClassifierMatchedTrackingInfoParams, ClassificationFlagsParams>
+      ClassifierMatchedTrackingInfoParams, ClassificationFlagsParams,
+      NotifyChannelClassifierProtectionDisabledParams,
+      NotifyCookieAllowedParams, NotifyCookieBlockedParams>
       IParentChannelFunction;
 
   // Store a list of all the attribute setters that have been called on this
   // channel, so that we can repeat them on the real channel that we redirect
   // to.
   nsTArray<IParentChannelFunction> mIParentChannelFunctions;
 
   // This defines a variant this describes all the functions
--- a/netwerk/ipc/PDocumentChannel.ipdl
+++ b/netwerk/ipc/PDocumentChannel.ipdl
@@ -45,25 +45,16 @@ parent:
   async __delete__();
 
 child:
 
   // Used to cancel child channel if we hit errors during creating and
   // AsyncOpen of nsHttpChannel on the parent.
   async FailedAsyncOpen(nsresult status);
 
-  async NotifyClassificationFlags(uint32_t classificationFlags, bool
-isThirdParty);
-  async NotifyChannelClassifierProtectionDisabled(uint32_t acceptedReason);
-  async NotifyCookieAllowed();
-  async NotifyCookieBlocked(uint32_t rejectedReason);
-
-  async SetClassifierMatchedInfo(nsCString list, nsCString provider, nsCString fullHash);
-  async SetClassifierMatchedTrackingInfo(nsCString lists, nsCString fullHash);
-  
   async AttachStreamFilter(Endpoint<PStreamFilterParent> aEndpoint);
 
   // This message is sent to a child that has been redirected to another process.
   // As a consequence, it should cleanup the channel listeners and remove the
   // request from the loadGroup.
   // aStatus must be an error result.
   async DisconnectChildListeners(nsresult aStatus);