Skip to content

Commit

Permalink
Bug 1660954. r=smaug
Browse files Browse the repository at this point in the history
  • Loading branch information
jswalden committed Sep 21, 2020
1 parent 89d33e1 commit 55f9e3c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
6 changes: 1 addition & 5 deletions dom/abort/AbortSignal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@ void AbortSignalImpl::Abort() {

mAborted = true;

// We might be deleted as a result of aborting a follower, so ensure we live
// until all followers have been aborted.
RefPtr<AbortSignalImpl> pinThis = this;

// Let's inform the followers.
for (AbortFollower* follower : mFollowers.ForwardRange()) {
for (RefPtr<AbortFollower> follower : mFollowers.ForwardRange()) {
follower->Abort();
}
}
Expand Down
6 changes: 6 additions & 0 deletions dom/abort/AbortSignal.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define mozilla_dom_AbortSignal_h

#include "mozilla/DOMEventTargetHelper.h"
#include "nsISupportsImpl.h"
#include "nsTObserverArray.h"

namespace mozilla {
Expand All @@ -20,6 +21,8 @@ class AbortSignalImpl;
// AbortSignalImpl.
class AbortFollower {
public:
NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING

virtual void Abort() = 0;

void Follow(AbortSignalImpl* aSignal);
Expand All @@ -40,6 +43,9 @@ class AbortFollower {
// Unfollow() when Unlinking.
class AbortSignalImpl : public AbortFollower, public nsISupports {
public:
using nsISupports::AddRef;
using nsISupports::Release;

explicit AbortSignalImpl(bool aAborted);

bool Aborted() const;
Expand Down
2 changes: 1 addition & 1 deletion dom/fetch/Fetch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class AbortSignalProxy final : public AbortFollower {
};

public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(AbortSignalProxy)
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(AbortSignalProxy, override)

AbortSignalProxy(AbortSignalImpl* aSignalImpl,
nsIEventTarget* aMainThreadEventTarget)
Expand Down
3 changes: 3 additions & 0 deletions dom/fetch/Fetch.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ nsresult ExtractByteStreamFromBody(const fetch::ResponseBodyInit& aBodyInit,
template <class Derived>
class FetchBody : public BodyStreamHolder, public AbortFollower {
public:
using BodyStreamHolder::AddRef;
using BodyStreamHolder::Release;

bool GetBodyUsed(ErrorResult& aRv) const;

// For use in assertions. On success, returns true if the body is used, false
Expand Down

0 comments on commit 55f9e3c

Please sign in to comment.