|
@@ -0,0 +1,55 @@
|
|
|
+# HG changeset patch
|
|
|
+# User Andrew Sutherland <asutherland@asutherland.org>
|
|
|
+# Date 1698176456 0
|
|
|
+# Node ID d04b0067e2ec64e290fc887c316e0b5ee6eb2b34
|
|
|
+# Parent ee0e86a44f87ac70fb1372d06a89bf3ef32dc4b3
|
|
|
+Bug 1854076 - ESR115 Improve MessagePort state machine. r=dom-worker-reviewers,edenchuang, a=dsmith
|
|
|
+
|
|
|
+Differential Revision: https://phabricator.services.mozilla.com/D191773
|
|
|
+
|
|
|
+diff --git a/dom/messagechannel/MessagePort.cpp b/dom/messagechannel/MessagePort.cpp
|
|
|
+--- a/dom/messagechannel/MessagePort.cpp
|
|
|
++++ b/dom/messagechannel/MessagePort.cpp
|
|
|
+@@ -248,16 +248,21 @@ MessagePort::MessagePort(nsIGlobalObject
|
|
|
+ mIdentifier = new MessagePortIdentifier();
|
|
|
+ mIdentifier->neutered() = true;
|
|
|
+ mIdentifier->sequenceId() = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ MessagePort::~MessagePort()
|
|
|
+ {
|
|
|
+ CloseForced();
|
|
|
++ MOZ_ASSERT(!mActor);
|
|
|
++ if (mActor) {
|
|
|
++ mActor->SetPort(nullptr);
|
|
|
++ mActor = nullptr;
|
|
|
++ }
|
|
|
+ MOZ_ASSERT(!mWorkerHolder);
|
|
|
+ }
|
|
|
+
|
|
|
+ /* static */ already_AddRefed<MessagePort>
|
|
|
+ MessagePort::Create(nsIGlobalObject* aGlobal, const nsID& aUUID,
|
|
|
+ const nsID& aDestinationUUID, ErrorResult& aRv)
|
|
|
+ {
|
|
|
+ MOZ_ASSERT(aGlobal);
|
|
|
+@@ -325,16 +330,20 @@ MessagePort::Initialize(const nsID& aUUI
|
|
|
+
|
|
|
+ if (!NS_IsMainThread()) {
|
|
|
+ WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
|
|
+ MOZ_ASSERT(workerPrivate);
|
|
|
+ MOZ_ASSERT(!mWorkerHolder);
|
|
|
+
|
|
|
+ nsAutoPtr<WorkerHolder> workerHolder(new MessagePortWorkerHolder(this));
|
|
|
+ if (NS_WARN_IF(!workerHolder->HoldWorker(workerPrivate, Closing))) {
|
|
|
++ // The worker is shutting down.
|
|
|
++// - mState = eStateDisentangled;
|
|
|
++// - UpdateMustKeepAlive();
|
|
|
++ CloseForced();
|
|
|
+ aRv.Throw(NS_ERROR_FAILURE);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ mWorkerHolder = Move(workerHolder);
|
|
|
+ } else if (GetOwner()) {
|
|
|
+ MOZ_ASSERT(NS_IsMainThread());
|
|
|
+ MOZ_ASSERT(GetOwner()->IsInnerWindow());
|