tor-browser

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

LocalStorageManager2.h (2352B)


      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_localstorage_LocalStorageManager2_h
      8 #define mozilla_dom_localstorage_LocalStorageManager2_h
      9 
     10 #include "ErrorList.h"
     11 #include "nsIDOMStorageManager.h"
     12 #include "nsILocalStorageManager.h"
     13 #include "nsISupports.h"
     14 
     15 namespace mozilla::dom {
     16 
     17 class LSRequestChild;
     18 class LSRequestChildCallback;
     19 class LSRequestParams;
     20 class LSSimpleRequestParams;
     21 class Promise;
     22 
     23 /**
     24 * Under LSNG this exposes nsILocalStorageManager::Preload to ContentParent to
     25 * trigger preloading.  Otherwise, this is basically just a place for test logic
     26 * that doesn't make sense to put directly on the Storage WebIDL interface.
     27 *
     28 * Previously, the nsIDOMStorageManager XPCOM interface was also used by
     29 * nsGlobalWindowInner to interact with LocalStorage, but in these de-XPCOM
     30 * days, we've moved to just directly reference the relevant concrete classes
     31 * (ex: LSObject) directly.
     32 *
     33 * Note that testing methods are now also directly exposed on the Storage WebIDL
     34 * interface for simplicity/sanity.
     35 */
     36 class LocalStorageManager2 final : public nsIDOMStorageManager,
     37                                   public nsILocalStorageManager {
     38 public:
     39  LocalStorageManager2();
     40 
     41  NS_DECL_ISUPPORTS
     42  NS_DECL_NSIDOMSTORAGEMANAGER
     43  NS_DECL_NSILOCALSTORAGEMANAGER
     44 
     45  /**
     46   * Helper to trigger an LSRequest and resolve/reject the provided promise when
     47   * the result comes in.  This routine is notable because the LSRequest
     48   * mechanism is normally used synchronously from content, but here it's
     49   * exposed asynchronously.
     50   */
     51  LSRequestChild* StartRequest(const LSRequestParams& aParams,
     52                               LSRequestChildCallback* aCallback);
     53 
     54 private:
     55  ~LocalStorageManager2();
     56 
     57  /**
     58   * Helper to trigger an LSSimpleRequst and resolve/reject the provided promise
     59   * when the result comes in.
     60   */
     61  nsresult StartSimpleRequest(Promise* aPromise,
     62                              const LSSimpleRequestParams& aParams);
     63 };
     64 
     65 }  // namespace mozilla::dom
     66 
     67 #endif  // mozilla_dom_localstorage_LocalStorageManager2_h