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_SessionStorage_h
8 : #define mozilla_dom_SessionStorage_h
9 :
10 : #include "Storage.h"
11 :
12 : class nsIPrincipal;
13 :
14 : namespace mozilla {
15 : namespace dom {
16 :
17 : class SessionStorageCache;
18 : class SessionStorageManager;
19 :
20 : class SessionStorage final : public Storage
21 : {
22 : public:
23 : NS_DECL_ISUPPORTS_INHERITED
24 0 : NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SessionStorage, Storage)
25 :
26 : SessionStorage(nsPIDOMWindowInner* aWindow,
27 : nsIPrincipal* aPrincipal,
28 : SessionStorageCache* aCache,
29 : SessionStorageManager* aManager,
30 : const nsAString& aDocumentURI,
31 : bool aIsPrivate);
32 :
33 0 : StorageType Type() const override { return eSessionStorage; }
34 :
35 : SessionStorageManager* Manager() const { return mManager; }
36 :
37 0 : SessionStorageCache* Cache() const { return mCache; }
38 :
39 : already_AddRefed<SessionStorage>
40 : Clone() const;
41 :
42 : int64_t GetOriginQuotaUsage() const override;
43 :
44 : bool IsForkOf(const Storage* aStorage) const override;
45 :
46 : // WebIDL
47 : uint32_t GetLength(nsIPrincipal& aSubjectPrincipal,
48 : ErrorResult& aRv) override;
49 :
50 : void Key(uint32_t aIndex, nsAString& aResult,
51 : nsIPrincipal& aSubjectPrincipal,
52 : ErrorResult& aRv) override;
53 :
54 : void GetItem(const nsAString& aKey, nsAString& aResult,
55 : nsIPrincipal& aSubjectPrincipal,
56 : ErrorResult& aRv) override;
57 :
58 : void GetSupportedNames(nsTArray<nsString>& aKeys) override;
59 :
60 : void SetItem(const nsAString& aKey, const nsAString& aValue,
61 : nsIPrincipal& aSubjectPrincipal,
62 : ErrorResult& aRv) override;
63 :
64 : void RemoveItem(const nsAString& aKey,
65 : nsIPrincipal& aSubjectPrincipal,
66 : ErrorResult& aRv) override;
67 :
68 : void Clear(nsIPrincipal& aSubjectPrincipal,
69 : ErrorResult& aRv) override;
70 :
71 : private:
72 : ~SessionStorage();
73 :
74 : bool ProcessUsageDelta(int64_t aDelta);
75 :
76 : void
77 : BroadcastChangeNotification(const nsAString& aKey,
78 : const nsAString& aOldValue,
79 : const nsAString& aNewValue);
80 :
81 : RefPtr<SessionStorageCache> mCache;
82 : RefPtr<SessionStorageManager> mManager;
83 :
84 : nsString mDocumentURI;
85 : bool mIsPrivate;
86 : };
87 :
88 : } // dom namespace
89 : } // mozilla namespace
90 :
91 : #endif //mozilla_dom_SessionStorage_h
|