This patch is only remove the inheriting, but keeping Cancel() implmentation.
The Cancel() is needed in some special cases, such as Worker enters Canceling when WorkerScope is not created.
Depends on D176915
Differential Revision: https://phabricator.services.mozilla.com/D173850
And relax the check if someone carries away a stale reference to our global scope to happen after the JS context has gone out of scope.
Differential Revision: https://phabricator.services.mozilla.com/D150942
When running an infinitely-looping dynamic import, it is possible for the module loader to still be
holding on to that module at shutdown. Shutdown on the worker means that we will no longer run the
event loop, which will execute the dynamic import promises necessary to clear the global. The result
is that the global is kept alive. By calling `Shutdown()` we prevent this partially. We additionally
need to address the failure in the module code (next patch).
Differential Revision: https://phabricator.services.mozilla.com/D171683
This method always returned GetMainThreadSerialEventTarget(). This patch
switches all callers over to use that method instead.
We can't easily switch all calls to be calls to NS_GetMainThread(), as there is
no version of that method returning a bare nsIThread* instance.
I didn't introduce one, as we may want to add a lock around mMainThread in the
future, which would require removing nsThreadManager::GetMainThreadWeak. As
this method only returns nsISerialEventTarget, it method could remain
implemented, however, by returning a statically allocated fake event target
which forwards dispatches (and QIs to nsIThread) to the real main thread.
Differential Revision: https://phabricator.services.mozilla.com/D166608
This method always returned GetMainThreadSerialEventTarget(). This patch
switches all callers over to use that method instead.
We can't easily switch all calls to be calls to NS_GetMainThread(), as there is
no version of that method returning a bare nsIThread* instance.
I didn't introduce one, as we may want to add a lock around mMainThread in the
future, which would require removing nsThreadManager::GetMainThreadWeak. As
this method only returns nsISerialEventTarget, it method could remain
implemented, however, by returning a statically allocated fake event target
which forwards dispatches (and QIs to nsIThread) to the real main thread.
Differential Revision: https://phabricator.services.mozilla.com/D166608
Whereas previously we would pass in the principal of a document,
now we will pass in the document directly. This will work for most use
cases, but not all (like Workers.)
Additionally, for the User Agent, if we do not Resist Fingerprinting
(because there is an exemption), we will fall through to getting the
User-Agent header which uses the coarse RFP check, so we fix that in
a later patch.
Differential Revision: https://phabricator.services.mozilla.com/D138778
In order to get better shutdown hang reporting, we want to distinguish also the last phases, namely `XPCOMShutdownThreads`, `XPCOMShutdownMainThread` and `CCPostLastCycleCollection`.
This also makes `XPCOMShutdownNotified()` obsolete and we need to slightly re-arrange the watchdog function.
Differential Revision: https://phabricator.services.mozilla.com/D145433
There is a difference between
a) the cycle collector being shut down and
b) the JSContext being destroyed entirely
We can use weak references to cycle collected objects after the CC is destroyed, but not after the JSContext is destroyed.
Thus we need to move `nsCycleCollector_shutdown();` out of the `~WorkerJSContext()` and ensure we check our sentinels before we destroy it.
Differential Revision: https://phabricator.services.mozilla.com/D143061
The patch D138442 wanted to guard us against the late use of global scope's reference to WorkerPrivate by nulling it out. The rational behind this was to enforce the invariant, that a `WorkerGlobalScopeBase` derived object should never outlive its `WorkerPrivate`. It turned out that during further worker cleanup at the end of `WorkerThreadPrimaryRunnable::Run` we still process pending events (while the `WorkerPrivate` is still alive) that might want to access the global scope and in particular its `mWorkerPrivate` legitimately.
The purpose of this patch is to:
- Postpone the unrooting until after the last expected event processing.
- Enforce the invariant "Lifetime(global scope) < Lifetime(WorkerPrivate)" by asserting that the global scope went away after GC/CC.
- Do the nulling of global scope's `mWorkerPrivate` only if needed after the CC shut down.
- Do the nulling of debugger global scope's `mWorkerPrivate` while unrooting as it does not support weak references.
Differential Revision: https://phabricator.services.mozilla.com/D141507
During shutdown gRuntimeService can be accessed from a different thread while it gets destroyed. There should be not too much penalty having this atomic, even if it is for an edge case only.
Differential Revision: https://phabricator.services.mozilla.com/D139819