1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_URLClassifierParent_h
8 #define mozilla_dom_URLClassifierParent_h
10 #include "mozilla/dom/PContent.h"
11 #include "mozilla/dom/PURLClassifierParent.h"
12 #include "mozilla/dom/PURLClassifierLocalParent.h"
13 #include "nsIURIClassifier.h"
14 #include "nsIUrlClassifierFeature.h"
16 namespace mozilla::dom
{
18 class IPCURLClassifierFeature
;
20 //////////////////////////////////////////////////////////////
21 // URLClassifierParent
23 class URLClassifierParent
: public nsIURIClassifierCallback
,
24 public PURLClassifierParent
{
26 NS_DECL_THREADSAFE_ISUPPORTS
28 mozilla::ipc::IPCResult
StartClassify(nsIPrincipal
* aPrincipal
,
31 // nsIURIClassifierCallback.
32 NS_IMETHOD
OnClassifyComplete(nsresult aErrorCode
, const nsACString
& aList
,
33 const nsACString
& aProvider
,
34 const nsACString
& aFullHash
) override
{
36 ClassifierInfo info
= ClassifierInfo(
37 nsCString(aList
), nsCString(aProvider
), nsCString(aFullHash
));
38 Unused
<< Send__delete__(this, Some(info
), aErrorCode
);
44 void ClassificationFailed() {
46 Unused
<< Send__delete__(this, Nothing(), NS_ERROR_FAILURE
);
51 ~URLClassifierParent() = default;
53 // Override PURLClassifierParent::ActorDestroy. We seem to unable to
54 // override from the base template class.
55 void ActorDestroy(ActorDestroyReason aWhy
) override
{ mIPCOpen
= false; }
60 //////////////////////////////////////////////////////////////
61 // URLClassifierLocalParent
63 class URLClassifierLocalParent
: public nsIUrlClassifierFeatureCallback
,
64 public PURLClassifierLocalParent
{
66 NS_DECL_THREADSAFE_ISUPPORTS
68 mozilla::ipc::IPCResult
StartClassify(
69 nsIURI
* aURI
, const nsTArray
<IPCURLClassifierFeature
>& aFeatureNames
);
71 // nsIUrlClassifierFeatureCallback.
74 const nsTArray
<RefPtr
<nsIUrlClassifierFeatureResult
>>& aResults
) override
;
77 ~URLClassifierLocalParent() = default;
79 // Override PURLClassifierLocalParent::ActorDestroy.
80 void ActorDestroy(ActorDestroyReason aWhy
) override
{ mIPCOpen
= false; }
85 } // namespace mozilla::dom
87 #endif // mozilla_dom_URLClassifierParent_h