Bug 1450644 - WorkerRef should make APIs able to work until the worker is completely terminated - part 1 - MessagePort, r=asuth

This commit is contained in:
Andrea Marchesini 2018-04-17 20:51:02 +02:00
Родитель fbfb18c610
Коммит 8cb037ae07
2 изменённых файлов: 8 добавлений и 4 удалений

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

@ -297,8 +297,8 @@ MessagePort::Initialize(const nsID& aUUID,
StrongWorkerRef::Create(workerPrivate, "MessagePort",
[self]() { self->CloseForced(); });
if (NS_WARN_IF(!strongWorkerRef)) {
// The worker is shutting down. Let's return an already closed port.
mState = eStateDisentangledForClose;
// The worker is shutting down.
aRv.Throw(NS_ERROR_FAILURE);
return;
}

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

@ -70,6 +70,10 @@ public:
{
MOZ_ASSERT(mWorkerRef);
if (aStatus < Canceling) {
return true;
}
// Let's keep this object alive for the whole Notify() execution.
RefPtr<WorkerRef> workerRef;
workerRef = mWorkerRef;
@ -128,7 +132,7 @@ WeakWorkerRef::Create(WorkerPrivate* aWorkerPrivate,
// This holder doesn't keep the worker alive.
UniquePtr<Holder> holder(new Holder("WeakWorkerRef::Holder", ref,
WorkerHolder::AllowIdleShutdownStart));
if (NS_WARN_IF(!holder->HoldWorker(aWorkerPrivate, Closing))) {
if (NS_WARN_IF(!holder->HoldWorker(aWorkerPrivate, Canceling))) {
return nullptr;
}
@ -182,7 +186,7 @@ StrongWorkerRef::Create(WorkerPrivate* aWorkerPrivate,
// The worker is kept alive by this holder.
UniquePtr<Holder> holder(new Holder(aName, ref,
WorkerHolder::PreventIdleShutdownStart));
if (NS_WARN_IF(!holder->HoldWorker(aWorkerPrivate, Closing))) {
if (NS_WARN_IF(!holder->HoldWorker(aWorkerPrivate, Canceling))) {
return nullptr;
}