forked from mirrors/gecko-dev
This patch simplifies and cleans up the RemoteWorker state machine by:
- (In a previous patch in the stack) making PRemoteWorker refcounted instead of
ManualAlloc allows us to eliminate use of ThreadSafeWeakPtr and some legwork
that was attempting to ensure we only drop references to RemoteWorkerChild on
the "Worker Launcher" thread.
- Although we are not allowed to call IPC methods on a different thread, we
can absolutely add and remove refcounts on other threads as needed.
- This allowed removal of the `SelfHolder` class as well as a number of calls
to NS_ProxyRelease.
- This allowed removal of the `{get,m}RemoteWorkerControllerWeakRef` hack.
- Adding 2 optional lambda callbacks to the WorkerPrivate constructor that will
be notified on the parent thread in order to simplify tracking the state of
the worker:
- CancellationCallback: Invoked when the parent thread tells the worker to
cancel itself. This can be the automatic result of a script load error,
a call to `self.close()`, or an explicit call to Cancel() by the parent.
- Note that cancellation was always being initiated by the parent thread,
even in the case of `self.close()`!
- TerminationCallback: Invoked when the worker thread has finished and the
WorkerPrivate's self-ref is about to be dropped. This indicates that the
worker transitioned to Killing and fully completed that process.
- Changing the RemoteWorkerChild to always perform state transitions on the
owning parent thread (although the state may be checked from other threads,
more in the code comments).
- The CancellationCallback mechanism replaces a complicated use of
WorkerRefs. This allowed removal of ReleaseWorkerRunnable.
- In general this reduces the number of permutations of thread interactions
we have to worry about.
- Changing the RemoteWorkerChild to only report that the worker has finished
shutting down as a result of the TerminationCallback rather than when the
worker has transitioned to Cancelling.
- Changing the states to better represent the worker's state in terms of
WorkerStatus terminology.
Some related cleanups:
- Use of mechanisms provided by IPC:
- RemoteWorkerChild had an mOwningEventTarget with a GetOwningEventTarget
getter that we were able to replace with the IPC-maintained
GetActorEventTarget().
- We replaced the `mIPCActive` with use of IPC's CanSend().
- MOZ_LOG logging was added under "RemoteWorkerChild".
Differential Revision: https://phabricator.services.mozilla.com/D164644
|
||
|---|---|---|
| .. | ||
| docs | ||
| test | ||
| FetchEventOpChild.cpp | ||
| FetchEventOpChild.h | ||
| FetchEventOpParent.cpp | ||
| FetchEventOpParent.h | ||
| FetchEventOpProxyChild.cpp | ||
| FetchEventOpProxyChild.h | ||
| FetchEventOpProxyParent.cpp | ||
| FetchEventOpProxyParent.h | ||
| IPCNavigationPreloadState.ipdlh | ||
| IPCServiceWorkerDescriptor.ipdlh | ||
| IPCServiceWorkerRegistrationDescriptor.ipdlh | ||
| moz.build | ||
| NavigationPreloadManager.cpp | ||
| NavigationPreloadManager.h | ||
| PFetchEventOp.ipdl | ||
| PFetchEventOpProxy.ipdl | ||
| PServiceWorker.ipdl | ||
| PServiceWorkerContainer.ipdl | ||
| PServiceWorkerManager.ipdl | ||
| PServiceWorkerRegistration.ipdl | ||
| ServiceWorker.cpp | ||
| ServiceWorker.h | ||
| ServiceWorkerActors.cpp | ||
| ServiceWorkerActors.h | ||
| ServiceWorkerChild.cpp | ||
| ServiceWorkerChild.h | ||
| ServiceWorkerCloneData.cpp | ||
| ServiceWorkerCloneData.h | ||
| ServiceWorkerContainer.cpp | ||
| ServiceWorkerContainer.h | ||
| ServiceWorkerContainerChild.cpp | ||
| ServiceWorkerContainerChild.h | ||
| ServiceWorkerContainerParent.cpp | ||
| ServiceWorkerContainerParent.h | ||
| ServiceWorkerContainerProxy.cpp | ||
| ServiceWorkerContainerProxy.h | ||
| ServiceWorkerDescriptor.cpp | ||
| ServiceWorkerDescriptor.h | ||
| ServiceWorkerEvents.cpp | ||
| ServiceWorkerEvents.h | ||
| ServiceWorkerInfo.cpp | ||
| ServiceWorkerInfo.h | ||
| ServiceWorkerInterceptController.cpp | ||
| ServiceWorkerInterceptController.h | ||
| ServiceWorkerIPCUtils.h | ||
| ServiceWorkerJob.cpp | ||
| ServiceWorkerJob.h | ||
| ServiceWorkerJobQueue.cpp | ||
| ServiceWorkerJobQueue.h | ||
| ServiceWorkerManager.cpp | ||
| ServiceWorkerManager.h | ||
| ServiceWorkerManagerChild.h | ||
| ServiceWorkerManagerParent.cpp | ||
| ServiceWorkerManagerParent.h | ||
| ServiceWorkerOp.cpp | ||
| ServiceWorkerOp.h | ||
| ServiceWorkerOpArgs.ipdlh | ||
| ServiceWorkerOpPromise.h | ||
| ServiceWorkerParent.cpp | ||
| ServiceWorkerParent.h | ||
| ServiceWorkerPrivate.cpp | ||
| ServiceWorkerPrivate.h | ||
| ServiceWorkerProxy.cpp | ||
| ServiceWorkerProxy.h | ||
| ServiceWorkerQuotaUtils.cpp | ||
| ServiceWorkerQuotaUtils.h | ||
| ServiceWorkerRegisterJob.cpp | ||
| ServiceWorkerRegisterJob.h | ||
| ServiceWorkerRegistrar.cpp | ||
| ServiceWorkerRegistrar.h | ||
| ServiceWorkerRegistrarTypes.ipdlh | ||
| ServiceWorkerRegistration.cpp | ||
| ServiceWorkerRegistration.h | ||
| ServiceWorkerRegistrationChild.cpp | ||
| ServiceWorkerRegistrationChild.h | ||
| ServiceWorkerRegistrationDescriptor.cpp | ||
| ServiceWorkerRegistrationDescriptor.h | ||
| ServiceWorkerRegistrationInfo.cpp | ||
| ServiceWorkerRegistrationInfo.h | ||
| ServiceWorkerRegistrationListener.h | ||
| ServiceWorkerRegistrationParent.cpp | ||
| ServiceWorkerRegistrationParent.h | ||
| ServiceWorkerRegistrationProxy.cpp | ||
| ServiceWorkerRegistrationProxy.h | ||
| ServiceWorkerScriptCache.cpp | ||
| ServiceWorkerScriptCache.h | ||
| ServiceWorkerShutdownBlocker.cpp | ||
| ServiceWorkerShutdownBlocker.h | ||
| ServiceWorkerShutdownState.cpp | ||
| ServiceWorkerShutdownState.h | ||
| ServiceWorkerUnregisterCallback.cpp | ||
| ServiceWorkerUnregisterCallback.h | ||
| ServiceWorkerUnregisterJob.cpp | ||
| ServiceWorkerUnregisterJob.h | ||
| ServiceWorkerUpdateJob.cpp | ||
| ServiceWorkerUpdateJob.h | ||
| ServiceWorkerUtils.cpp | ||
| ServiceWorkerUtils.h | ||