Bug 1588241 - P3. Move classification methods to PHttpChannel. r=mayhemer
☠☠ backed out by 2f19e7b646e0 ☠ ☠
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 12 Nov 2019 18:06:04 +0000
changeset 501693 a21cd1c41c6cbea911d0039764bdab6bc523cbf5
parent 501692 8d2cf0fc6b9bd03e2a34b6cefc0bd3be36bd06c0
child 501694 48362412c9d583393fc81a551543499b4bf31039
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)
reviewersmayhemer
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 - P3. Move classification methods to PHttpChannel. r=mayhemer We can guarantee that those callbacks will occur prior the call to OnStartRequest. By running them all on the PHttpChannel we remove the potential race between the PHttpChannel which runs on the main thread and PHttpBackroundChannel which runs on the necko thread. Depends on D52261 Differential Revision: https://phabricator.services.mozilla.com/D52262
netwerk/protocol/http/HttpBackgroundChannelChild.cpp
netwerk/protocol/http/HttpBackgroundChannelChild.h
netwerk/protocol/http/HttpBackgroundChannelParent.cpp
netwerk/protocol/http/HttpBackgroundChannelParent.h
netwerk/protocol/http/HttpChannelChild.cpp
netwerk/protocol/http/HttpChannelChild.h
netwerk/protocol/http/HttpChannelParent.cpp
netwerk/protocol/http/PHttpBackgroundChannel.ipdl
netwerk/protocol/http/PHttpChannel.ipdl
--- a/netwerk/protocol/http/HttpBackgroundChannelChild.cpp
+++ b/netwerk/protocol/http/HttpBackgroundChannelChild.cpp
@@ -226,145 +226,16 @@ IPCResult HttpBackgroundChannelChild::Re
     return IPC_OK();
   }
 
   mChannelChild->ProcessDivertMessages();
 
   return IPC_OK();
 }
 
