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_URLClassifierChild_h
8 : #define mozilla_dom_URLClassifierChild_h
9 :
10 : #include "mozilla/dom/PURLClassifierChild.h"
11 : #include "mozilla/dom/PURLClassifierLocalChild.h"
12 : #include "nsIURIClassifier.h"
13 :
14 : namespace mozilla {
15 : namespace dom {
16 :
17 : template<typename BaseProtocol>
18 : class URLClassifierChildBase : public BaseProtocol
19 : {
20 : public:
21 0 : URLClassifierChildBase() = default;
22 :
23 0 : void SetCallback(nsIURIClassifierCallback* aCallback)
24 : {
25 0 : mCallback = aCallback;
26 0 : }
27 :
28 0 : mozilla::ipc::IPCResult Recv__delete__(const MaybeInfo& aInfo,
29 : const nsresult& aResult) override
30 : {
31 0 : MOZ_ASSERT(mCallback);
32 0 : if (aInfo.type() == MaybeInfo::TClassifierInfo) {
33 0 : mCallback->OnClassifyComplete(aResult, aInfo.get_ClassifierInfo().list(),
34 0 : aInfo.get_ClassifierInfo().provider(),
35 0 : aInfo.get_ClassifierInfo().prefix());
36 : }
37 0 : return IPC_OK();
38 : }
39 :
40 : private:
41 0 : ~URLClassifierChildBase() = default;
42 :
43 : nsCOMPtr<nsIURIClassifierCallback> mCallback;
44 : };
45 :
46 : using URLClassifierChild = URLClassifierChildBase<PURLClassifierChild>;
47 : using URLClassifierLocalChild = URLClassifierChildBase<PURLClassifierLocalChild>;
48 :
49 : } // namespace dom
50 : } // namespace mozilla
51 :
52 : #endif // mozilla_dom_URLClassifierChild_h
|