tor-browser

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

PartitionedLocalStorage.h (2123B)


      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_PartitionedLocalStorage_h
      8 #define mozilla_dom_PartitionedLocalStorage_h
      9 
     10 #include "Storage.h"
     11 
     12 class nsIPrincipal;
     13 
     14 namespace mozilla::dom {
     15 
     16 class SessionStorageCache;
     17 
     18 // PartitionedLocalStorage is a in-memory-only storage exposed to trackers. It
     19 // doesn't share data with other contexts.
     20 
     21 class PartitionedLocalStorage final : public Storage {
     22 public:
     23  NS_DECL_ISUPPORTS_INHERITED
     24  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PartitionedLocalStorage, Storage)
     25 
     26  PartitionedLocalStorage(nsPIDOMWindowInner* aWindow, nsIPrincipal* aPrincipal,
     27                          nsIPrincipal* aStoragePrincipal,
     28                          SessionStorageCache* aCache);
     29 
     30  StorageType Type() const override { return ePartitionedLocalStorage; }
     31 
     32  int64_t GetOriginQuotaUsage() const override;
     33 
     34  bool IsForkOf(const Storage* aStorage) const override;
     35 
     36  // WebIDL
     37  uint32_t GetLength(nsIPrincipal& aSubjectPrincipal,
     38                     ErrorResult& aRv) override;
     39 
     40  void Key(uint32_t aIndex, nsAString& aResult, nsIPrincipal& aSubjectPrincipal,
     41           ErrorResult& aRv) override;
     42 
     43  void GetItem(const nsAString& aKey, nsAString& aResult,
     44               nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv) override;
     45 
     46  void GetSupportedNames(nsTArray<nsString>& aKeys) override;
     47 
     48  void SetItem(const nsAString& aKey, const nsAString& aValue,
     49               nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv) override;
     50 
     51  void RemoveItem(const nsAString& aKey, nsIPrincipal& aSubjectPrincipal,
     52                  ErrorResult& aRv) override;
     53 
     54  void Clear(nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv) override;
     55 
     56 private:
     57  ~PartitionedLocalStorage();
     58 
     59  RefPtr<SessionStorageCache> mCache;
     60 };
     61 
     62 }  // namespace mozilla::dom
     63 
     64 #endif  // mozilla_dom_PartitionedLocalStorage_h