Name Description Size Coverage
ChromeWorker.cpp static 3116 100 %
ChromeWorker.h unused 1077 100 %
ChromeWorkerScope.cpp 1886 82 %
ChromeWorkerScope.h 643 -
EventWithOptionsRunnable.cpp 4813 67 %
EventWithOptionsRunnable.h 2165 0 %
JSExecutionManager.cpp 7199 29 %
JSExecutionManager.h 6930 33 %
JSSettings.h 1819 91 %
loader 84 %
MessageEventRunnable.cpp 6442 74 %
MessageEventRunnable.h 1752 100 %
metrics.yaml 2840 -
moz.build 2609 -
nsIWorkerChannelInfo.idl 847 -
nsIWorkerDebugger.idl 2435 -
nsIWorkerDebuggerManager.idl 836 -
Queue.h mozilla_dom_workerinternals_Queue_h 3754 100 %
RegisterBindings.cpp 1486 74 %
remoteworkers 73 %
RuntimeService.cpp 83803 82 %
RuntimeService.h 5749 100 %
ScriptLoader.cpp 70002 94 %
ScriptLoader.h 13917 71 %
sharedworkers 82 %
test -
Worker.cpp static 9016 92 %
Worker.h mozilla_dom_Worker_h 4173 100 %
WorkerChannelInfo.cpp 1890 75 %
WorkerChannelInfo.h 1363 100 %
WorkerCommon.h 2146 100 %
WorkerCSPEventListener.cpp static 2773 95 %
WorkerCSPEventListener.h 1100 100 %
WorkerDebugger.cpp 13931 85 %
WorkerDebugger.h 1691 100 %
WorkerDebuggerManager.cpp anonymous namespace 10763 84 %
WorkerDebuggerManager.h 3366 80 %
WorkerDocumentListener.cpp 3530 95 %
WorkerDocumentListener.h mozilla_dom_WorkerDocumentListener_h_ 1150 100 %
WorkerError.cpp isErrorEvent 15738 88 %
WorkerError.h 2521 100 %
WorkerEventTarget.cpp 8273 62 %
WorkerEventTarget.h 1708 100 %
WorkerIPCUtils.h 1356 100 %
WorkerLoadInfo.cpp 16815 95 %
WorkerLoadInfo.h 6065 100 %
WorkerLocation.cpp static 1419 100 %
WorkerLocation.h 2488 100 %
WorkerNavigator.cpp static 10033 98 %
WorkerNavigator.h unused 3748 95 %
WorkerPrivate.cpp 226009 84 %
WorkerPrivate.h 61411 98 %
WorkerRef.cpp static 7388 100 %
WorkerRef.h If you want to play with a DOM Worker, you must know that it can go away at any time if nothing prevents its shutting down. This documentation helps to understand how to play with DOM Workers correctly. There are several reasons why a DOM Worker could go away. Here is the complete list: a. GC/CC - If the DOM Worker thread is idle and the Worker object is garbage collected, it goes away. b. The worker script can call self.close() c. The Worker object calls worker.terminate() d. Firefox is shutting down. When a DOM Worker goes away, it does several steps. See more in WorkerStatus.h. The DOM Worker thread will basically stop scheduling WorkerRunnables, and eventually WorkerControlRunnables. But if there is something preventing the shutting down, it will always possible to dispatch WorkerControlRunnables. Of course, at some point, the worker _must_ be released, otherwise firefox will leak it and the browser shutdown will hang. WeakWorkerRef is a refcounted, NON thread-safe object. From this object, you can obtain a WorkerPrivate, calling WeakWorkerRef::GetPrivate(). It returns nullptr if the worker is shutting down or if it is already gone away. If you want to know when a DOM Worker starts the shutting down procedure, pass a callback to the mozilla::dom::WeakWorkerRef::Create() method. Your function will be called. Note that _after_ the callback, WeakWorkerRef::GetPrivate() will return nullptr. How to keep a DOM Worker alive? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If you need to keep the worker alive, you must use StrongWorkerRef. You can have this refcounted, NON thread-safe object, calling mozilla::dom::StrongWorkerRef::Create(WorkerPrivate* aWorkerPrivate); If you have a StrongWorkerRef: a. the DOM Worker is kept alive. b. you can have access to the WorkerPrivate, calling: Private(). c. WorkerControlRunnable can be dispatched. Note that the DOM Worker shutdown can start at any time, but having a StrongWorkerRef prevents the full shutdown. Also with StrongWorkerRef, you can pass a callback when calling mozilla::dom::StrongWorkerRef::Create(). When the DOM Worker shutdown starts, WorkerRunnable cannot be dispatched anymore. At this point, you should dispatch WorkerControlRunnable just to release resources. How to have a thread-safe DOM Worker reference? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sometimes you need to play with threads and you need a thread-safe worker reference. ThreadSafeWorkerRef is what you want. Just because this object can be sent to different threads, we don't allow the setting of a callback. It would be confusing. ThreadSafeWorkerRef can be destroyed in any thread. Internally it keeps a reference to its StrongWorkerRef creator and this ref will be dropped on the correct thread when the ThreadSafeWorkerRef is deleted. IPC WorkerRef ~~~~~~~~~~~~~ IPDL protocols require a correct shutdown sequence. Because of this, they need a special configuration: 1. they need to be informed when the Worker starts the shutting down 2. they don't want to prevent the shutdown 3. but at the same time, they need to block the shutdown until the WorkerRef is not longer alive. Point 1 is a standard feature of WorkerRef; point 2 is similar to WeakWorkerRef; point 3 is similar to StrongWorkerRef. You can create a special IPC WorkerRef using this static method: mozilla::dom::IPCWorkerRef::Create(WorkerPrivate* aWorkerPrivate, const char* * aName); 9180 82 %
WorkerRunnable.cpp 25305 89 %
WorkerRunnable.h 20264 84 %
WorkerScope.cpp 52770 93 %
WorkerScope.h 20167 76 %
WorkerStatus.h Use this chart to help figure out behavior during each of the closing statuses. Details below. +========================================================+ | Closing Statuses | +=============+=============+=================+==========+ | status | clear queue | abort execution | notified | +=============+=============+=================+==========+ | Closing | yes | no | no | +-------------+-------------+-----------------+----------+ | Canceling | yes | yes | yes | +-------------+-------------+-----------------+----------+ | Killing | yes | yes | yes | +-------------+-------------+-----------------+----------+ 2185 -
WorkerTestUtils.cpp 5553 72 %
WorkerTestUtils.h dom/webidl/WorkerTestUtils.webidl defines APIs to expose worker's internal status for glass-box testing. The APIs are only exposed to Workers with prefs dom.workers.testing.enabled. WorkerTestUtils is the implementation of dom/webidl/WorkerTestUtils.webidl 2000 -
WorkerThread.cpp aKey 10465 83 %
WorkerThread.h 3667 100 %