-IPCResult
-HttpBackgroundChannelChild::RecvNotifyChannelClassifierProtectionDisabled(
-    const uint32_t& aAcceptedReason) {
-  LOG(
-      ("HttpBackgroundChannelChild::"
-       "RecvNotifyChannelClassifierProtectionDisabled [this=%p "
-       "aAcceptedReason=%" PRIu32 "]\n",
-       this, aAcceptedReason));
-  MOZ_ASSERT(OnSocketThread());
-
-  if (NS_WARN_IF(!mChannelChild)) {
-    return IPC_OK();
-  }
-
-  // NotifyChannelClassifierProtectionDisabled has no order dependency to
-  // OnStartRequest. It this be handled as soon as possible
-  mChannelChild->ProcessNotifyChannelClassifierProtectionDisabled(
-      aAcceptedReason);
-
-  return IPC_OK();
-}
-
-IPCResult HttpBackgroundChannelChild::RecvNotifyCookieAllowed() {
-  LOG(("HttpBackgroundChannelChild::RecvNotifyCookieAllowed [this=%p]\n",
-       this));
-  MOZ_ASSERT(OnSocketThread());
-
-  if (NS_WARN_IF(!mChannelChild)) {
-    return IPC_OK();
-  }
-
-  mChannelChild->ProcessNotifyCookieAllowed();
-
-  return IPC_OK();
-}
-
-IPCResult HttpBackgroundChannelChild::RecvNotifyCookieBlocked(
-    const uint32_t& aRejectedReason) {
-  LOG(
-      ("HttpBackgroundChannelChild::RecvNotifyCookieBlocked [this=%p "
-       "aRejectedReason=%" PRIu32 "]\n",
-       this, aRejectedReason));
-  MOZ_ASSERT(OnSocketThread());
-
-  if (NS_WARN_IF(!mChannelChild)) {
-    return IPC_OK();
-  }
-
-  mChannelChild->ProcessNotifyCookieBlocked(aRejectedReason);
-
-  return IPC_OK();
-}
-
-IPCResult HttpBackgroundChannelChild::RecvNotifyClassificationFlags(
-    const uint32_t& aClassificationFlags, const bool& aIsThirdParty) {
-  LOG(
-      ("HttpBackgroundChannelChild::RecvNotifyClassificationFlags "
-       "classificationFlags=%" PRIu32 ", thirdparty=%d [this=%p]\n",
-       aClassificationFlags, static_cast<int>(aIsThirdParty), this));
-  MOZ_ASSERT(OnSocketThread());
-
-  if (NS_WARN_IF(!mChannelChild)) {
-    return IPC_OK();
-  }
-
-  // NotifyClassificationFlags has no order dependency to OnStartRequest.
-  // It this be handled as soon as possible
-  mChannelChild->ProcessNotifyClassificationFlags(aClassificationFlags,
-                                                  aIsThirdParty);
-
-  return IPC_OK();
-}
-
-IPCResult HttpBackgroundChannelChild::RecvNotifyFlashPluginStateChanged(
-    const nsIHttpChannel::FlashPluginState& aState) {
-  LOG(
-      ("HttpBackgroundChannelChild::RecvNotifyFlashPluginStateChanged "
-       "[this=%p]\n",
-       this));
-  MOZ_ASSERT(OnSocketThread());
-
-  if (NS_WARN_IF(!mChannelChild)) {
-    return IPC_OK();
-  }
-
-  // NotifyFlashPluginStateChanged has no order dependency to OnStartRequest.
-  // It this be handled as soon as possible
-  mChannelChild->ProcessNotifyFlashPluginStateChanged(aState);
-
-  return IPC_OK();
-}
-
-IPCResult HttpBackgroundChannelChild::RecvSetClassifierMatchedInfo(
-    const ClassifierInfo& info) {
-  LOG(("HttpBackgroundChannelChild::RecvSetClassifierMatchedInfo [this=%p]\n",
-       this));
-  MOZ_ASSERT(OnSocketThread());
-
-  if (NS_WARN_IF(!mChannelChild)) {
-    return IPC_OK();
-  }
-
-  // SetClassifierMatchedInfo has no order dependency to OnStartRequest.
-  // It this be handled as soon as possible
-  mChannelChild->ProcessSetClassifierMatchedInfo(info.list(), info.provider(),
-                                                 info.fullhash());
-
-  return IPC_OK();
-}
-
-IPCResult HttpBackgroundChannelChild::RecvSetClassifierMatchedTrackingInfo(
-    const ClassifierInfo& info) {
-  LOG(
-      ("HttpBackgroundChannelChild::RecvSetClassifierMatchedTrackingInfo "
-       "[this=%p]\n",
-       this));
-  MOZ_ASSERT(OnSocketThread());
-
-  if (NS_WARN_IF(!mChannelChild)) {
-    return IPC_OK();
-  }
-
-  // SetClassifierMatchedTrackingInfo has no order dependency to OnStartRequest.
-  // It this be handled as soon as possible
-  mChannelChild->ProcessSetClassifierMatchedTrackingInfo(info.list(),
-                                                         info.fullhash());
-
-  return IPC_OK();
-}
 void HttpBackgroundChannelChild::ActorDestroy(ActorDestroyReason aWhy) {
   LOG(("HttpBackgroundChannelChild::ActorDestroy[this=%p]\n", this));
   // This function might be called during shutdown phase, so OnSocketThread()
   // might return false even on STS thread. Use IsOnCurrentThreadInfallible()
   // to get correct information.
   MOZ_ASSERT(gSocketTransportService);
   MOZ_ASSERT(gSocketTransportService->IsOnCurrentThreadInfallible());
 
--- a/netwerk/protocol/http/HttpBackgroundChannelChild.h
+++ b/netwerk/protocol/http/HttpBackgroundChannelChild.h
@@ -7,17 +7,16 @@
 
 #ifndef mozilla_net_HttpBackgroundChannelChild_h
 #define mozilla_net_HttpBackgroundChannelChild_h
 
 #include "mozilla/net/PHttpBackgroundChannelChild.h"
 #include "nsIRunnable.h"
 #include "nsTArray.h"
 
-using mozilla::dom::ClassifierInfo;
 using mozilla::ipc::IPCResult;
 
 namespace mozilla {
 namespace net {
 
 class HttpChannelChild;
 
 class HttpBackgroundChannelChild final : public PHttpBackgroundChannelChild {
@@ -54,33 +53,16 @@ class HttpBackgroundChannelChild final :
                               const nsHttpHeaderArray& aResponseTrailers);
 
   IPCResult RecvFlushedForDiversion();
 
   IPCResult RecvDivertMessages();
 
   IPCResult RecvOnStartRequestSent();
 
-  IPCResult RecvNotifyChannelClassifierProtectionDisabled(
-      const uint32_t& aAcceptedReason);
-
-  IPCResult RecvNotifyCookieAllowed();
-
-  IPCResult RecvNotifyCookieBlocked(const uint32_t& aRejectedReason);
-
-  IPCResult RecvNotifyClassificationFlags(const uint32_t& aClassificationFlags,
-                                          const bool& aIsThirdParty);
-
-  IPCResult RecvNotifyFlashPluginStateChanged(
-      const nsIHttpChannel::FlashPluginState& aState);
-
-  IPCResult RecvSetClassifierMatchedInfo(const ClassifierInfo& info);
-
-  IPCResult RecvSetClassifierMatchedTrackingInfo(const ClassifierInfo& info);
-
   void ActorDestroy(ActorDestroyReason aWhy) override;
 
  private:
   virtual ~HttpBackgroundChannelChild();
 
   // Initiate the creation of the PBckground IPC channel.
   // Return false if failed.
   bool CreateBackgroundChannel();
--- a/netwerk/protocol/http/HttpBackgroundChannelParent.cpp
+++ b/netwerk/protocol/http/HttpBackgroundChannelParent.cpp
@@ -258,233 +258,16 @@ bool HttpBackgroundChannelParent::OnDive
   // the OnDataAvailables and OnStopRequest to associated HttpChannelParent.
   if (!SendDivertMessages()) {
     return false;
   }
 
   return true;
 }
 
-bool HttpBackgroundChannelParent::OnNotifyChannelClassifierProtectionDisabled(
-    uint32_t aAcceptedReason) {
-  LOG(
-      ("HttpBackgroundChannelParent::"
-       "OnNotifyChannelClassifierProtectionDisabled [this=%p - "
-       "aAcceptedReason=%" PRIu32 "]\n",
-       this, aAcceptedReason));
-  AssertIsInMainProcess();
-
-  if (NS_WARN_IF(!mIPCOpened)) {
-    return false;
-  }
-
-  if (!IsOnBackgroundThread()) {
-    MutexAutoLock lock(mBgThreadMutex);
-    RefPtr<HttpBackgroundChannelParent> self = this;
-    nsresult rv = mBackgroundThread->Dispatch(
-        NS_NewRunnableFunction(
-            "net::HttpBackgroundChannelParent::"
-            "OnNotifyChannelClassifierProtectionDisabled",
-            [self, aAcceptedReason]() {
-              self->OnNotifyChannelClassifierProtectionDisabled(
-                  aAcceptedReason);
-            }),
-        NS_DISPATCH_NORMAL);
-
-    MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));
-
-    return NS_SUCCEEDED(rv);
-  }
-
-  return SendNotifyChannelClassifierProtectionDisabled(aAcceptedReason);
-}
-
-bool HttpBackgroundChannelParent::OnNotifyCookieAllowed() {
-  LOG(("HttpBackgroundChannelParent::OnNotifyCookieAllowed [this=%p]\n", this));
-  AssertIsInMainProcess();
-
-  if (NS_WARN_IF(!mIPCOpened)) {
-    return false;
-  }
-
-  if (!IsOnBackgroundThread()) {
-    MutexAutoLock lock(mBgThreadMutex);
-    RefPtr<HttpBackgroundChannelParent> self = this;
-    nsresult rv = mBackgroundThread->Dispatch(
-        NS_NewRunnableFunction(
-            "net::HttpBackgroundChannelParent::OnNotifyCookieAllowed",
-            [self]() { self->OnNotifyCookieAllowed(); }),
-        NS_DISPATCH_NORMAL);
-
-    MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));
-
-    return NS_SUCCEEDED(rv);
-  }
-
-  return SendNotifyCookieAllowed();
-}
-
-bool HttpBackgroundChannelParent::OnNotifyCookieBlocked(
-    uint32_t aRejectedReason) {
-  LOG(
-      ("HttpBackgroundChannelParent::OnNotifyCookieBlocked [this=%p "
-       "aRejectedReason=%" PRIu32 "]\n",
-       this, aRejectedReason));
-  AssertIsInMainProcess();
-
-  if (NS_WARN_IF(!mIPCOpened)) {
-    return false;
-  }
-
-  if (!IsOnBackgroundThread()) {
-    MutexAutoLock lock(mBgThreadMutex);
-    RefPtr<HttpBackgroundChannelParent> self = this;
-    nsresult rv = mBackgroundThread->Dispatch(
-        NS_NewRunnableFunction(
-            "net::HttpBackgroundChannelParent::OnNotifyCookieBlocked",
-            [self, aRejectedReason]() {
-              self->OnNotifyCookieBlocked(aRejectedReason);
-            }),
-        NS_DISPATCH_NORMAL);
-
-    MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));
-
-    return NS_SUCCEEDED(rv);
-  }
-
-  return SendNotifyCookieBlocked(aRejectedReason);
-}
-
-bool HttpBackgroundChannelParent::OnNotifyClassificationFlags(
-    uint32_t aClassificationFlags, bool aIsThirdParty) {
-  LOG(
-      ("HttpBackgroundChannelParent::OnNotifyClassificationFlags "
-       "classificationFlags=%" PRIu32 ", thirdparty=%d [this=%p]\n",
-       aClassificationFlags, static_cast<int>(aIsThirdParty), this));
-  AssertIsInMainProcess();
-
-  if (NS_WARN_IF(!mIPCOpened)) {
-    return false;
-  }
-
-  if (!IsOnBackgroundThread()) {
-    MutexAutoLock lock(mBgThreadMutex);
-    nsresult rv = mBackgroundThread->Dispatch(
-        NewRunnableMethod<uint32_t, bool>(
-            "net::HttpBackgroundChannelParent::OnNotifyClassificationFlags",
-            this, &HttpBackgroundChannelParent::OnNotifyClassificationFlags,
-            aClassificationFlags, aIsThirdParty),
-        NS_DISPATCH_NORMAL);
-
-    MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));
-
-    return NS_SUCCEEDED(rv);
-  }
-
-  return SendNotifyClassificationFlags(aClassificationFlags, aIsThirdParty);
-}
-
-bool HttpBackgroundChannelParent::OnNotifyFlashPluginStateChanged(
-    nsIHttpChannel::FlashPluginState aState) {
-  LOG(
-      ("HttpBackgroundChannelParent::OnNotifyFlashPluginStateChanged "
-       "[this=%p]\n",
-       this));
-  AssertIsInMainProcess();
-
-  if (NS_WARN_IF(!mIPCOpened)) {
-    return false;
-  }
-
-  if (!IsOnBackgroundThread()) {
-    MutexAutoLock lock(mBgThreadMutex);
-    RefPtr<HttpBackgroundChannelParent> self = this;
-    nsresult rv = mBackgroundThread->Dispatch(
-        NS_NewRunnableFunction(
-            "net::HttpBackgroundChannelParent::OnNotifyFlashPluginStateChanged",
-            [self, aState]() {
-              self->OnNotifyFlashPluginStateChanged(aState);
-            }),
-        NS_DISPATCH_NORMAL);
-
-    MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));
-
-    return NS_SUCCEEDED(rv);
-  }
-
-  return SendNotifyFlashPluginStateChanged(aState);
-}
-
-bool HttpBackgroundChannelParent::OnSetClassifierMatchedInfo(
-    const nsACString& aList, const nsACString& aProvider,
-    const nsACString& aFullHash) {
-  LOG(("HttpBackgroundChannelParent::OnSetClassifierMatchedInfo [this=%p]\n",
-       this));
-  AssertIsInMainProcess();
-
-  if (NS_WARN_IF(!mIPCOpened)) {
-    return false;
-  }
-
-  if (!IsOnBackgroundThread()) {
-    MutexAutoLock lock(mBgThreadMutex);
-    nsresult rv = mBackgroundThread->Dispatch(
-        NewRunnableMethod<const nsCString, const nsCString, const nsCString>(
-            "net::HttpBackgroundChannelParent::OnSetClassifierMatchedInfo",
-            this, &HttpBackgroundChannelParent::OnSetClassifierMatchedInfo,
-            aList, aProvider, aFullHash),
-        NS_DISPATCH_NORMAL);
-
-    MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));
-
-    return NS_SUCCEEDED(rv);
-  }
-
-  ClassifierInfo info;
-  info.list() = aList;
-  info.fullhash() = aFullHash;
-  info.provider() = aProvider;
-
-  return SendSetClassifierMatchedInfo(info);
-}
-
-bool HttpBackgroundChannelParent::OnSetClassifierMatchedTrackingInfo(
-    const nsACString& aLists, const nsACString& aFullHashes) {
-  LOG(
-      ("HttpBackgroundChannelParent::OnSetClassifierMatchedTrackingInfo "
-       "[this=%p]\n",
-       this));
-  AssertIsInMainProcess();
-
-  if (NS_WARN_IF(!mIPCOpened)) {
-    return false;
-  }
-
-  if (!IsOnBackgroundThread()) {
-    MutexAutoLock lock(mBgThreadMutex);
-    nsresult rv = mBackgroundThread->Dispatch(
-        NewRunnableMethod<const nsCString, const nsCString>(
-            "net::HttpBackgroundChannelParent::"
-            "OnSetClassifierMatchedTrackingInfo",
-            this,
-            &HttpBackgroundChannelParent::OnSetClassifierMatchedTrackingInfo,
-            aLists, aFullHashes),
-        NS_DISPATCH_NORMAL);
-
-    MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));
-
-    return NS_SUCCEEDED(rv);
-  }
-
-  ClassifierInfo info;
-  info.list() = aLists;
-  info.fullhash() = aFullHashes;
-
-  return SendSetClassifierMatchedTrackingInfo(info);
-}
 void HttpBackgroundChannelParent::ActorDestroy(ActorDestroyReason aWhy) {
   LOG(("HttpBackgroundChannelParent::ActorDestroy [this=%p]\n", this));
   AssertIsInMainProcess();
   AssertIsOnBackgroundThread();
 
   mIPCOpened = false;
 
   RefPtr<HttpBackgroundChannelParent> self = this;
--- a/netwerk/protocol/http/HttpBackgroundChannelParent.h
+++ b/netwerk/protocol/http/HttpBackgroundChannelParent.h
@@ -52,42 +52,16 @@ class HttpBackgroundChannelParent final 
   bool OnStopRequest(const nsresult& aChannelStatus,
                      const ResourceTimingStruct& aTiming,
                      const nsHttpHeaderArray& aResponseTrailers);
 
   // To send FlushedForDiversion and DivertMessages messages
   // over background channel.
   bool OnDiversion();
 
-  // To send NotifyChannelClassifierProtectionDisabled message over background
-  // channel.
-  bool OnNotifyChannelClassifierProtectionDisabled(uint32_t aAcceptedReason);
-
-  // To send NotifyCookieAllowed message over background channel.
-  bool OnNotifyCookieAllowed();
-
-  // To send NotifyCookieBlocked message over background channel.
-  bool OnNotifyCookieBlocked(uint32_t aRejectedReason);
-
-  // To send NotifyClassificationFlags message over background channel.
-  bool OnNotifyClassificationFlags(uint32_t aClassificationFlags,
-                                   bool aIsThirdParty);
-
-  // To send NotifyFlashPluginStateChanged message over background channel.
-  bool OnNotifyFlashPluginStateChanged(nsIHttpChannel::FlashPluginState aState);
-
-  // To send SetClassifierMatchedInfo message over background channel.
-  bool OnSetClassifierMatchedInfo(const nsACString& aList,
-                                  const nsACString& aProvider,
-                                  const nsACString& aFullHash);
-
-  // To send SetClassifierMatchedTrackingInfo message over background channel.
-  bool OnSetClassifierMatchedTrackingInfo(const nsACString& aLists,
-                                          const nsACString& aFullHashes);
-
  protected:
   void ActorDestroy(ActorDestroyReason aWhy) override;
 
  private:
   virtual ~HttpBackgroundChannelParent();
 
   Atomic<bool> mIPCOpened;
 
--- a/netwerk/protocol/http/HttpChannelChild.cpp
+++ b/netwerk/protocol/http/HttpChannelChild.cpp
@@ -1614,87 +1614,88 @@ void HttpChannelChild::ProcessFlushedFor
   MOZ_RELEASE_ASSERT(mDivertingToParent);
 
   RefPtr<HttpChannelChild> self = this;
   mEventQ->RunOrEnqueue(new NeckoTargetChannelFunctionEvent(
                             this, [self]() { self->FlushedForDiversion(); }),
                         true);
 }
 
