tor-browser

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

CookieStoreManager.h (1969B)


      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_CookieStoreManager_h
      8 #define mozilla_dom_CookieStoreManager_h
      9 
     10 #include "mozilla/dom/CookieStoreBinding.h"
     11 #include "mozilla/dom/CookieStoreManagerBinding.h"
     12 #include "nsWrapperCache.h"
     13 
     14 class nsIGlobalObject;
     15 
     16 namespace mozilla::dom {
     17 
     18 class CookieStoreChild;
     19 class Promise;
     20 
     21 class CookieStoreManager final : public nsWrapperCache {
     22 public:
     23  NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(CookieStoreManager)
     24  NS_DECL_CYCLE_COLLECTION_NATIVE_WRAPPERCACHE_CLASS(CookieStoreManager)
     25 
     26  CookieStoreManager(nsIGlobalObject* aGlobalObject,
     27                     const nsACString& aServiceWorkerRegistrationScopeURL);
     28 
     29  nsIGlobalObject* GetParentObject() const { return mGlobalObject; }
     30 
     31  JSObject* WrapObject(JSContext* aCx,
     32                       JS::Handle<JSObject*> aGivenProto) override;
     33 
     34  already_AddRefed<Promise> Subscribe(
     35      const CopyableTArray<CookieStoreGetOptions>& aSubscriptions,
     36      ErrorResult& aRv);
     37 
     38  already_AddRefed<Promise> GetSubscriptions(ErrorResult& aRv);
     39 
     40  already_AddRefed<Promise> Unsubscribe(
     41      const CopyableTArray<CookieStoreGetOptions>& aSubscriptions,
     42      ErrorResult& aRv);
     43 
     44 private:
     45  ~CookieStoreManager();
     46 
     47  bool MaybeCreateActor();
     48 
     49  void Shutdown();
     50 
     51  enum class Action {
     52    eSubscribe,
     53    eUnsubscribe,
     54  };
     55 
     56  already_AddRefed<Promise> SubscribeOrUnsubscribe(
     57      Action aAction,
     58      const CopyableTArray<CookieStoreGetOptions>& aSubscriptions,
     59      ErrorResult& aRv);
     60 
     61  RefPtr<nsIGlobalObject> mGlobalObject;
     62  nsCString mScopeURL;
     63 
     64  RefPtr<CookieStoreChild> mActor;
     65 };
     66 
     67 }  // namespace mozilla::dom
     68 
     69 #endif /* mozilla_dom_CookieStoreManager_h */