no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / dom / push / PushSubscription.h
blobea2bed5ad7e02c78adca820513eac09585b66d0d
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_PushSubscription_h
8 #define mozilla_dom_PushSubscription_h
10 #include "js/RootingAPI.h"
11 #include "nsCOMPtr.h"
12 #include "nsWrapperCache.h"
14 #include "mozilla/AlreadyAddRefed.h"
15 #include "mozilla/RefPtr.h"
17 #include "mozilla/dom/BindingDeclarations.h"
18 #include "mozilla/dom/PushSubscriptionBinding.h"
19 #include "mozilla/dom/PushSubscriptionOptionsBinding.h"
20 #include "mozilla/dom/TypedArray.h"
21 #include "domstubs.h"
23 class nsIGlobalObject;
25 namespace mozilla {
26 class ErrorResult;
28 namespace dom {
30 class Promise;
32 class PushSubscription final : public nsISupports, public nsWrapperCache {
33 public:
34 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
35 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(PushSubscription)
37 PushSubscription(nsIGlobalObject* aGlobal, const nsAString& aEndpoint,
38 const nsAString& aScope,
39 Nullable<EpochTimeStamp>&& aExpirationTime,
40 nsTArray<uint8_t>&& aP256dhKey,
41 nsTArray<uint8_t>&& aAuthSecret,
42 nsTArray<uint8_t>&& aAppServerKey);
44 JSObject* WrapObject(JSContext* aCx,
45 JS::Handle<JSObject*> aGivenProto) override;
47 nsIGlobalObject* GetParentObject() const { return mGlobal; }
49 void GetEndpoint(nsAString& aEndpoint) const { aEndpoint = mEndpoint; }
51 void GetKey(JSContext* cx, PushEncryptionKeyName aType,
52 JS::MutableHandle<JSObject*> aKey, ErrorResult& aRv);
54 Nullable<EpochTimeStamp> GetExpirationTime() { return mExpirationTime; };
56 static already_AddRefed<PushSubscription> Constructor(
57 GlobalObject& aGlobal, const PushSubscriptionInit& aInitDict,
58 ErrorResult& aRv);
60 already_AddRefed<Promise> Unsubscribe(ErrorResult& aRv);
62 void ToJSON(PushSubscriptionJSON& aJSON, ErrorResult& aRv);
64 already_AddRefed<PushSubscriptionOptions> Options();
66 private:
67 ~PushSubscription();
69 already_AddRefed<Promise> UnsubscribeFromWorker(ErrorResult& aRv);
71 nsString mEndpoint;
72 nsString mScope;
73 Nullable<EpochTimeStamp> mExpirationTime;
74 nsTArray<uint8_t> mRawP256dhKey;
75 nsTArray<uint8_t> mAuthSecret;
76 nsCOMPtr<nsIGlobalObject> mGlobal;
77 RefPtr<PushSubscriptionOptions> mOptions;
80 } // namespace dom
81 } // namespace mozilla
83 #endif // mozilla_dom_PushSubscription_h