Bug 1776680 [wpt PR 34603] - [@container] Test invalidation of font-relative units...
[gecko.git] / dom / storage / SessionStorage.h
blobde2028227648c39fdd235ad7a0f1c318cf97fc80
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_SessionStorage_h
8 #define mozilla_dom_SessionStorage_h
10 #include "Storage.h"
12 class nsIPrincipal;
14 namespace mozilla::dom {
16 class SessionStorageCache;
17 class SessionStorageManager;
19 class SessionStorage final : public Storage {
20 public:
21 NS_DECL_ISUPPORTS_INHERITED
22 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SessionStorage, Storage)
24 SessionStorage(nsPIDOMWindowInner* aWindow, nsIPrincipal* aPrincipal,
25 nsIPrincipal* aStoragePrincipal, SessionStorageCache* aCache,
26 SessionStorageManager* aManager, const nsAString& aDocumentURI,
27 bool aIsPrivate);
29 void AssertIsOnOwningThread() const {
30 NS_ASSERT_OWNINGTHREAD(SessionStorage);
33 StorageType Type() const override { return eSessionStorage; }
35 SessionStorageManager* Manager() const { return mManager; }
37 SessionStorageCache* Cache() const { return mCache; }
39 int64_t GetOriginQuotaUsage() const override;
41 bool IsForkOf(const Storage* aStorage) const override;
43 // WebIDL
44 uint32_t GetLength(nsIPrincipal& aSubjectPrincipal,
45 ErrorResult& aRv) override;
47 void Key(uint32_t aIndex, nsAString& aResult, nsIPrincipal& aSubjectPrincipal,
48 ErrorResult& aRv) override;
50 void GetItem(const nsAString& aKey, nsAString& aResult,
51 nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv) override;
53 void GetSupportedNames(nsTArray<nsString>& aKeys) override;
55 void SetItem(const nsAString& aKey, const nsAString& aValue,
56 nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv) override;
58 void RemoveItem(const nsAString& aKey, nsIPrincipal& aSubjectPrincipal,
59 ErrorResult& aRv) override;
61 void Clear(nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv) override;
63 private:
64 ~SessionStorage();
66 void BroadcastChangeNotification(const nsAString& aKey,
67 const nsAString& aOldValue,
68 const nsAString& aNewValue);
70 void MaybeScheduleStableStateCallback();
72 void StableStateCallback();
74 nsresult EnsureCacheLoadedOrCloned() const;
76 RefPtr<SessionStorageCache> mCache;
77 RefPtr<SessionStorageManager> mManager;
79 nsString mDocumentURI;
80 bool mIsPrivate;
81 bool mHasPendingStableStateCallback;
84 } // namespace mozilla::dom
86 #endif // mozilla_dom_SessionStorage_h