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