Bug 1919824 - Make `NativeKey::GetFollowingCharMessage` return `false` when removed...
[gecko.git] / dom / quota / ResolvableNormalOriginOp.h
blob29294cbe32cc232b6fe1e25a7621a3c9731fd969
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 {
16 template <typename ResolveValueT, bool IsExclusive>
17 class ResolvableNormalOriginOp : public NormalOriginOperationBase {
18 public:
19 NS_INLINE_DECL_REFCOUNTING(ResolvableNormalOriginOp, override)
21 using PromiseType = MozPromise<ResolveValueT, nsresult, IsExclusive>;
23 RefPtr<PromiseType> OnResults() {
24 AssertIsOnOwningThread();
26 return mPromiseHolder.Ensure(__func__);
29 protected:
30 ResolvableNormalOriginOp(MovingNotNull<RefPtr<QuotaManager>> aQuotaManager,
31 const char* aName)
32 : NormalOriginOperationBase(std::move(aQuotaManager), aName) {
33 AssertIsOnOwningThread();
36 virtual ~ResolvableNormalOriginOp() = default;
38 virtual ResolveValueT GetResolveValue() = 0;
40 private:
41 void SendResults() override {
42 if (Canceled()) {
43 mResultCode = NS_ERROR_FAILURE;
46 if (NS_SUCCEEDED(mResultCode)) {
47 mPromiseHolder.ResolveIfExists(GetResolveValue(), __func__);
48 } else {
49 mPromiseHolder.RejectIfExists(mResultCode, __func__);
53 MozPromiseHolder<PromiseType> mPromiseHolder;
56 } // namespace mozilla::dom::quota
58 #endif // DOM_QUOTA_RESOLVABLENORMALORIGINOP_H_