Bug 1378342 - AbortSignal/AbortController - part 3 - Removing the following algorithm, r=bkelly

This commit is contained in:
Andrea Marchesini 2017-08-29 07:30:20 +02:00
Родитель 9b66f91da8
Коммит df2bbaffa3
6 изменённых файлов: 6 добавлений и 125 удалений

Просмотреть файл

@ -12,8 +12,7 @@
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(AbortController, mGlobal, mSignal,
mFollowingSignal)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(AbortController, mGlobal, mSignal)
NS_IMPL_CYCLE_COLLECTING_ADDREF(AbortController)
NS_IMPL_CYCLE_COLLECTING_RELEASE(AbortController)
@ -95,33 +94,5 @@ AbortController::Abort()
}
}
void
AbortController::Follow(AbortSignal& aSignal)
{
AbortSignal::Follower::Follow(&aSignal);
}
void
AbortController::Unfollow(AbortSignal& aSignal)
{
if (mFollowingSignal != &aSignal) {
return;
}
AbortSignal::Follower::Unfollow();
}
AbortSignal*
AbortController::Following() const
{
return mFollowingSignal;
}
void
AbortController::Aborted()
{
Abort();
}
} // dom namespace
} // mozilla namespace

Просмотреть файл

@ -8,16 +8,19 @@
#define mozilla_dom_AbortController_h
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/AbortSignal.h"
#include "mozilla/ErrorResult.h"
#include "nsCycleCollectionParticipant.h"
#include "nsWrapperCache.h"
class nsIGlobalObject;
namespace mozilla {
namespace dom {
class AbortSignal;
class AbortController final : public nsISupports
, public nsWrapperCache
, public AbortSignal::Follower
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
@ -43,19 +46,6 @@ public:
void
Abort();
void
Follow(AbortSignal& aSignal);
void
Unfollow(AbortSignal& aSignal);
AbortSignal*
Following() const;
// AbortSignal::Follower
void Aborted() override;
private:
~AbortController() = default;

Просмотреть файл

@ -67,8 +67,6 @@ AbortSignal::Abort()
init.mBubbles = false;
init.mCancelable = false;
// TODO which kind of event should we dispatch here?
RefPtr<Event> event =
Event::Constructor(this, NS_LITERAL_STRING("abort"), init);
event->SetTrusted(true);
@ -93,27 +91,6 @@ AbortSignal::RemoveFollower(AbortSignal::Follower* aFollower)
mFollowers.RemoveElement(aFollower);
}
bool
AbortSignal::CanAcceptFollower(AbortSignal::Follower* aFollower) const
{
MOZ_DIAGNOSTIC_ASSERT(aFollower);
if (!mController) {
return true;
}
if (aFollower == mController) {
return false;
}
AbortSignal* following = mController->Following();
if (!following) {
return true;
}
return following->CanAcceptFollower(aFollower);
}
// AbortSignal::Follower
// ----------------------------------------------------------------------------
@ -127,10 +104,6 @@ AbortSignal::Follower::Follow(AbortSignal* aSignal)
{
MOZ_DIAGNOSTIC_ASSERT(aSignal);
if (!aSignal->CanAcceptFollower(this)) {
return;
}
Unfollow();
mFollowingSignal = aSignal;

Просмотреть файл

@ -59,9 +59,6 @@ public:
void
RemoveFollower(Follower* aFollower);
bool
CanAcceptFollower(Follower* aFollower) const;
private:
~AbortSignal() = default;

Просмотреть файл

@ -32,49 +32,6 @@ function testUpdateData() {
next();
}
function testFollowingOurself() {
// Let's follow ourself
var ac = new AbortController();
ac.follow(ac.signal);
ac.abort();
is(ac.signal.aborted, true, "Signal is aborted");
next();
}
function testFollowingOther() {
// Let's follow another one
var ac1 = new AbortController();
var ac2 = new AbortController();
ac1.follow(ac2.signal);
ac2.abort();
is(ac1.signal.aborted, true, "Signal is aborted");
is(ac2.signal.aborted, true, "Signal is aborted");
next();
}
function testFollowingLoop() {
// ac1 -> ac2 -> ac3 -> ac1
var ac1 = new AbortController();
var ac2 = new AbortController();
var ac3 = new AbortController();
ac1.follow(ac2.signal);
ac2.follow(ac3.signal);
ac3.follow(ac1.signal);
ac3.abort();
is(ac1.signal.aborted, true, "Signal is aborted");
is(ac2.signal.aborted, true, "Signal is aborted");
is(ac3.signal.aborted, true, "Signal is aborted");
next();
}
function testAbortEvent() {
var ac = new AbortController();
ac.signal.onabort = function(e) {
@ -131,11 +88,6 @@ var steps = [
testWebIDL,
testUpdateData,
// Following algorithm
testFollowingOurself,
testFollowingOther,
testFollowingLoop,
// Event propagation
testAbortEvent,

Просмотреть файл

@ -13,6 +13,4 @@ interface AbortController {
readonly attribute AbortSignal signal;
void abort();
void follow(AbortSignal signal);
void unfollow(AbortSignal signal);
};