/* 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/. */
using remoteworker::Canceled; using remoteworker::Killed; using remoteworker::Pending; using remoteworker::Running;
namespace {
// Normal runnable because AddPortIdentifier() is going to exec JS code. class MessagePortIdentifierRunnable final : public WorkerSameThreadRunnable { public:
MessagePortIdentifierRunnable(
RemoteWorkerNonLifeCycleOpControllerChild* aActor, const MessagePortIdentifier& aPortIdentifier)
: WorkerSameThreadRunnable("MessagePortIdentifierRunnable"),
mActor(aActor),
mPortIdentifier(aPortIdentifier) {}
bool SharedWorkerOp::MaybeStart(RemoteWorkerChild* aOwner,
RemoteWorkerState& aState) {
MOZ_ASSERT(!mStarted);
MOZ_ASSERT(aOwner); // Thread: We are on the Worker Launcher thread.
// Return false, indicating we should queue this op if our current state is // pending and this isn't a termination op (which should skip the line). if (aState.is<Pending>() && !IsTerminationOp()) { returnfalse;
}
// If the worker is already shutting down (which should be unexpected // because we should be told new operations after a termination op), just // return true to indicate the op should be discarded. if (aState.is<Canceled>() || aState.is<Killed>()) { #ifdef DEBUG
mStarted = true; #endif returntrue;
}
void SharedWorkerOp::Start(RemoteWorkerNonLifeCycleOpControllerChild* aOwner,
RemoteWorkerState& aState) {
MOZ_ASSERT(!mStarted);
MOZ_ASSERT(aOwner); // Thread: We are on the Worker thread.
// Only PortIdentifierOp is NonLifeCycle related opertaion.
MOZ_ASSERT(mOpArgs.type() ==
SharedWorkerOpArgs::TSharedWorkerPortIdentifierOpArgs);
// Should never be Pending state.
MOZ_ASSERT(!aState.is<Pending>());
// If the worker is already shutting down (which should be unexpected // because we should be told new operations after a termination op), just // return directly. if (aState.is<Canceled>() || aState.is<Killed>()) { #ifdef DEBUG
mStarted = true; #endif
MessagePort::ForceClose(
mOpArgs.get_SharedWorkerPortIdentifierOpArgs().portIdentifier()); return;
}
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.