Backed out changeset 1d9301697aa0 (bug 1887752) for causing failures on browser_all_f...
[gecko.git] / dom / ipc / URLClassifierParent.h
blob1eb6b2fcce8a4d374eed353acdf514021db407a1
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 {
25 public:
26 NS_DECL_THREADSAFE_ISUPPORTS
28 mozilla::ipc::IPCResult StartClassify(nsIPrincipal* aPrincipal,
29 bool* aSuccess);
31 // nsIURIClassifierCallback.
32 NS_IMETHOD OnClassifyComplete(nsresult aErrorCode, const nsACString& aList,
33 const nsACString& aProvider,
34 const nsACString& aFullHash) override {
35 if (mIPCOpen) {
36 ClassifierInfo info = ClassifierInfo(
37 nsCString(aList), nsCString(aProvider), nsCString(aFullHash));
38 Unused << Send__delete__(this, Some(info), aErrorCode);
40 return NS_OK;
43 // Custom.
44 void ClassificationFailed() {
45 if (mIPCOpen) {
46 Unused << Send__delete__(this, Nothing(), NS_ERROR_FAILURE);
50 private:
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; }
57 bool mIPCOpen = true;
60 //////////////////////////////////////////////////////////////
61 // URLClassifierLocalParent
63 class URLClassifierLocalParent : public nsIUrlClassifierFeatureCallback,
64 public PURLClassifierLocalParent {
65 public:
66 NS_DECL_THREADSAFE_ISUPPORTS
68 mozilla::ipc::IPCResult StartClassify(
69 nsIURI* aURI, const nsTArray<IPCURLClassifierFeature>& aFeatureNames);
71 // nsIUrlClassifierFeatureCallback.
72 NS_IMETHOD
73 OnClassifyComplete(
74 const nsTArray<RefPtr<nsIUrlClassifierFeatureResult>>& aResults) override;
76 private:
77 ~URLClassifierLocalParent() = default;
79 // Override PURLClassifierLocalParent::ActorDestroy.
80 void ActorDestroy(ActorDestroyReason aWhy) override { mIPCOpen = false; }
82 bool mIPCOpen = true;
85 } // namespace mozilla::dom
87 #endif // mozilla_dom_URLClassifierParent_h