tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

SessionStorage.h (2680B)


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