Bug 1356211 - Part 2: Move PURLClassifierLocal from PContent to PBackground. (implementation) draft
authorHenry Chang <hchang@mozilla.com>
Tue, 02 May 2017 11:37:56 +0800
changeset 571114 cf413b80579442afc202a629ed7cf4305430d7a9
parent 571113 27ed1c69f46cfad681e5b24b43f8b686bc7547b1
child 571115 ab3b69fd6222874d91dc458149d883c563d79a5d
push id56685
push userhchang@mozilla.com
push dateTue, 02 May 2017 03:43:08 +0000
bugs1356211
milestone55.0a1
Bug 1356211 - Part 2: Move PURLClassifierLocal from PContent to PBackground. (implementation) MozReview-Commit-ID: LrplsHUbYdl
dom/ipc/ContentChild.cpp
dom/ipc/ContentChild.h
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
dom/ipc/URLClassifierChild.h
dom/ipc/URLClassifierParent.cpp
dom/ipc/URLClassifierParent.h
ipc/glue/BackgroundChildImpl.cpp
ipc/glue/BackgroundChildImpl.h
ipc/glue/BackgroundParentImpl.cpp
ipc/glue/BackgroundParentImpl.h
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -3216,31 +3216,16 @@ ContentChild::AllocPURLClassifierChild(c
 bool
 ContentChild::DeallocPURLClassifierChild(PURLClassifierChild* aActor)
 {
   MOZ_ASSERT(aActor);
   delete aActor;
   return true;
 }
 
-PURLClassifierLocalChild*
-ContentChild::AllocPURLClassifierLocalChild(const URIParams& aUri,
-                                            const nsCString& aTables)
-{
-  return new URLClassifierLocalChild();
-}
-
-bool
-ContentChild::DeallocPURLClassifierLocalChild(PURLClassifierLocalChild* aActor)
-{
-  MOZ_ASSERT(aActor);
-  delete aActor;
-  return true;
-}
-
 // The IPC code will call this method asking us to assign an event target to new
 // actors created by the ContentParent.
 already_AddRefed<nsIEventTarget>
 ContentChild::GetConstructedEventTarget(const Message& aMsg)
 {
   // Currently we only set targets for PBrowser.
   if (aMsg.type() != PContent::Msg_PBrowserConstructor__ID) {
     return nullptr;
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -628,23 +628,16 @@ public:
   // PURLClassifierChild
   virtual PURLClassifierChild*
   AllocPURLClassifierChild(const Principal& aPrincipal,
                            const bool& aUseTrackingProtection,
                            bool* aSuccess) override;
   virtual bool
   DeallocPURLClassifierChild(PURLClassifierChild* aActor) override;
 
-  // PURLClassifierLocalChild
-  virtual PURLClassifierLocalChild*
-  AllocPURLClassifierLocalChild(const URIParams& aUri,
-                                const nsCString& aTables) override;
-  virtual bool
-  DeallocPURLClassifierLocalChild(PURLClassifierLocalChild* aActor) override;
-
   nsTArray<LookAndFeelInt>&
   LookAndFeelCache() {
     return mLookAndFeelCache;
   }
 
   /**
    * Helper function for protocols that use the GPU process when available.
    * Overrides FatalError to just be a warning when communicating with the
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -5206,58 +5206,16 @@ ContentParent::DeallocPURLClassifierPare
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aActor);
 
   RefPtr<URLClassifierParent> actor =
     dont_AddRef(static_cast<URLClassifierParent*>(aActor));
   return true;
 }
 
-//////////////////////////////////////////////////////////////////
-// PURLClassifierLocalParent
-
-PURLClassifierLocalParent*
-ContentParent::AllocPURLClassifierLocalParent(const URIParams& aURI,
-                                              const nsCString& aTables)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  RefPtr<URLClassifierLocalParent> actor = new URLClassifierLocalParent();
-  return actor.forget().take();
-}
-
-mozilla::ipc::IPCResult
-ContentParent::RecvPURLClassifierLocalConstructor(PURLClassifierLocalParent* aActor,
-                                                  const URIParams& aURI,
-                                                  const nsCString& aTables)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  MOZ_ASSERT(aActor);
-
-  nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
-  if (!uri) {
-    NS_WARNING("Failed to DeserializeURI");
-    return IPC_FAIL_NO_REASON(this);
-  }
-
-  auto* actor = static_cast<URLClassifierLocalParent*>(aActor);
-  return actor->StartClassify(uri, aTables);
-}
-
-bool
-ContentParent::DeallocPURLClassifierLocalParent(PURLClassifierLocalParent* aActor)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  MOZ_ASSERT(aActor);
-
-  RefPtr<URLClassifierLocalParent> actor =
-    dont_AddRef(static_cast<URLClassifierLocalParent*>(aActor));
-  return true;
-}
-
 mozilla::ipc::IPCResult
 ContentParent::RecvClassifyLocal(const URIParams& aURI, const nsCString& aTables,
                                  nsresult *aRv, nsTArray<nsCString>* aResults)
 {
   MOZ_ASSERT(aResults);
   nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
   if (!uri) {
     return IPC_FAIL_NO_REASON(this);
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -604,25 +604,16 @@ public:
                             const bool& aUseTrackingProtection,
                             bool* aSuccess) override;
   virtual mozilla::ipc::IPCResult
   RecvPURLClassifierConstructor(PURLClassifierParent* aActor,
                                 const Principal& aPrincipal,
                                 const bool& aUseTrackingProtection,
                                 bool* aSuccess) override;
 
-  // PURLClassifierLocalParent.
-  virtual PURLClassifierLocalParent*
-  AllocPURLClassifierLocalParent(const URIParams& aURI,
-                                 const nsCString& aTables) override;
-  virtual mozilla::ipc::IPCResult
-  RecvPURLClassifierLocalConstructor(PURLClassifierLocalParent* aActor,
-                                     const URIParams& aURI,
-                                     const nsCString& aTables) override;
-
   virtual bool SendActivate(PBrowserParent* aTab) override
   {
     return PContentParent::SendActivate(aTab);
   }
 
   virtual bool SendDeactivate(PBrowserParent* aTab) override
   {
     return PContentParent::SendDeactivate(aTab);
@@ -630,19 +621,16 @@ public:
 
   virtual bool SendParentActivated(PBrowserParent* aTab,
                                    const bool& aActivated) override
   {
     return PContentParent::SendParentActivated(aTab, aActivated);
   }
 
   virtual bool
-  DeallocPURLClassifierLocalParent(PURLClassifierLocalParent* aActor) override;
-
-  virtual bool
   DeallocPURLClassifierParent(PURLClassifierParent* aActor) override;
 
   virtual mozilla::ipc::IPCResult
   RecvClassifyLocal(const URIParams& aURI,
                     const nsCString& aTables,
                     nsresult* aRv,
                     nsTArray<nsCString>* aResults) override;
 
--- a/dom/ipc/URLClassifierChild.h
+++ b/dom/ipc/URLClassifierChild.h
@@ -4,48 +4,67 @@
  * 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/. */
 
 #ifndef mozilla_dom_URLClassifierChild_h
 #define mozilla_dom_URLClassifierChild_h
 
 #include "mozilla/dom/PURLClassifierChild.h"
 #include "mozilla/dom/PURLClassifierLocalChild.h"
+#include "mozilla/SyncRunnable.h"
 #include "nsIURIClassifier.h"
 
 namespace mozilla {
 namespace dom {
 
 template<typename BaseProtocol>
 class URLClassifierChildBase : public BaseProtocol
 {
 public:
   URLClassifierChildBase() = default;
 
   void SetCallback(nsIURIClassifierCallback* aCallback)
   {
     mCallback = aCallback;
   }
+  void SetCallbackEventTarget(nsIEventTarget* aCallbackEventTarget)
+  {
+    MOZ_ASSERT(aCallbackEventTarget);
+    mCallbackEventTarget = aCallbackEventTarget;
+  }
 
   mozilla::ipc::IPCResult Recv__delete__(const MaybeInfo& aInfo,
                                          const nsresult& aResult) override
   {
     MOZ_ASSERT(mCallback);
+
     if (aInfo.type() == MaybeInfo::TClassifierInfo) {
-      mCallback->OnClassifyComplete(aResult, aInfo.get_ClassifierInfo().list(),
-                                    aInfo.get_ClassifierInfo().provider(),
-                                    aInfo.get_ClassifierInfo().prefix());
+      auto doCallback = [=] {
+        mCallback->OnClassifyComplete(aResult, aInfo.get_ClassifierInfo().list(),
+                                      aInfo.get_ClassifierInfo().provider(),
+                                      aInfo.get_ClassifierInfo().prefix());
+      };
+
+      if (!mCallbackEventTarget) {
+        // For PURLClassifierChild.
+        doCallback();
+      } else {
+        // Callback on the callback thread.
+        nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(doCallback);
+        SyncRunnable::DispatchToThread(mCallbackEventTarget, r);
+      }
     }
     return IPC_OK();
   }
 
 private:
   ~URLClassifierChildBase() = default;
 
   nsCOMPtr<nsIURIClassifierCallback> mCallback;
+  nsCOMPtr<nsIEventTarget> mCallbackEventTarget;
 };
 
 using URLClassifierChild = URLClassifierChildBase<PURLClassifierChild>;
 using URLClassifierLocalChild = URLClassifierChildBase<PURLClassifierLocalChild>;
 
 } // namespace dom
 } // namespace mozilla
 
--- a/dom/ipc/URLClassifierParent.cpp
+++ b/dom/ipc/URLClassifierParent.cpp
@@ -1,14 +1,15 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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 "URIUtils.h"
 #include "URLClassifierParent.h"
 #include "nsComponentManagerUtils.h"
 #include "mozilla/Unused.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 /////////////////////////////////////////////////////////////////////
@@ -51,34 +52,63 @@ URLClassifierParent::ActorDestroy(ActorD
 }
 
 /////////////////////////////////////////////////////////////////////
 //URLClassifierLocalParent.
 
 NS_IMPL_ISUPPORTS(URLClassifierLocalParent, nsIURIClassifierCallback)
 
 mozilla::ipc::IPCResult
-URLClassifierLocalParent::StartClassify(nsIURI* aURI, const nsACString& aTables)
+URLClassifierLocalParent::StartClassify(const URIParams& aURI,
+                                        const nsACString& aTables)
+{
+  // In case we failed to do 'classify' for any reason, we call
+  // 'OnClassifyComplete' to asynchronously notify the result.
+
+  nsCString tables(aTables);
+  RefPtr<URLClassifierLocalParent> self = this;
+  nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction([=] () {
+    nsCOMPtr<nsIURI> uri = mozilla::ipc::DeserializeURI(aURI);
+    if (!uri) {
+      NS_WARNING("Null aURI for StartClassify");
+      self->OnClassifyComplete(NS_OK, EmptyCString(), EmptyCString(), EmptyCString());
+      return;
+    }
+    StartClassifyInternal(uri, tables);
+  });
+
+  nsCOMPtr<nsIEventTarget> systemGroupEventTarget
+    = mozilla::SystemGroup::EventTargetFor(mozilla::TaskCategory::Other);
+  nsresult rv = systemGroupEventTarget->Dispatch(r, nsIEventTarget::DISPATCH_NORMAL);
+  if (NS_FAILED(rv)) {
+    OnClassifyComplete(NS_OK, EmptyCString(), EmptyCString(), EmptyCString());
+  }
+
+  return IPC_OK();
+}
+
+void
+URLClassifierLocalParent::StartClassifyInternal(nsIURI* aURI,
+                                                const nsACString& aTables)
 {
   nsresult rv = NS_OK;
   // Note that in safe mode, the URL classifier service isn't available, so we
   // should handle the service not being present gracefully.
   nsCOMPtr<nsIURIClassifier> uriClassifier =
     do_GetService(NS_URICLASSIFIERSERVICE_CONTRACTID, &rv);
   if (NS_SUCCEEDED(rv)) {
     MOZ_ASSERT(aURI);
-    rv = uriClassifier->AsyncClassifyLocalWithTables(aURI, aTables, this);
+    rv = uriClassifier->AsyncClassifyLocalWithTables(aURI, aTables, this, nullptr);
   }
   if (NS_FAILED(rv)) {
     // Cannot do ClassificationFailed() because the child side
     // is expecting a callback. Only the second parameter will
     // be used, which is the "matched list". We treat "unable
     // to classify" as "not on any list".
     OnClassifyComplete(NS_OK, EmptyCString(), EmptyCString(), EmptyCString());
   }
-  return IPC_OK();
 }
 
 void
 URLClassifierLocalParent::ActorDestroy(ActorDestroyReason aWhy)
 {
   mIPCOpen = false;
 }
--- a/dom/ipc/URLClassifierParent.h
+++ b/dom/ipc/URLClassifierParent.h
@@ -4,52 +4,71 @@
  * 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/. */
 
 #ifndef mozilla_dom_URLClassifierParent_h
 #define mozilla_dom_URLClassifierParent_h
 
 #include "mozilla/dom/PURLClassifierParent.h"
 #include "mozilla/dom/PURLClassifierLocalParent.h"
+#include "mozilla/SyncRunnable.h"
 #include "nsIURIClassifier.h"
 
 namespace mozilla {
 namespace dom {
 
 template<typename BaseProtocol>
 class URLClassifierParentBase : public nsIURIClassifierCallback,
                                 public BaseProtocol
 {
 public:
+  URLClassifierParentBase()
+    : mIPCThread(NS_GetCurrentThread())
+  {
+    MOZ_ASSERT(mIPCThread);
+  }
+
   // nsIURIClassifierCallback.
   NS_IMETHOD OnClassifyComplete(nsresult aErrorCode,
                                 const nsACString& aList,
                                 const nsACString& aProvider,
                                 const nsACString& aPrefix)
   {
+    MOZ_ASSERT(NS_IsMainThread(), "URLClassifierParentBase::OnClassifyComplete "
+                                  "should not be on main thread.");
     if (mIPCOpen) {
       ClassifierInfo info = ClassifierInfo(nsCString(aList),
                                            nsCString(aProvider),
                                            nsCString(aPrefix));
-      Unused << BaseProtocol::Send__delete__(this, info, aErrorCode);
+      SendDelete(info, aErrorCode);
     }
     return NS_OK;
   }
 
   // Custom.
   void ClassificationFailed()
   {
     if (mIPCOpen) {
-      Unused << BaseProtocol::Send__delete__(this, void_t(), NS_ERROR_FAILURE);
+      SendDelete(void_t(), NS_ERROR_FAILURE);
     }
   }
 
+  void SendDelete(const MaybeInfo& aInfo, nsresult aResult)
+  {
+    RefPtr<URLClassifierParentBase<BaseProtocol>> self = this;
+    nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction([=] () {
+      Unused << BaseProtocol::Send__delete__(self.get(), aInfo, aResult);
+    });
+    SyncRunnable::DispatchToThread(mIPCThread, r);
+  }
+
 protected:
   ~URLClassifierParentBase() = default;
   bool mIPCOpen = true;
+  nsCOMPtr<nsIThread> mIPCThread;
 };
 
 //////////////////////////////////////////////////////////////
 // URLClassifierParent
 
 class URLClassifierParent : public URLClassifierParentBase<PURLClassifierParent>
 {
 public:
@@ -69,21 +88,23 @@ private:
 //////////////////////////////////////////////////////////////
 // URLClassifierLocalParent
 
 class URLClassifierLocalParent : public URLClassifierParentBase<PURLClassifierLocalParent>
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
 
-  mozilla::ipc::IPCResult StartClassify(nsIURI* aURI, const nsACString& aTables);
+  mozilla::ipc::IPCResult StartClassify(const mozilla::ipc::URIParams& aURI,
+                                        const nsACString& aTables);
 
 private:
   ~URLClassifierLocalParent() = default;
 
+  void StartClassifyInternal(nsIURI* aURI, const nsACString& aTables);
   // Override PURLClassifierParent::ActorDestroy.
   void ActorDestroy(ActorDestroyReason aWhy) override;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_URLClassifierParent_h
--- a/ipc/glue/BackgroundChildImpl.cpp
+++ b/ipc/glue/BackgroundChildImpl.cpp
@@ -30,16 +30,17 @@
 #include "mozilla/dom/GamepadTestChannelChild.h"
 #include "mozilla/dom/MessagePortChild.h"
 #include "mozilla/ipc/IPCStreamAlloc.h"
 #include "mozilla/ipc/PBackgroundTestChild.h"
 #include "mozilla/ipc/PChildToParentStreamChild.h"
 #include "mozilla/ipc/PParentToChildStreamChild.h"
 #include "mozilla/layout/VsyncChild.h"
 #include "mozilla/net/PUDPSocketChild.h"
+#include "mozilla/dom/URLClassifierChild.h"
 #include "mozilla/dom/network/UDPSocketChild.h"
 #include "nsID.h"
 #include "nsTraceRefcnt.h"
 
 namespace {
 
 class TestChild final : public mozilla::ipc::PBackgroundTestChild
 {
@@ -66,21 +67,23 @@ public:
 
 } // namespace
 
 namespace mozilla {
 namespace ipc {
 
 using mozilla::dom::UDPSocketChild;
 using mozilla::net::PUDPSocketChild;
+using mozilla::dom::URLClassifierLocalChild;
 
 using mozilla::dom::asmjscache::PAsmJSCacheEntryChild;
 using mozilla::dom::cache::PCacheChild;
 using mozilla::dom::cache::PCacheStorageChild;
 using mozilla::dom::cache::PCacheStreamControlChild;
+using mozilla::dom::PURLClassifierLocalChild;
 
 // -----------------------------------------------------------------------------
 // BackgroundChildImpl::ThreadLocal
 // -----------------------------------------------------------------------------
 
 BackgroundChildImpl::
 ThreadLocal::ThreadLocal()
   : mCurrentFileHandle(nullptr)
@@ -542,16 +545,31 @@ BackgroundChildImpl::AllocPGamepadTestCh
 bool
 BackgroundChildImpl::DeallocPGamepadTestChannelChild(PGamepadTestChannelChild* aActor)
 {
   MOZ_ASSERT(aActor);
   delete static_cast<dom::GamepadTestChannelChild*>(aActor);
   return true;
 }
 
+PURLClassifierLocalChild*
+BackgroundChildImpl::AllocPURLClassifierLocalChild(const URIParams& aUri,
+                                            const nsCString& aTables)
+{
+  return new URLClassifierLocalChild();
+}
+
+bool
+BackgroundChildImpl::DeallocPURLClassifierLocalChild(PURLClassifierLocalChild* aActor)
+{
+  MOZ_ASSERT(aActor);
+  delete aActor;
+  return true;
+}
+
 } // namespace ipc
 } // namespace mozilla
 
 mozilla::ipc::IPCResult
 TestChild::Recv__delete__(const nsCString& aTestArg)
 {
   MOZ_RELEASE_ASSERT(aTestArg == mTestArg,
                      "BackgroundTest message was corrupted!");
--- a/ipc/glue/BackgroundChildImpl.h
+++ b/ipc/glue/BackgroundChildImpl.h
@@ -192,16 +192,23 @@ protected:
   virtual bool
   DeallocPGamepadEventChannelChild(PGamepadEventChannelChild* aActor) override;
 
   virtual PGamepadTestChannelChild*
   AllocPGamepadTestChannelChild() override;
 
   virtual bool
   DeallocPGamepadTestChannelChild(PGamepadTestChannelChild* aActor) override;
+
+  // PURLClassifierLocalChild
+  virtual PURLClassifierLocalChild*
+  AllocPURLClassifierLocalChild(const URIParams& aUri,
+                                const nsCString& aTables) override;
+  virtual bool
+  DeallocPURLClassifierLocalChild(PURLClassifierLocalChild* aActor) override;
 };
 
 class BackgroundChildImpl::ThreadLocal final
 {
   friend class nsAutoPtr<ThreadLocal>;
 
 public:
   nsAutoPtr<mozilla::dom::indexedDB::ThreadLocal> mIndexedDBThreadLocal;
--- a/ipc/glue/BackgroundParentImpl.cpp
+++ b/ipc/glue/BackgroundParentImpl.cpp
@@ -7,16 +7,17 @@
 #include "BackgroundParentImpl.h"
 
 #include "BroadcastChannelParent.h"
 #include "FileDescriptorSetParent.h"
 #ifdef MOZ_WEBRTC
 #include "CamerasParent.h"
 #endif
 #include "mozilla/media/MediaParent.h"
+#include "mozilla/AbstractThread.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/DOMTypes.h"
 #include "mozilla/dom/FileSystemBase.h"
 #include "mozilla/dom/FileSystemRequestParent.h"
 #include "mozilla/dom/GamepadEventChannelParent.h"
 #include "mozilla/dom/GamepadTestChannelParent.h"
 #include "mozilla/dom/PBlobParent.h"
@@ -25,16 +26,17 @@
 #include "mozilla/dom/MessagePortParent.h"
 #include "mozilla/dom/ServiceWorkerRegistrar.h"
 #include "mozilla/dom/asmjscache/AsmJSCache.h"
 #include "mozilla/dom/cache/ActorUtils.h"
 #include "mozilla/dom/indexedDB/ActorsParent.h"
 #include "mozilla/dom/ipc/BlobParent.h"
 #include "mozilla/dom/ipc/IPCBlobInputStreamParent.h"
 #include "mozilla/dom/ipc/MemoryStreamParent.h"
+#include "mozilla/dom/URLClassifierParent.h"
 #include "mozilla/dom/quota/ActorsParent.h"
 #include "mozilla/ipc/BackgroundParent.h"
 #include "mozilla/ipc/BackgroundUtils.h"
 #include "mozilla/ipc/IPCStreamAlloc.h"
 #include "mozilla/ipc/PBackgroundSharedTypes.h"
 #include "mozilla/ipc/PBackgroundTestParent.h"
 #include "mozilla/ipc/PChildToParentStreamParent.h"
 #include "mozilla/ipc/PParentToChildStreamParent.h"
@@ -44,33 +46,36 @@
 #include "nsNetUtil.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsProxyRelease.h"
 #include "mozilla/RefPtr.h"
 #include "nsThreadUtils.h"
 #include "nsTraceRefcnt.h"
 #include "nsXULAppAPI.h"
 #include "ServiceWorkerManagerParent.h"
+#include "URIUtils.h"
 
 #ifdef DISABLE_ASSERTS_FOR_FUZZING
 #define ASSERT_UNLESS_FUZZING(...) do { } while (0)
 #else
 #define ASSERT_UNLESS_FUZZING(...) MOZ_ASSERT(false)
 #endif
 
 using mozilla::ipc::AssertIsOnBackgroundThread;
 using mozilla::dom::asmjscache::PAsmJSCacheEntryParent;
 using mozilla::dom::cache::PCacheParent;
 using mozilla::dom::cache::PCacheStorageParent;
 using mozilla::dom::cache::PCacheStreamControlParent;
 using mozilla::dom::FileSystemBase;
 using mozilla::dom::FileSystemRequestParent;
 using mozilla::dom::MessagePortParent;
 using mozilla::dom::PMessagePortParent;
+using mozilla::dom::PURLClassifierLocalParent;
 using mozilla::dom::UDPSocketParent;
+using mozilla::dom::URLClassifierLocalParent;
 
 namespace {
 
 void
 AssertIsOnMainThread()
 {
   MOZ_ASSERT(NS_IsMainThread());
 }
@@ -883,16 +888,56 @@ bool
 BackgroundParentImpl::DeallocPGamepadTestChannelParent(dom::PGamepadTestChannelParent *aActor)
 {
   MOZ_ASSERT(aActor);
   RefPtr<dom::GamepadTestChannelParent> parent =
     dont_AddRef(static_cast<dom::GamepadTestChannelParent*>(aActor));
   return true;
 }
 
+//////////////////////////////////////////////////////////////////
+// PURLClassifierLocalParent
+
+PURLClassifierLocalParent*
+BackgroundParentImpl::AllocPURLClassifierLocalParent(const URIParams& aURI,
+                                                     const nsCString& aTables)
+{
+  AssertIsInMainProcess();
+  AssertIsOnBackgroundThread();
+  RefPtr<URLClassifierLocalParent> actor = new URLClassifierLocalParent();
+  return actor.forget().take();
+}
+
+mozilla::ipc::IPCResult
+BackgroundParentImpl::RecvPURLClassifierLocalConstructor(PURLClassifierLocalParent* aActor,
+                                                         const URIParams& aURI,
+                                                         const nsCString& aTables)
+{
+  AssertIsInMainProcess();
+  AssertIsOnBackgroundThread();
+  MOZ_ASSERT(aActor);
+
+  auto* actor = static_cast<URLClassifierLocalParent*>(aActor);
+  actor->StartClassify(aURI, aTables);
+
+  return IPC_OK();
+}
+
+bool
+BackgroundParentImpl::DeallocPURLClassifierLocalParent(PURLClassifierLocalParent* aActor)
+{
+  AssertIsInMainProcess();
+  AssertIsOnBackgroundThread();
+  MOZ_ASSERT(aActor);
+
+  RefPtr<URLClassifierLocalParent> actor =
+    dont_AddRef(static_cast<URLClassifierLocalParent*>(aActor));
+  return true;
+}
+
 } // namespace ipc
 } // namespace mozilla
 
 void
 TestParent::ActorDestroy(ActorDestroyReason aWhy)
 {
   mozilla::ipc::AssertIsInMainProcess();
   AssertIsOnBackgroundThread();
--- a/ipc/glue/BackgroundParentImpl.h
+++ b/ipc/glue/BackgroundParentImpl.h
@@ -220,14 +220,26 @@ protected:
   virtual bool
   DeallocPGamepadEventChannelParent(PGamepadEventChannelParent *aActor) override;
 
   virtual PGamepadTestChannelParent*
   AllocPGamepadTestChannelParent() override;
 
   virtual bool
   DeallocPGamepadTestChannelParent(PGamepadTestChannelParent* aActor) override;
+
+  // PURLClassifierLocalParent.
+  virtual PURLClassifierLocalParent*
+  AllocPURLClassifierLocalParent(const URIParams& aURI,
+                                 const nsCString& aTables) override;
+  virtual mozilla::ipc::IPCResult
+  RecvPURLClassifierLocalConstructor(PURLClassifierLocalParent* aActor,
+                                     const URIParams& aURI,
+                                     const nsCString& aTables) override;
+
+  virtual bool
+  DeallocPURLClassifierLocalParent(PURLClassifierLocalParent* aActor) override;
 };
 
 } // namespace ipc
 } // namespace mozilla
 
 #endif // mozilla_ipc_backgroundparentimpl_h__