Backed out changeset f594e6f00208 (bug 1940883) for causing crashes in bug 1941164.
[gecko.git] / dom / quota / OriginOperationBase.h
blobfc1c56c1a857871c202c48a7102fa6e54589d250
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/. */
7 #ifndef DOM_QUOTA_ORIGINOPERATIONBASE_H_
8 #define DOM_QUOTA_ORIGINOPERATIONBASE_H_
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"
20 namespace mozilla::dom::quota {
22 class QuotaManager;
24 class OriginOperationBase : public BackgroundThreadObject,
25 public OriginOperationCallbackHolders,
26 public Stringifyable {
27 protected:
28 const NotNull<RefPtr<QuotaManager>> mQuotaManager;
29 nsresult mResultCode;
31 private:
32 #ifdef QM_COLLECTING_OPERATION_TELEMETRY
33 const char* mName = nullptr;
34 #endif
36 public:
37 NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
39 #ifdef QM_COLLECTING_OPERATION_TELEMETRY
40 const char* Name() const { return mName; }
41 #endif
43 void RunImmediately();
45 OriginOperationCallbacks GetCallbacks(
46 const OriginOperationCallbackOptions& aCallbackOptions);
48 protected:
49 OriginOperationBase(MovingNotNull<RefPtr<QuotaManager>>&& aQuotaManager,
50 const char* aName);
52 // Reference counted.
53 virtual ~OriginOperationBase();
55 virtual nsresult DoInit(QuotaManager& aQuotaManager);
57 virtual RefPtr<BoolPromise> Open() = 0;
59 #ifdef DEBUG
60 virtual nsresult DirectoryOpen();
61 #endif
63 virtual nsresult DoDirectoryWork(QuotaManager& aQuotaManager) = 0;
65 virtual void UnblockOpen() = 0;
67 private:
68 void DoStringify(nsACString& aData) override {}
71 } // namespace mozilla::dom::quota
73 #endif // DOM_QUOTA_ORIGINOPERATIONBASE_H_