NormalOriginOperationBase.h (1802B)
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_NORMALORIGINOPERATIONBASE_H_ 8 #define DOM_QUOTA_NORMALORIGINOPERATIONBASE_H_ 9 10 #include "OriginOperationBase.h" 11 #include "mozilla/Atomics.h" 12 #include "mozilla/dom/quota/CheckedUnsafePtr.h" 13 14 namespace mozilla::dom::quota { 15 16 class NormalOriginOperationBase 17 : public OriginOperationBase, 18 public SupportsCheckedUnsafePtr<CheckIf<DiagnosticAssertEnabled>> { 19 public: 20 const Atomic<bool>& Canceled() const { return mCanceled; } 21 22 bool Cancel() { return mCanceled.exchange(true); } 23 24 protected: 25 // If we want to only forward declare DirectoryLock which is referenced by 26 // the mDirectoryLock member then the constructor and destructor must be 27 // defined in the cpp where DirectoryLock is fully declared (DirectoryLock.h 28 // is included). The compiler would complain otherwise because it wouldn't 29 // know how to call DirectoryLock::AddRef/Release in the constructor and 30 // destructor 31 NormalOriginOperationBase(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager, 32 const char* aName); 33 34 ~NormalOriginOperationBase(); 35 36 virtual RefPtr<BoolPromise> OpenDirectory() = 0; 37 38 // Used to send results before unblocking open. 39 virtual void SendResults() = 0; 40 41 virtual void CloseDirectory() = 0; 42 43 private: 44 virtual RefPtr<BoolPromise> Open() override; 45 46 virtual void UnblockOpen() override; 47 48 mozilla::Atomic<bool> mCanceled; 49 }; 50 51 } // namespace mozilla::dom::quota 52 53 #endif // DOM_QUOTA_NORMALORIGINOPERATIONBASE_H_