AbortController.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef mozilla_dom_AbortController_h
  6. #define mozilla_dom_AbortController_h
  7. #include "mozilla/dom/BindingDeclarations.h"
  8. #include "mozilla/dom/AbortSignal.h"
  9. #include "nsCycleCollectionParticipant.h"
  10. #include "nsWrapperCache.h"
  11. #include "mozilla/ErrorResult.h"
  12. #include "nsIGlobalObject.h"
  13. namespace mozilla {
  14. namespace dom {
  15. class AbortController final : public nsISupports
  16. , public nsWrapperCache
  17. {
  18. public:
  19. NS_DECL_CYCLE_COLLECTING_ISUPPORTS
  20. NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(AbortController)
  21. static bool
  22. IsEnabled(JSContext* aCx, JSObject* aGlobal);
  23. static already_AddRefed<AbortController>
  24. Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
  25. explicit AbortController(nsIGlobalObject* aGlobal);
  26. JSObject*
  27. WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
  28. nsIGlobalObject*
  29. GetParentObject() const;
  30. AbortSignal*
  31. Signal();
  32. void
  33. Abort();
  34. private:
  35. ~AbortController() = default;
  36. nsCOMPtr<nsIGlobalObject> mGlobal;
  37. RefPtr<AbortSignal> mSignal;
  38. bool mAborted;
  39. };
  40. } // dom namespace
  41. } // mozilla namespace
  42. #endif // mozilla_dom_AbortController_h