-void HttpChannelChild::ProcessNotifyChannelClassifierProtectionDisabled(
-    uint32_t aAcceptedReason) {
+mozilla::ipc::IPCResult
+HttpChannelChild::RecvNotifyChannelClassifierProtectionDisabled(
+    const uint32_t& aAcceptedReason) {
   LOG(
-      ("HttpChannelChild::ProcessNotifyChannelClassifierProtectionDisabled "
+      ("HttpChannelChild::RecvNotifyChannelClassifierProtectionDisabled "
        "[this=%p aAcceptedReason=%" PRIu32 "]\n",
        this, aAcceptedReason));
-  MOZ_ASSERT(OnSocketThread());
+  MOZ_ASSERT(NS_IsMainThread());
 
   RefPtr<HttpChannelChild> self = this;
-  nsCOMPtr<nsIEventTarget> neckoTarget = GetNeckoTarget();
-  neckoTarget->Dispatch(
-      NS_NewRunnableFunction(
-          "AntiTrackingCommon::NotifyChannelClassifierProtectionDisabled",
-          [self, aAcceptedReason]() {
-            UrlClassifierCommon::NotifyChannelClassifierProtectionDisabled(
-                self, aAcceptedReason);
-          }),
-      NS_DISPATCH_NORMAL);
+  mEventQ->RunOrEnqueue(new NeckoTargetChannelFunctionEvent(this, [=] {
+    UrlClassifierCommon::NotifyChannelClassifierProtectionDisabled(
+        self, aAcceptedReason);
+  }));
+
+  return IPC_OK();
 }
 
-void HttpChannelChild::ProcessNotifyCookieAllowed() {
-  LOG(("HttpChannelChild::ProcessNotifyCookieAllowed [this=%p]\n", this));
-  MOZ_ASSERT(OnSocketThread());
+mozilla::ipc::IPCResult HttpChannelChild::RecvNotifyCookieAllowed() {
+  LOG(("HttpChannelChild::RecvNotifyCookieAllowed [this=%p]\n", this));
+  MOZ_ASSERT(NS_IsMainThread());
 
   RefPtr<HttpChannelChild> self = this;
-  nsCOMPtr<nsIEventTarget> neckoTarget = GetNeckoTarget();
-  neckoTarget->Dispatch(
-      NS_NewRunnableFunction(
-          "UrlClassifierCommon::NotifyBlockingDecision",
-          [self]() {
-            AntiTrackingCommon::NotifyBlockingDecision(
-                self, AntiTrackingCommon::BlockingDecision::eAllow, 0);
-          }),
-      NS_DISPATCH_NORMAL);
+  mEventQ->RunOrEnqueue(new NeckoTargetChannelFunctionEvent(this, [=] {
+    AntiTrackingCommon::NotifyBlockingDecision(
+        self, AntiTrackingCommon::BlockingDecision::eAllow, 0);
+  }));
+
+  return IPC_OK();
 }
 
-void HttpChannelChild::ProcessNotifyCookieBlocked(uint32_t aRejectedReason) {
-  LOG(("HttpChannelChild::ProcessNotifyCookieBlocked [this=%p]\n", this));
-  MOZ_ASSERT(OnSocketThread());
+mozilla::ipc::IPCResult HttpChannelChild::RecvNotifyCookieBlocked(
+    const uint32_t& aRejectedReason) {
+  LOG(("HttpChannelChild::RecvNotifyCookieBlocked [this=%p]\n", this));
+  MOZ_ASSERT(NS_IsMainThread());
 
   RefPtr<HttpChannelChild> self = this;
-  nsCOMPtr<nsIEventTarget> neckoTarget = GetNeckoTarget();
-  neckoTarget->Dispatch(
-      NS_NewRunnableFunction("AntiTrackingCommon::NotifyBlockingDecision",
-                             [self, aRejectedReason]() {
-                               AntiTrackingCommon::NotifyBlockingDecision(
-                                   self,
-                                   AntiTrackingCommon::BlockingDecision::eBlock,
-                                   aRejectedReason);
-                             }),
-      NS_DISPATCH_NORMAL);
+  mEventQ->RunOrEnqueue(new NeckoTargetChannelFunctionEvent(this, [=] {
+    AntiTrackingCommon::NotifyBlockingDecision(
+        self, AntiTrackingCommon::BlockingDecision::eBlock, aRejectedReason);
+  }));
+
+  return IPC_OK();
 }
 
-void HttpChannelChild::ProcessNotifyClassificationFlags(
-    uint32_t aClassificationFlags, bool aIsThirdParty) {
+mozilla::ipc::IPCResult HttpChannelChild::RecvNotifyClassificationFlags(
+    const uint32_t& aClassificationFlags, const bool& aIsThirdParty) {
   LOG(
-      ("HttpChannelChild::ProcessNotifyClassificationFlags thirdparty=%d "
+      ("HttpChannelChild::RecvNotifyClassificationFlags thirdparty=%d "
        "flags=%" PRIu32 " [this=%p]\n",
        static_cast<int>(aIsThirdParty), aClassificationFlags, this));
-  MOZ_ASSERT(OnSocketThread());
-
-  AddClassificationFlags(aClassificationFlags, aIsThirdParty);
+  MOZ_ASSERT(NS_IsMainThread());
+
+  RefPtr<HttpChannelChild> self = this;
+  mEventQ->RunOrEnqueue(new NeckoTargetChannelFunctionEvent(this, [=] {
+    self->AddClassificationFlags(aClassificationFlags, aIsThirdParty);
+  }));
+
+  return IPC_OK();
 }
 
-void HttpChannelChild::ProcessNotifyFlashPluginStateChanged(
-    nsIHttpChannel::FlashPluginState aState) {
-  LOG(("HttpChannelChild::ProcessNotifyFlashPluginStateChanged [this=%p]\n",
+mozilla::ipc::IPCResult HttpChannelChild::RecvNotifyFlashPluginStateChanged(
+    const nsIHttpChannel::FlashPluginState& aState) {
+  LOG(("HttpChannelChild::RecvNotifyFlashPluginStateChanged [this=%p]\n",
        this));
-  MOZ_ASSERT(OnSocketThread());
-
-  SetFlashPluginState(aState);
+  MOZ_ASSERT(NS_IsMainThread());
+
+  RefPtr<HttpChannelChild> self = this;
+  mEventQ->RunOrEnqueue(new NeckoTargetChannelFunctionEvent(
+      this, [=] { self->SetFlashPluginState(aState); }));
+
+  return IPC_OK();
 }
 
 void HttpChannelChild::FlushedForDiversion() {
   LOG(("HttpChannelChild::FlushedForDiversion [this=%p]\n", this));
   MOZ_RELEASE_ASSERT(mDivertingToParent);
 
   // Once this is set, it should not be unset before HttpChannelChild is taken
   // down. After it is set, no OnStart/OnData/OnStop callbacks should be
@@ -1703,50 +1704,48 @@ void HttpChannelChild::FlushedForDiversi
 
   // If we're synthesized, it's up to the SyntheticDiversionListener to invoke
   // SendDivertComplete after it has sent the DivertOnStopRequestMessage.
   if (!mSynthesizedResponse) {
     SendDivertComplete();
   }
 }
 
-void HttpChannelChild::ProcessSetClassifierMatchedInfo(
-    const nsCString& aList, const nsCString& aProvider,
-    const nsCString& aFullHash) {
-  LOG(("HttpChannelChild::ProcessSetClassifierMatchedInfo [this=%p]\n", this));
-  MOZ_ASSERT(OnSocketThread());
-
-  nsCOMPtr<nsIEventTarget> neckoTarget = GetNeckoTarget();
-  neckoTarget->Dispatch(
-      NewRunnableMethod<const nsCString, const nsCString, const nsCString>(
-          "HttpChannelChild::SetMatchedInfo", this,
-          &HttpChannelChild::SetMatchedInfo, aList, aProvider, aFullHash),
-      NS_DISPATCH_NORMAL);
+mozilla::ipc::IPCResult HttpChannelChild::RecvSetClassifierMatchedInfo(
+    const ClassifierInfo& aInfo) {
+  LOG(("HttpChannelChild::RecvSetClassifierMatchedInfo [this=%p]\n", this));
+  MOZ_ASSERT(NS_IsMainThread());
+
+  RefPtr<HttpChannelChild> self = this;
+  mEventQ->RunOrEnqueue(new NeckoTargetChannelFunctionEvent(this, [=]() {
+    self->SetMatchedInfo(aInfo.list(), aInfo.provider(), aInfo.fullhash());
+  }));
+
+  return IPC_OK();
 }
 
-void HttpChannelChild::ProcessSetClassifierMatchedTrackingInfo(
-    const nsCString& aLists, const nsCString& aFullHashes) {
-  LOG(("HttpChannelChild::ProcessSetClassifierMatchedTrackingInfo [this=%p]\n",
+mozilla::ipc::IPCResult HttpChannelChild::RecvSetClassifierMatchedTrackingInfo(
+    const ClassifierInfo& aInfo) {
+  LOG(("HttpChannelChild::RecvSetClassifierMatchedTrackingInfo [this=%p]\n",
        this));
-  MOZ_ASSERT(OnSocketThread());
+  MOZ_ASSERT(NS_IsMainThread());
 
   nsTArray<nsCString> lists, fullhashes;
-  for (const nsACString& token : aLists.Split(',')) {
+  for (const nsACString& token : aInfo.list().Split(',')) {
     lists.AppendElement(token);
   }
-  for (const nsACString& token : aFullHashes.Split(',')) {
+  for (const nsACString& token : aInfo.fullhash().Split(',')) {
     fullhashes.AppendElement(token);
   }
 
-  nsCOMPtr<nsIEventTarget> neckoTarget = GetNeckoTarget();
-  neckoTarget->Dispatch(
-      NewRunnableMethod<const nsTArray<nsCString>, const nsTArray<nsCString>>(
-          "HttpChannelChild::SetMatchedTrackingInfo", this,
-          &HttpChannelChild::SetMatchedTrackingInfo, lists, fullhashes),
-      NS_DISPATCH_NORMAL);
+  RefPtr<HttpChannelChild> self = this;
+  mEventQ->RunOrEnqueue(new NeckoTargetChannelFunctionEvent(
+      this, [=]() { self->SetMatchedTrackingInfo(lists, fullhashes); }));
+
+  return IPC_OK();
 }
 
 void HttpChannelChild::ProcessDivertMessages() {
   LOG(("HttpChannelChild::ProcessDivertMessages [this=%p]\n", this));
   MOZ_ASSERT(OnSocketThread());
   MOZ_RELEASE_ASSERT(mDivertingToParent);
 
   // DivertTo() has been called on parent, so we can now start sending queued
--- a/netwerk/protocol/http/HttpChannelChild.h
+++ b/netwerk/protocol/http/HttpChannelChild.h
@@ -177,16 +177,36 @@ class HttpChannelChild final : public PH
       const Maybe<IPCStream>& aStream) override;
 
   mozilla::ipc::IPCResult RecvAltDataCacheInputStreamAvailable(
       const Maybe<IPCStream>& aStream) override;
 
   mozilla::ipc::IPCResult RecvOverrideReferrerInfoDuringBeginConnect(
       nsIReferrerInfo* aReferrerInfo) override;
 
+  mozilla::ipc::IPCResult RecvNotifyChannelClassifierProtectionDisabled(
+      const uint32_t& aAcceptedReason) override;
+
+  mozilla::ipc::IPCResult RecvNotifyCookieAllowed() override;
+
+  mozilla::ipc::IPCResult RecvNotifyCookieBlocked(
+      const uint32_t& aRejectedReason) override;
+
+  mozilla::ipc::IPCResult RecvNotifyClassificationFlags(
+      const uint32_t& aClassificationFlags, const bool& aIsThirdParty) override;
+
+  mozilla::ipc::IPCResult RecvNotifyFlashPluginStateChanged(
+      const nsIHttpChannel::FlashPluginState& aState) override;
+
+  mozilla::ipc::IPCResult RecvSetClassifierMatchedInfo(
+      const ClassifierInfo& info) override;
+
+  mozilla::ipc::IPCResult RecvSetClassifierMatchedTrackingInfo(
+      const ClassifierInfo& info) override;
+
   virtual void ActorDestroy(ActorDestroyReason aWhy) override;
 
   virtual void DoNotifyListenerCleanup() override;
 
   virtual void DoAsyncAbort(nsresult aStatus) override;
 
   nsresult AsyncCall(
       void (HttpChannelChild::*funcPtr)(),
@@ -265,29 +285,16 @@ class HttpChannelChild final : public PH
                                  const uint64_t& aOffset,
                                  const uint32_t& aCount,
                                  const nsCString& aData);
   void ProcessOnStopRequest(const nsresult& aStatusCode,
                             const ResourceTimingStruct& aTiming,
                             const nsHttpHeaderArray& aResponseTrailers);
   void ProcessFlushedForDiversion();
   void ProcessDivertMessages();
-  void ProcessNotifyChannelClassifierProtectionDisabled(
-      uint32_t aAcceptedReason);
-  void ProcessNotifyCookieAllowed();
-  void ProcessNotifyCookieBlocked(uint32_t aRejectedReason);
-  void ProcessNotifyClassificationFlags(uint32_t aClassificationFlags,
-                                        bool aIsThirdParty);
-  void ProcessNotifyFlashPluginStateChanged(
-      nsIHttpChannel::FlashPluginState aState);
-  void ProcessSetClassifierMatchedInfo(const nsCString& aList,
-                                       const nsCString& aProvider,
-                                       const nsCString& aFullHash);
-  void ProcessSetClassifierMatchedTrackingInfo(const nsCString& aLists,
-                                               const nsCString& aFullHashes);
 
   // Return true if we need to tell the parent the size of unreported received
   // data
   bool NeedToReportBytesRead();
   int32_t mUnreportBytesRead = 0;
 
   void DoOnStartRequest(nsIRequest* aRequest, nsISupports* aContext);
   void DoOnStatus(nsIRequest* aRequest, nsresult status);
--- a/netwerk/protocol/http/HttpChannelParent.cpp
+++ b/netwerk/protocol/http/HttpChannelParent.cpp
@@ -1849,92 +1849,90 @@ HttpChannelParent::SetParentListener(Par
 NS_IMETHODIMP
 HttpChannelParent::NotifyChannelClassifierProtectionDisabled(
     uint32_t aAcceptedReason) {
   LOG(
       ("HttpChannelParent::NotifyChannelClassifierProtectionDisabled [this=%p "
        "aAcceptedReason=%" PRIu32 "]\n",
        this, aAcceptedReason));
   if (!mIPCClosed) {
-    MOZ_ASSERT(mBgParent);
-    Unused << NS_WARN_IF(
-        !mBgParent->OnNotifyChannelClassifierProtectionDisabled(
-            aAcceptedReason));
+    Unused << SendNotifyChannelClassifierProtectionDisabled(aAcceptedReason);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HttpChannelParent::NotifyCookieAllowed() {
   LOG(("HttpChannelParent::NotifyCookieAllowed [this=%p]\n", this));
   if (!mIPCClosed) {
-    MOZ_ASSERT(mBgParent);
-    Unused << NS_WARN_IF(!mBgParent->OnNotifyCookieAllowed());
+    Unused << SendNotifyCookieAllowed();
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HttpChannelParent::NotifyCookieBlocked(uint32_t aRejectedReason) {
   LOG(("HttpChannelParent::NotifyCookieBlocked [this=%p]\n", this));
   if (!mIPCClosed) {
-    MOZ_ASSERT(mBgParent);
-    Unused << NS_WARN_IF(!mBgParent->OnNotifyCookieBlocked(aRejectedReason));
+    Unused << SendNotifyCookieBlocked(aRejectedReason);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HttpChannelParent::SetClassifierMatchedInfo(const nsACString& aList,
                                             const nsACString& aProvider,
                                             const nsACString& aFullHash) {
   LOG(("HttpChannelParent::SetClassifierMatchedInfo [this=%p]\n", this));
   if (!mIPCClosed) {
-    MOZ_ASSERT(mBgParent);
-    Unused << mBgParent->OnSetClassifierMatchedInfo(aList, aProvider,
-                                                    aFullHash);
+    ClassifierInfo info;
+    info.list() = aList;
+    info.provider() = aProvider;
+    info.fullhash() = aFullHash;
+
+    Unused << SendSetClassifierMatchedInfo(info);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HttpChannelParent::SetClassifierMatchedTrackingInfo(
     const nsACString& aLists, const nsACString& aFullHashes) {
   LOG(("HttpChannelParent::SetClassifierMatchedTrackingInfo [this=%p]\n",
        this));
   if (!mIPCClosed) {
-    MOZ_ASSERT(mBgParent);
-    Unused << mBgParent->OnSetClassifierMatchedTrackingInfo(aLists,
-                                                            aFullHashes);
+    ClassifierInfo info;
+    info.list() = aLists;
+    info.fullhash() = aFullHashes;
+
+    Unused << SendSetClassifierMatchedTrackingInfo(info);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HttpChannelParent::NotifyClassificationFlags(uint32_t aClassificationFlags,
                                              bool aIsThirdParty) {
   LOG(
       ("HttpChannelParent::NotifyClassificationFlags "
        "classificationFlags=%" PRIu32 ", thirdparty=%d [this=%p]\n",
        aClassificationFlags, static_cast<int>(aIsThirdParty), this));
   if (!mIPCClosed) {
-    MOZ_ASSERT(mBgParent);
-    Unused << mBgParent->OnNotifyClassificationFlags(aClassificationFlags,
-                                                     aIsThirdParty);
+    Unused << SendNotifyClassificationFlags(aClassificationFlags,
+                                            aIsThirdParty);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HttpChannelParent::NotifyFlashPluginStateChanged(
     nsIHttpChannel::FlashPluginState aState) {
   LOG(("HttpChannelParent::NotifyFlashPluginStateChanged [this=%p]\n", this));
   if (!mIPCClosed) {
-    MOZ_ASSERT(mBgParent);
-    Unused << mBgParent->OnNotifyFlashPluginStateChanged(aState);
+    Unused << SendNotifyFlashPluginStateChanged(aState);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HttpChannelParent::Delete() {
   if (!mIPCClosed) Unused << DoSendDeleteSelf();
 
--- a/netwerk/protocol/http/PHttpBackgroundChannel.ipdl
+++ b/netwerk/protocol/http/PHttpBackgroundChannel.ipdl
@@ -2,23 +2,21 @@
 /* vim: set sw=2 ts=8 et tw=80 ft=cpp : */
 
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 include protocol PBackground;
 include NeckoChannelParams;
-include PURLClassifierInfo;
 
 include "mozilla/net/NeckoMessageUtils.h";
 
 using class nsHttpHeaderArray from "nsHttpHeaderArray.h";
 using struct mozilla::net::ResourceTimingStruct from "mozilla/net/TimingStruct.h";
-using nsIHttpChannel::FlashPluginState from "mozilla/net/NeckoMessageUtils.h";
 
 namespace mozilla {
 namespace net {
 
 //-------------------------------------------------------------------
 async refcounted protocol PHttpBackgroundChannel
 {
   manager PBackground;
@@ -45,38 +43,14 @@ child:
 
   // Parent has been suspended for diversion; no more events to be enqueued.
   async FlushedForDiversion();
 
   // Child should resume processing the ChannelEventQueue, i.e. diverting any
   // OnDataAvailable and OnStopRequest messages in the queue back to the parent.
   async DivertMessages();
 
-  // Tell the child that channel classifier protection was disabled for this
-  // load.
-  async NotifyChannelClassifierProtectionDisabled(uint32_t aAcceptedReason);
-
-  // Tell the child that cookies are allowed for this load.
-  async NotifyCookieAllowed();
-
-  // Tell the child that tracking cookies are blocked for this load.
-  async NotifyCookieBlocked(uint32_t aRejectedReason);
-
-  // Tell the child that the resource being loaded has been classified.
-  async NotifyClassificationFlags(uint32_t aClassificationFlags, bool aIsThirdParty);
-
-  // Tell the child that the current channel's document is not allowed to load
-  // flash content.
-  async NotifyFlashPluginStateChanged(FlashPluginState aState);
-
-  // Tell the child information of matched URL againts SafeBrowsing list
-  async SetClassifierMatchedInfo(ClassifierInfo info);
-
-  // Tell the child information of matched URL againts SafeBrowsing tracking list
-  async SetClassifierMatchedTrackingInfo(ClassifierInfo info);
-
   async __delete__();
 
 };
 
-
 } // namespace net
 } // namespace mozilla
--- a/netwerk/protocol/http/PHttpChannel.ipdl
+++ b/netwerk/protocol/http/PHttpChannel.ipdl
@@ -8,23 +8,25 @@
 include protocol PNecko;
 include protocol PStreamFilter;
 include InputStreamParams;
 include URIParams;
 include PBackgroundSharedTypes;
 include NeckoChannelParams;
 include IPCServiceWorkerDescriptor;
 include IPCStream;
+include PURLClassifierInfo;
 
 include "mozilla/net/NeckoMessageUtils.h";
 
 using class nsHttpHeaderArray from "nsHttpHeaderArray.h";
 using mozilla::net::NetAddr from "mozilla/net/DNS.h";
 using struct mozilla::net::ResourceTimingStruct from "mozilla/net/TimingStruct.h";
 using refcounted class nsIReferrerInfo from "mozilla/dom/ReferrerInfoUtils.h";
+using nsIHttpChannel::FlashPluginState from "mozilla/net/NeckoMessageUtils.h";
 
 namespace mozilla {
 namespace net {
 
 //-------------------------------------------------------------------
 refcounted protocol PHttpChannel
 {
   manager PNecko;
@@ -189,16 +191,39 @@ child:
   async AltDataCacheInputStreamAvailable(IPCStream? stream);
 
   async OverrideReferrerInfoDuringBeginConnect(nsIReferrerInfo referrerInfo);
 
   async OnProgress(int64_t progress, int64_t progressMax);
 
   async OnStatus(nsresult status);
 
+  // Tell the child that channel classifier protection was disabled for this
+  // load.
+  async NotifyChannelClassifierProtectionDisabled(uint32_t aAcceptedReason);
+
+  // Tell the child that cookies are allowed for this load.
+  async NotifyCookieAllowed();
+
+  // Tell the child that tracking cookies are blocked for this load.
+  async NotifyCookieBlocked(uint32_t aRejectedReason);
+
+  // Tell the child that the resource being loaded has been classified.
+  async NotifyClassificationFlags(uint32_t aClassificationFlags, bool aIsThirdParty);
+
+  // Tell the child that the current channel's document is not allowed to load
+  // flash content.
+  async NotifyFlashPluginStateChanged(FlashPluginState aState);
+
+  // Tell the child information of matched URL againts SafeBrowsing list
+  async SetClassifierMatchedInfo(ClassifierInfo info);
+
+  // Tell the child information of matched URL againts SafeBrowsing tracking list
+  async SetClassifierMatchedTrackingInfo(ClassifierInfo info);
+
 both:
   // After receiving this message, the parent also calls
   // SendFinishInterceptedRedirect, and makes sure not to send any more messages
   // after that. When receiving this message, the child will call
   // Send__delete__() and complete the steps required to finish the redirect.
   async FinishInterceptedRedirect();
 
   async SetPriority(int16_t priority);