FetchObserver.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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_FetchObserver_h
  6. #define mozilla_dom_FetchObserver_h
  7. #include "mozilla/DOMEventTargetHelper.h"
  8. #include "mozilla/dom/FetchObserverBinding.h"
  9. #include "mozilla/dom/AbortSignal.h"
  10. namespace mozilla {
  11. namespace dom {
  12. class FetchObserver final : public DOMEventTargetHelper
  13. , public AbortSignal::Follower
  14. {
  15. public:
  16. NS_DECL_ISUPPORTS_INHERITED
  17. NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(FetchObserver, DOMEventTargetHelper)
  18. static bool
  19. IsEnabled(JSContext* aCx, JSObject* aGlobal);
  20. FetchObserver(nsIGlobalObject* aGlobal, AbortSignal* aSignal);
  21. JSObject*
  22. WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
  23. FetchState
  24. State() const;
  25. IMPL_EVENT_HANDLER(statechange);
  26. IMPL_EVENT_HANDLER(requestprogress);
  27. IMPL_EVENT_HANDLER(responseprogress);
  28. void
  29. Aborted() override;
  30. void
  31. SetState(FetchState aState);
  32. private:
  33. ~FetchObserver() = default;
  34. FetchState mState;
  35. };
  36. } // dom namespace
  37. } // mozilla namespace
  38. #endif // mozilla_dom_FetchObserver_h