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_RESOLVABLENORMALORIGINOP_H_
8 #define DOM_QUOTA_RESOLVABLENORMALORIGINOP_H_
10 #include "NormalOriginOperationBase.h"
12 #include "mozilla/MozPromise.h"
14 namespace mozilla::dom::quota
{
17 class ResolvableNormalOriginOp
: public NormalOriginOperationBase
{
19 using PromiseType
= MozPromise
<T
, nsresult
, false>;
21 RefPtr
<PromiseType
> OnResults() {
22 AssertIsOnOwningThread();
24 return mPromiseHolder
.Ensure(__func__
);
28 ResolvableNormalOriginOp(MovingNotNull
<RefPtr
<QuotaManager
>> aQuotaManager
,
30 : NormalOriginOperationBase(std::move(aQuotaManager
), aName
) {
31 AssertIsOnOwningThread();
34 virtual ~ResolvableNormalOriginOp() = default;
36 virtual T
GetResolveValue() = 0;
39 void SendResults() override
{
44 if (NS_SUCCEEDED(mResultCode
)) {
45 mPromiseHolder
.ResolveIfExists(GetResolveValue(), __func__
);
47 mPromiseHolder
.RejectIfExists(mResultCode
, __func__
);
51 MozPromiseHolder
<PromiseType
> mPromiseHolder
;
54 } // namespace mozilla::dom::quota
56 #endif // DOM_QUOTA_RESOLVABLENORMALORIGINOP_H_