Source code

Revision control

Other Tools

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
public:
22
NS_DECL_ISUPPORTS_INHERITED
23
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SessionStorage, Storage)
24
25
SessionStorage(nsPIDOMWindowInner* aWindow, nsIPrincipal* aPrincipal,
26
SessionStorageCache* aCache, SessionStorageManager* aManager,
27
const nsAString& aDocumentURI, bool aIsPrivate);
28
29
StorageType Type() const override { return eSessionStorage; }
30
31
SessionStorageManager* Manager() const { return mManager; }
32
33
SessionStorageCache* Cache() const { return mCache; }
34
35
int64_t GetOriginQuotaUsage() const override;
36
37
bool IsForkOf(const Storage* aStorage) const override;
38
39
// WebIDL
40
uint32_t GetLength(nsIPrincipal& aSubjectPrincipal,
41
ErrorResult& aRv) override;
42
43
void Key(uint32_t aIndex, nsAString& aResult, nsIPrincipal& aSubjectPrincipal,
44
ErrorResult& aRv) override;
45
46
void GetItem(const nsAString& aKey, nsAString& aResult,
47
nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv) override;
48
49
void GetSupportedNames(nsTArray<nsString>& aKeys) override;
50
51
void SetItem(const nsAString& aKey, const nsAString& aValue,
52
nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv) override;
53
54
void RemoveItem(const nsAString& aKey, nsIPrincipal& aSubjectPrincipal,
55
ErrorResult& aRv) override;
56
57
void Clear(nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv) override;
58
59
private:
60
~SessionStorage();
61
62
void BroadcastChangeNotification(const nsAString& aKey,
63
const nsAString& aOldValue,
64
const nsAString& aNewValue);
65
66
RefPtr<SessionStorageCache> mCache;
67
RefPtr<SessionStorageManager> mManager;
68
69
nsString mDocumentURI;
70
bool mIsPrivate;
71
};
72
73
} // namespace dom
74
} // namespace mozilla
75
76
#endif // mozilla_dom_SessionStorage_h