Bug 1848468 - Mark k-rate-dynamics-compressor-connections.html subtest as failing...
[gecko.git] / dom / abort / AbortSignal.h
blob45c0390477e74da24ee0770d406fd8b58af99d84
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
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_AbortSignal_h
8 #define mozilla_dom_AbortSignal_h
10 #include "mozilla/dom/AbortFollower.h"
11 #include "mozilla/DOMEventTargetHelper.h"
13 namespace mozilla::dom {
15 // AbortSignal the spec concept includes the concept of a child signal
16 // "following" a parent signal -- internally, adding abort steps to the parent
17 // signal that will then signal abort on the child signal -- to propagate
18 // signaling abort from one signal to another. See
19 // <https://dom.spec.whatwg.org/#abortsignal-follow>.
21 // This requires that AbortSignal also inherit from AbortFollower.
23 // This ability to follow isn't directly exposed in the DOM; as of this writing
24 // it appears only to be used internally in the Fetch API. It might be a good
25 // idea to split AbortSignal into an implementation that can follow, and an
26 // implementation that can't, to provide this complexity only when it's needed.
27 class AbortSignal : public DOMEventTargetHelper,
28 public AbortSignalImpl,
29 public AbortFollower {
30 public:
31 NS_DECL_ISUPPORTS_INHERITED
32 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(AbortSignal,
33 DOMEventTargetHelper)
35 AbortSignal(nsIGlobalObject* aGlobalObject, bool aAborted,
36 JS::Handle<JS::Value> aReason);
38 JSObject* WrapObject(JSContext* aCx,
39 JS::Handle<JSObject*> aGivenProto) override;
41 IMPL_EVENT_HANDLER(abort);
43 static already_AddRefed<AbortSignal> Abort(GlobalObject& aGlobal,
44 JS::Handle<JS::Value> aReason);
46 static already_AddRefed<AbortSignal> Timeout(GlobalObject& aGlobal,
47 uint64_t aMilliseconds,
48 ErrorResult& aRv);
50 void ThrowIfAborted(JSContext* aCx, ErrorResult& aRv);
52 // AbortSignalImpl
53 void SignalAbort(JS::Handle<JS::Value> aReason) override;
55 // AbortFollower
56 void RunAbortAlgorithm() override;
58 virtual bool IsTaskSignal() const { return false; }
60 protected:
61 ~AbortSignal();
64 } // namespace mozilla::dom
66 #endif // mozilla_dom_AbortSignal_h