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/Config.h"
14 #include "mozilla/dom/quota/ForwardDecls.h"
15 #include "mozilla/dom/quota/QuotaCommon.h"
16 #include "nsISupportsImpl.h"
18 namespace mozilla::dom::quota
{
22 class OriginOperationBase
: public BackgroundThreadObject
{
24 const NotNull
<RefPtr
<QuotaManager
>> mQuotaManager
;
30 #ifdef QM_COLLECTING_OPERATION_TELEMETRY
31 const char* mName
= nullptr;
35 NS_INLINE_DECL_REFCOUNTING(OriginOperationBase
)
37 void NoteActorDestroyed() {
38 AssertIsOnOwningThread();
40 mActorDestroyed
= true;
43 bool IsActorDestroyed() const {
44 AssertIsOnOwningThread();
46 return mActorDestroyed
;
49 #ifdef QM_COLLECTING_OPERATION_TELEMETRY
50 const char* Name() const { return mName
; }
53 void RunImmediately();
56 OriginOperationBase(MovingNotNull
<RefPtr
<QuotaManager
>>&& aQuotaManager
,
60 virtual ~OriginOperationBase();
62 virtual nsresult
DoInit(QuotaManager
& aQuotaManager
);
64 virtual RefPtr
<BoolPromise
> Open() = 0;
67 virtual nsresult
DirectoryOpen();
70 virtual nsresult
DoDirectoryWork(QuotaManager
& aQuotaManager
) = 0;
72 virtual void UnblockOpen() = 0;
75 } // namespace mozilla::dom::quota
77 #endif // DOM_QUOTA_ORIGINOPERATIONBASE_H_