tor-browser

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

CookieStoreNotificationWatcher.h (1681B)


      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_CookieStoreNotificationWatcher_h
      8 #define mozilla_dom_CookieStoreNotificationWatcher_h
      9 
     10 #include "mozilla/MoveOnlyFunction.h"
     11 #include "mozilla/OriginAttributes.h"
     12 #include "nsIObserver.h"
     13 #include "nsWeakReference.h"
     14 
     15 namespace mozilla::dom {
     16 
     17 class CookieStoreNotificationWatcher final : public nsIObserver,
     18                                             public nsSupportsWeakReference {
     19 public:
     20  NS_DECL_ISUPPORTS
     21  NS_DECL_NSIOBSERVER
     22 
     23  static already_AddRefed<CookieStoreNotificationWatcher> Create(
     24      bool aPrivateBrowsing);
     25 
     26  static void ReleaseOnMainThread(
     27      already_AddRefed<CookieStoreNotificationWatcher> aWatcher);
     28 
     29  void CallbackWhenNotified(const nsID& aOperationID,
     30                            MoveOnlyFunction<void()> aCallback);
     31  void ForgetOperationID(const nsID& aOperationID);
     32 
     33 private:
     34  CookieStoreNotificationWatcher() = default;
     35  ~CookieStoreNotificationWatcher() = default;
     36 
     37  void MaybeResolveOperations(const nsID* aOperationID);
     38 
     39  struct PendingOperation {
     40    MoveOnlyFunction<void()> mCallback;
     41    nsID mOperationID;
     42  };
     43 
     44  // This is a simple list because I don't think we will have so many concurrent
     45  // operations to motivate an hash table.
     46  nsTArray<PendingOperation> mPendingOperations;
     47 };
     48 
     49 }  // namespace mozilla::dom
     50 
     51 #endif /* mozilla_dom_CookieStoreNotificationWatcher_h */