tor-browser

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

OriginOperationBase.h (2042B)


      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 file,
      5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef DOM_QUOTA_ORIGINOPERATIONBASE_H_
      8 #define DOM_QUOTA_ORIGINOPERATIONBASE_H_
      9 
     10 #include "ErrorList.h"
     11 #include "mozilla/NotNull.h"
     12 #include "mozilla/RefPtr.h"
     13 #include "mozilla/dom/quota/BackgroundThreadObject.h"
     14 #include "mozilla/dom/quota/Config.h"
     15 #include "mozilla/dom/quota/ForwardDecls.h"
     16 #include "mozilla/dom/quota/OriginOperationCallbacks.h"
     17 #include "mozilla/dom/quota/StringifyUtils.h"
     18 #include "nsISupportsImpl.h"
     19 
     20 namespace mozilla::dom::quota {
     21 
     22 class QuotaManager;
     23 
     24 class OriginOperationBase : public BackgroundThreadObject,
     25                            public OriginOperationCallbackHolders,
     26                            public Stringifyable {
     27 protected:
     28  const NotNull<RefPtr<QuotaManager>> mQuotaManager;
     29  nsresult mResultCode;
     30 
     31 private:
     32 #ifdef QM_COLLECTING_OPERATION_TELEMETRY
     33  const char* mName = nullptr;
     34 #endif
     35 
     36 public:
     37  NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
     38 
     39 #ifdef QM_COLLECTING_OPERATION_TELEMETRY
     40  const char* Name() const { return mName; }
     41 #endif
     42 
     43  void RunImmediately();
     44 
     45  OriginOperationCallbacks GetCallbacks(
     46      const OriginOperationCallbackOptions& aCallbackOptions);
     47 
     48 protected:
     49  OriginOperationBase(MovingNotNull<RefPtr<QuotaManager>>&& aQuotaManager,
     50                      const char* aName);
     51 
     52  // Reference counted.
     53  virtual ~OriginOperationBase();
     54 
     55  virtual nsresult DoInit(QuotaManager& aQuotaManager);
     56 
     57  virtual RefPtr<BoolPromise> Open() = 0;
     58 
     59 #ifdef DEBUG
     60  virtual nsresult DirectoryOpen();
     61 #endif
     62 
     63  virtual nsresult DoDirectoryWork(QuotaManager& aQuotaManager) = 0;
     64 
     65  virtual void UnblockOpen() = 0;
     66 
     67 private:
     68  void DoStringify(nsACString& aData) override {}
     69 };
     70 
     71 }  // namespace mozilla::dom::quota
     72 
     73 #endif  // DOM_QUOTA_ORIGINOPERATIONBASE_H_