1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 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 __PlayPromise_h__
8 #define __PlayPromise_h__
10 #include "mozilla/dom/Promise.h"
11 #include "mozilla/Telemetry.h"
13 namespace mozilla::dom
{
15 // Decorates a DOM Promise to report telemetry as to whether it was resolved
16 // or rejected and why.
17 class PlayPromise
: public Promise
{
19 static already_AddRefed
<PlayPromise
> Create(nsIGlobalObject
* aGlobal
,
22 using PlayPromiseArr
= nsTArray
<RefPtr
<PlayPromise
>>;
23 static void ResolvePromisesWithUndefined(const PlayPromiseArr
& aPromises
);
24 static void RejectPromises(const PlayPromiseArr
& aPromises
, nsresult aError
);
27 void MaybeResolveWithUndefined();
28 void MaybeReject(nsresult aReason
);
31 explicit PlayPromise(nsIGlobalObject
* aGlobal
);
32 bool mFulfilled
= false;
35 } // namespace mozilla::dom
37 #endif // __PlayPromise_h__