/work/obj-fuzz/dist/include/mozilla/dom/PushSubscription.h
Line | Count | Source (jump to first uncovered line) |
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_PushSubscription_h |
8 | | #define mozilla_dom_PushSubscription_h |
9 | | |
10 | | #include "jsapi.h" |
11 | | #include "nsCOMPtr.h" |
12 | | #include "nsWrapperCache.h" |
13 | | |
14 | | #include "mozilla/AlreadyAddRefed.h" |
15 | | #include "mozilla/ErrorResult.h" |
16 | | #include "mozilla/RefPtr.h" |
17 | | |
18 | | #include "mozilla/dom/BindingDeclarations.h" |
19 | | #include "mozilla/dom/DOMPrefs.h" |
20 | | #include "mozilla/dom/PushSubscriptionBinding.h" |
21 | | #include "mozilla/dom/PushSubscriptionOptionsBinding.h" |
22 | | #include "mozilla/dom/TypedArray.h" |
23 | | |
24 | | class nsIGlobalObject; |
25 | | |
26 | | namespace mozilla { |
27 | | namespace dom { |
28 | | |
29 | | class Promise; |
30 | | |
31 | | class PushSubscription final : public nsISupports |
32 | | , public nsWrapperCache |
33 | | { |
34 | | public: |
35 | | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
36 | | NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PushSubscription) |
37 | | |
38 | | PushSubscription(nsIGlobalObject* aGlobal, |
39 | | const nsAString& aEndpoint, |
40 | | const nsAString& aScope, |
41 | | nsTArray<uint8_t>&& aP256dhKey, |
42 | | nsTArray<uint8_t>&& aAuthSecret, |
43 | | nsTArray<uint8_t>&& aAppServerKey); |
44 | | |
45 | | JSObject* |
46 | | WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; |
47 | | |
48 | | nsIGlobalObject* |
49 | | GetParentObject() const |
50 | 0 | { |
51 | 0 | return mGlobal; |
52 | 0 | } |
53 | | |
54 | | void |
55 | | GetEndpoint(nsAString& aEndpoint) const |
56 | 0 | { |
57 | 0 | aEndpoint = mEndpoint; |
58 | 0 | } |
59 | | |
60 | | void |
61 | | GetKey(JSContext* cx, |
62 | | PushEncryptionKeyName aType, |
63 | | JS::MutableHandle<JSObject*> aKey, |
64 | | ErrorResult& aRv); |
65 | | |
66 | | static already_AddRefed<PushSubscription> |
67 | | Constructor(GlobalObject& aGlobal, |
68 | | const PushSubscriptionInit& aInitDict, |
69 | | ErrorResult& aRv); |
70 | | |
71 | | already_AddRefed<Promise> |
72 | | Unsubscribe(ErrorResult& aRv); |
73 | | |
74 | | void |
75 | | ToJSON(PushSubscriptionJSON& aJSON, ErrorResult& aRv); |
76 | | |
77 | | already_AddRefed<PushSubscriptionOptions> |
78 | | Options(); |
79 | | |
80 | | private: |
81 | | ~PushSubscription(); |
82 | | |
83 | | already_AddRefed<Promise> |
84 | | UnsubscribeFromWorker(ErrorResult& aRv); |
85 | | |
86 | | nsString mEndpoint; |
87 | | nsString mScope; |
88 | | nsTArray<uint8_t> mRawP256dhKey; |
89 | | nsTArray<uint8_t> mAuthSecret; |
90 | | nsCOMPtr<nsIGlobalObject> mGlobal; |
91 | | RefPtr<PushSubscriptionOptions> mOptions; |
92 | | }; |
93 | | |
94 | | } // namespace dom |
95 | | } // namespace mozilla |
96 | | |
97 | | #endif // mozilla_dom_PushSubscription_h |