Bug 1843230 - Remove IsWin8OrLater checks from dom/geolocation/ r=emk
[gecko.git] / dom / storage / LocalStorage.h
blob4df24c5e63a073a8a079c47900110cf560bdea93
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_LocalStorage_h
8 #define mozilla_dom_LocalStorage_h
10 #include "Storage.h"
11 #include "nsWeakReference.h"
13 namespace mozilla::dom {
15 class LocalStorageCache;
16 class LocalStorageManager;
17 class StorageEvent;
19 class LocalStorage final : public Storage, public nsSupportsWeakReference {
20 public:
21 NS_DECL_ISUPPORTS_INHERITED
22 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(LocalStorage, Storage)
24 StorageType Type() const override { return eLocalStorage; }
26 LocalStorageManager* GetManager() const { return mManager; }
28 LocalStorageCache const* GetCache() const { return mCache; }
30 const nsString& DocumentURI() const { return mDocumentURI; }
32 LocalStorage(nsPIDOMWindowInner* aWindow, LocalStorageManager* aManager,
33 LocalStorageCache* aCache, const nsAString& aDocumentURI,
34 nsIPrincipal* aPrincipal, nsIPrincipal* aStoragePrincipal,
35 bool aIsPrivate);
37 bool IsForkOf(const Storage* aOther) const override;
39 // WebIDL
41 int64_t GetOriginQuotaUsage() const override;
43 uint32_t GetLength(nsIPrincipal& aSubjectPrincipal,
44 ErrorResult& aRv) override;
46 void Key(uint32_t aIndex, nsAString& aResult, nsIPrincipal& aSubjectPrincipal,
47 ErrorResult& aRv) override;
49 void GetItem(const nsAString& aKey, nsAString& aResult,
50 nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv) override;
52 void GetSupportedNames(nsTArray<nsString>& aKeys) override;
54 void SetItem(const nsAString& aKey, const nsAString& aValue,
55 nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv) override;
57 void RemoveItem(const nsAString& aKey, nsIPrincipal& aSubjectPrincipal,
58 ErrorResult& aRv) override;
60 void Clear(nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv) override;
62 void ApplyEvent(StorageEvent* aStorageEvent);
64 private:
65 ~LocalStorage();
67 friend class LocalStorageManager;
68 friend class LocalStorageCache;
70 RefPtr<LocalStorageManager> mManager;
71 RefPtr<LocalStorageCache> mCache;
72 nsString mDocumentURI;
74 // Whether this storage is running in private-browsing window.
75 bool mIsPrivate : 1;
77 void OnChange(const nsAString& aKey, const nsAString& aOldValue,
78 const nsAString& aNewValue);
81 } // namespace mozilla::dom
83 #endif // mozilla_dom_LocalStorage_h