Bug 1874684 - Part 6: Limit day length calculations to safe integers. r=mgaudet
[gecko.git] / dom / quota / OriginOperationBase.h
blobb3a8f9eb6762350f049acb74e1bf896afd99c564
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 {
20 class QuotaManager;
22 class OriginOperationBase : public BackgroundThreadObject {
23 protected:
24 const NotNull<RefPtr<QuotaManager>> mQuotaManager;
25 nsresult mResultCode;
27 private:
28 bool mActorDestroyed;
30 #ifdef QM_COLLECTING_OPERATION_TELEMETRY
31 const char* mName = nullptr;
32 #endif
34 public:
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; }
51 #endif
53 void RunImmediately();
55 protected:
56 OriginOperationBase(MovingNotNull<RefPtr<QuotaManager>>&& aQuotaManager,
57 const char* aName);
59 // Reference counted.
60 virtual ~OriginOperationBase();
62 virtual nsresult DoInit(QuotaManager& aQuotaManager);
64 virtual RefPtr<BoolPromise> Open() = 0;
66 #ifdef DEBUG
67 virtual nsresult DirectoryOpen();
68 #endif
70 virtual nsresult DoDirectoryWork(QuotaManager& aQuotaManager) = 0;
72 virtual void UnblockOpen() = 0;
75 } // namespace mozilla::dom::quota
77 #endif // DOM_QUOTA_ORIGINOPERATIONBASE_H_