Bug 1572460 - Refactor `selection` out of the `InspectorFront`. r=yulia
[gecko.git] / dom / storage / SessionStorage.h
blob100a1ca5971fde63f4d30fee60347e628a03f8fc
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 {
15 namespace dom {
17 class SessionStorageCache;
18 class SessionStorageManager;
20 class SessionStorage final : public Storage {
21 public:
22 NS_DECL_ISUPPORTS_INHERITED
23 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SessionStorage, Storage)
25 SessionStorage(nsPIDOMWindowInner* aWindow, nsIPrincipal* aPrincipal,
26 SessionStorageCache* aCache, SessionStorageManager* aManager,
27 const nsAString& aDocumentURI, bool aIsPrivate);
29 StorageType Type() const override { return eSessionStorage; }
31 SessionStorageManager* Manager() const { return mManager; }
33 SessionStorageCache* Cache() const { return mCache; }
35 int64_t GetOriginQuotaUsage() const override;
37 bool IsForkOf(const Storage* aStorage) const override;
39 // WebIDL
40 uint32_t GetLength(nsIPrincipal& aSubjectPrincipal,
41 ErrorResult& aRv) override;
43 void Key(uint32_t aIndex, nsAString& aResult, nsIPrincipal& aSubjectPrincipal,
44 ErrorResult& aRv) override;
46 void GetItem(const nsAString& aKey, nsAString& aResult,
47 nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv) override;
49 void GetSupportedNames(nsTArray<nsString>& aKeys) override;
51 void SetItem(const nsAString& aKey, const nsAString& aValue,
52 nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv) override;
54 void RemoveItem(const nsAString& aKey, nsIPrincipal& aSubjectPrincipal,
55 ErrorResult& aRv) override;
57 void Clear(nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv) override;
59 private:
60 ~SessionStorage();
62 void BroadcastChangeNotification(const nsAString& aKey,
63 const nsAString& aOldValue,
64 const nsAString& aNewValue);
66 RefPtr<SessionStorageCache> mCache;
67 RefPtr<SessionStorageManager> mManager;
69 nsString mDocumentURI;
70 bool mIsPrivate;
73 } // namespace dom
74 } // namespace mozilla
76 #endif // mozilla_dom_SessionStorage_h