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_SessionStorageManager_h
8
#define mozilla_dom_SessionStorageManager_h
9
10
#include "nsIDOMStorageManager.h"
11
#include "nsClassHashtable.h"
12
#include "nsRefPtrHashtable.h"
13
#include "StorageObserver.h"
14
15
namespace mozilla {
16
namespace dom {
17
18
class SessionStorageCache;
19
class SessionStorageObserver;
20
21
class SessionStorageManager final : public nsIDOMSessionStorageManager,
22
public StorageObserverSink {
23
public:
24
SessionStorageManager();
25
26
NS_DECL_ISUPPORTS
27
NS_DECL_NSIDOMSTORAGEMANAGER
28
NS_DECL_NSIDOMSESSIONSTORAGEMANAGER
29
30
private:
31
~SessionStorageManager();
32
33
// StorageObserverSink, handler to various chrome clearing notification
34
nsresult Observe(const char* aTopic,
35
const nsAString& aOriginAttributesPattern,
36
const nsACString& aOriginScope) override;
37
38
enum ClearStorageType {
39
eAll,
40
eSessionOnly,
41
};
42
43
void ClearStorages(ClearStorageType aType,
44
const OriginAttributesPattern& aPattern,
45
const nsACString& aOriginScope);
46
47
nsresult GetSessionStorageCacheHelper(nsIPrincipal* aPrincipal,
48
nsIPrincipal* aStoragePrincipal,
49
bool aMakeIfNeeded,
50
SessionStorageCache* aCloneFrom,
51
RefPtr<SessionStorageCache>* aRetVal);
52
53
typedef nsRefPtrHashtable<nsCStringHashKey, SessionStorageCache>
54
OriginKeyHashTable;
55
nsClassHashtable<nsCStringHashKey, OriginKeyHashTable> mOATable;
56
57
RefPtr<SessionStorageObserver> mObserver;
58
};
59
60
} // namespace dom
61
} // namespace mozilla
62
63
#endif // mozilla_dom_SessionStorageManager_h