tree: 3e42304540908c3c94bab412f108599dd5e53fb1 [path history] [tgz]
  1. BUILD.gn
  2. OWNERS
  3. README.md
  4. abstract_worker.cc
  5. abstract_worker.h
  6. abstract_worker.idl
  7. dedicated_worker.cc
  8. dedicated_worker.h
  9. dedicated_worker_global_scope.cc
  10. dedicated_worker_global_scope.h
  11. dedicated_worker_global_scope.idl
  12. dedicated_worker_messaging_proxy.cc
  13. dedicated_worker_messaging_proxy.h
  14. dedicated_worker_object_proxy.cc
  15. dedicated_worker_object_proxy.h
  16. dedicated_worker_test.cc
  17. dedicated_worker_thread.cc
  18. dedicated_worker_thread.h
  19. execution_context_worker_registry.cc
  20. execution_context_worker_registry.h
  21. experimental/
  22. global_scope_creation_params.cc
  23. global_scope_creation_params.h
  24. installed_scripts_manager.cc
  25. installed_scripts_manager.h
  26. main_thread_worklet_reporting_proxy.cc
  27. main_thread_worklet_reporting_proxy.h
  28. main_thread_worklet_test.cc
  29. parent_execution_context_task_runners.cc
  30. parent_execution_context_task_runners.h
  31. shared_worker.cc
  32. shared_worker.h
  33. shared_worker.idl
  34. shared_worker_content_settings_proxy.cc
  35. shared_worker_content_settings_proxy.h
  36. shared_worker_global_scope.cc
  37. shared_worker_global_scope.h
  38. shared_worker_global_scope.idl
  39. shared_worker_reporting_proxy.cc
  40. shared_worker_reporting_proxy.h
  41. shared_worker_repository_client.h
  42. shared_worker_thread.cc
  43. shared_worker_thread.h
  44. threaded_messaging_proxy_base.cc
  45. threaded_messaging_proxy_base.h
  46. threaded_object_proxy_base.cc
  47. threaded_object_proxy_base.h
  48. threaded_worklet_messaging_proxy.cc
  49. threaded_worklet_messaging_proxy.h
  50. threaded_worklet_object_proxy.cc
  51. threaded_worklet_object_proxy.h
  52. threaded_worklet_test.cc
  53. worker.idl
  54. worker_animation_frame_provider.cc
  55. worker_animation_frame_provider.h
  56. worker_backing_thread.cc
  57. worker_backing_thread.h
  58. worker_backing_thread_startup_data.h
  59. worker_classic_script_loader.cc
  60. worker_classic_script_loader.h
  61. worker_clients.cc
  62. worker_clients.h
  63. worker_content_settings_client.cc
  64. worker_content_settings_client.h
  65. worker_fetch_test_helper.h
  66. worker_global_scope.cc
  67. worker_global_scope.h
  68. worker_global_scope.idl
  69. worker_inspector_proxy.cc
  70. worker_inspector_proxy.h
  71. worker_location.h
  72. worker_location.idl
  73. worker_module_tree_client.cc
  74. worker_module_tree_client.h
  75. worker_navigator.cc
  76. worker_navigator.h
  77. worker_navigator.idl
  78. worker_options.idl
  79. worker_or_worklet_global_scope.cc
  80. worker_or_worklet_global_scope.h
  81. worker_reporting_proxy.h
  82. worker_settings.cc
  83. worker_settings.h
  84. worker_thread.cc
  85. worker_thread.h
  86. worker_thread_test.cc
  87. worker_thread_test_helper.h
  88. worklet.cc
  89. worklet.h
  90. worklet.idl
  91. worklet_global_scope.cc
  92. worklet_global_scope.h
  93. worklet_global_scope.idl
  94. worklet_global_scope_proxy.h
  95. worklet_module_responses_map.cc
  96. worklet_module_responses_map.h
  97. worklet_module_responses_map_test.cc
  98. worklet_module_tree_client.cc
  99. worklet_module_tree_client.h
  100. worklet_options.idl
  101. worklet_pending_tasks.cc
  102. worklet_pending_tasks.h
  103. worklet_thread_holder.h
third_party/blink/renderer/core/workers/README.md

This directory contains the base implementation of all worker and worklet types. Also, this contains the implementation of the Web Workers API (Dedicated Worker and Shared Worker) and Worklets API.

Worker / Worklet types

  • Workers are divided into 2 types:
    • In-process workers (Dedicated Workers): A worker of this type always runs in the same renderer process with a parent document that starts the worker.
    • Out-of-process workers (Shared Workers and Service Workers): A worker of this type may run in a different renderer process with a parent document that starts the worker.
  • Worklets are divided into 2 types:
    • Main thread worklets (Paint Worklets and Layout Worklets): A worklet of this type runs on the main thread.
    • Threaded worklets (Audio Worklets and Animation Worklets): A worklet of this type runs on a worker thread.

Worklets always run in the same renderer process with a parent document that starts the worklet like the in-process-workers.

Naming conventions

Classes in this directory are named with the following conventions, there're still some exceptions though.

  • WorkerOrWorklet prefix: Classes commonly used for workers and worklets (e.g., WorkerOrWorkletGlobalScope).
  • Worker / Worklet prefix: Classes used for workers or worklets (e.g., WorkerGlobalScope).
  • Threaded prefix: Classes used for workers and threaded worklets (e.g., ThreadedMessagingProxyBase).
  • MainThreadWorklet prefix: Classes used for main thread worklets (e.g., MainThreadWorkletReportingProxy).

Thread hopping between the main (parent) thread and a worker thread is handled by proxy classes.

  • MessagingProxy is the main (parent) thread side proxy that communicates to the worker thread.
  • ObjectProxy is the worker thread side proxy that communicates to the main (parent) thread. Object indicates a worker/worklet JavaScript object on the parent execution context.

References