Line data Source code
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/. */
6 :
7 : #ifndef mozilla_dom_URLClassifierParent_h
8 : #define mozilla_dom_URLClassifierParent_h
9 :
10 : #include "mozilla/dom/PURLClassifierParent.h"
11 : #include "mozilla/dom/PURLClassifierLocalParent.h"
12 : #include "nsIURIClassifier.h"
13 :
14 : namespace mozilla {
15 : namespace dom {
16 :
17 : template<typename BaseProtocol>
18 0 : class URLClassifierParentBase : public nsIURIClassifierCallback,
19 : public BaseProtocol
20 : {
21 : public:
22 : // nsIURIClassifierCallback.
23 0 : NS_IMETHOD OnClassifyComplete(nsresult aErrorCode,
24 : const nsACString& aList,
25 : const nsACString& aProvider,
26 : const nsACString& aPrefix)
27 : {
28 0 : if (mIPCOpen) {
29 : ClassifierInfo info = ClassifierInfo(nsCString(aList),
30 : nsCString(aProvider),
31 0 : nsCString(aPrefix));
32 0 : Unused << BaseProtocol::Send__delete__(this, info, aErrorCode);
33 : }
34 0 : return NS_OK;
35 : }
36 :
37 : // Custom.
38 0 : void ClassificationFailed()
39 : {
40 0 : if (mIPCOpen) {
41 0 : Unused << BaseProtocol::Send__delete__(this, void_t(), NS_ERROR_FAILURE);
42 : }
43 0 : }
44 :
45 : protected:
46 0 : ~URLClassifierParentBase() = default;
47 : bool mIPCOpen = true;
48 : };
49 :
50 : //////////////////////////////////////////////////////////////
51 : // URLClassifierParent
52 :
53 0 : class URLClassifierParent : public URLClassifierParentBase<PURLClassifierParent>
54 : {
55 : public:
56 : NS_DECL_THREADSAFE_ISUPPORTS
57 :
58 : mozilla::ipc::IPCResult StartClassify(nsIPrincipal* aPrincipal,
59 : bool aUseTrackingProtection,
60 : bool* aSuccess);
61 : private:
62 0 : ~URLClassifierParent() = default;
63 :
64 : // Override PURLClassifierParent::ActorDestroy. We seem to unable to
65 : // override from the base template class.
66 : void ActorDestroy(ActorDestroyReason aWhy) override;
67 : };
68 :
69 : //////////////////////////////////////////////////////////////
70 : // URLClassifierLocalParent
71 :
72 0 : class URLClassifierLocalParent : public URLClassifierParentBase<PURLClassifierLocalParent>
73 : {
74 : public:
75 : NS_DECL_THREADSAFE_ISUPPORTS
76 :
77 : mozilla::ipc::IPCResult StartClassify(nsIURI* aURI, const nsACString& aTables);
78 :
79 : private:
80 0 : ~URLClassifierLocalParent() = default;
81 :
82 : // Override PURLClassifierParent::ActorDestroy.
83 : void ActorDestroy(ActorDestroyReason aWhy) override;
84 : };
85 :
86 : } // namespace dom
87 : } // namespace mozilla
88 :
89 : #endif // mozilla_dom_URLClassifierParent_h
|