/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Creating remote workers may result in creating new processes, but during // parent shutdown that would add just noise, so better bail out. if (AppShutdown::IsInOrBeyond(ShutdownPhase::AppShutdownConfirmed)) { returnfalse;
}
if (!mRemoteWorkerController) {
mRemoteWorkerController =
RemoteWorkerController::Create(aData, this, aProcessId); if (NS_WARN_IF(!mRemoteWorkerController)) { returnfalse;
}
}
if (aWindowID) {
mRemoteWorkerController->AddWindowID(aWindowID);
}
bool urlEquals; if (NS_FAILED(aScriptURL->Equals(mResolvedScriptURL, &urlEquals))) { return nullptr;
}
bool match =
aData.domain() == mDomain && urlEquals &&
aData.workerOptions().mName == mWorkerOptions.mName && // We want to be sure that the window's principal subsumes the // SharedWorker's loading principal and vice versa.
mLoadingPrincipal->Subsumes(aLoadingPrincipal) &&
aLoadingPrincipal->Subsumes(mLoadingPrincipal) &&
mEffectiveStoragePrincipalAttrs == aEffectiveStoragePrincipalAttrs; if (!match) { return nullptr;
}
if (mLockCount) {
Unused << aParent->SendNotifyLock(true);
}
if (mWebTransportCount) {
Unused << aParent->SendNotifyWebTransport(true);
}
// NB: We don't update our Suspended/Frozen state here, yet. The aParent is // responsible for doing so from SharedWorkerParent::ManagerCreated. // XXX But we could avoid iterating all of our actors because if aParent is // not frozen and we are, we would just need to thaw ourselves.
}
// mRemoteWorkerController creation can fail. If the creation fails // mRemoteWorkerController is nullptr and we should stop termination here. if (!mRemoteWorkerController) { return;
}
for (SharedWorkerParent* actor : mActors) { if (actor->IsSuspended()) {
++suspended;
}
}
// Call Suspend only when all of our actors' windows are suspended and call // Resume only when one of them resumes. if ((mSuspended && suspended == mActors.Length()) ||
(!mSuspended && suspended != mActors.Length())) { return;
}
for (SharedWorkerParent* actor : mActors) { if (actor->IsFrozen()) {
++frozen;
}
}
// Similar to UpdateSuspend, above, we only want to be frozen when all of our // actors are frozen. if ((mFrozen && frozen == mActors.Length()) ||
(!mFrozen && frozen != mActors.Length())) { return;
}
// Notify only when we either: // 1. Got a new lock when nothing were there // 2. Lost all locks if ((aCreated && mLockCount == 1) || !mLockCount) { for (SharedWorkerParent* actor : mActors) {
Unused << actor->SendNotifyLock(aCreated);
}
}
};
// Notify only when we either: // 1. Got a first WebTransport // 2. The last WebTransport goes away if ((aCreated && mWebTransportCount == 1) || mWebTransportCount == 0) { for (SharedWorkerParent* actor : mActors) {
Unused << actor->SendNotifyWebTransport(aCreated);
}
}
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.