tree: 7de5b19c8507923e7f069ae0269bb0d8b5f367d2 [path history] [tgz]
  1. cors/
  2. first_party_sets/
  3. origin_policy/
  4. p2p/
  5. public/
  6. resource_scheduler/
  7. sct_auditing/
  8. test/
  9. throttling/
  10. trust_tokens/
  11. BUILD.gn
  12. cert_verifier_with_trust_anchors.cc
  13. cert_verifier_with_trust_anchors.h
  14. cert_verifier_with_trust_anchors_unittest.cc
  15. chunked_data_pipe_upload_data_stream.cc
  16. chunked_data_pipe_upload_data_stream.h
  17. chunked_data_pipe_upload_data_stream_unittest.cc
  18. conditional_cache_deletion_helper.cc
  19. conditional_cache_deletion_helper.h
  20. content_security_policy_fuzzer.cc
  21. cookie_access_delegate_impl.cc
  22. cookie_access_delegate_impl.h
  23. cookie_manager.cc
  24. cookie_manager.h
  25. cookie_manager_unittest.cc
  26. cookie_settings.cc
  27. cookie_settings.h
  28. cookie_settings_unittest.cc
  29. crash_keys.cc
  30. crash_keys.h
  31. crl_set_distributor.cc
  32. crl_set_distributor.h
  33. cross_origin_read_blocking_explainer.md
  34. ct_log_list_distributor.cc
  35. ct_log_list_distributor.h
  36. ct_log_list_distributor_unittest.cc
  37. data_pipe_element_reader.cc
  38. data_pipe_element_reader.h
  39. data_pipe_element_reader_unittest.cc
  40. DEPS
  41. dhcp_pac_file_fetcher_mojo.cc
  42. dhcp_pac_file_fetcher_mojo.h
  43. dhcp_pac_file_fetcher_mojo_unittest.cc
  44. DIR_METADATA
  45. dns_config_change_manager.cc
  46. dns_config_change_manager.h
  47. dns_config_change_manager_unittest.cc
  48. expect_ct_reporter.cc
  49. expect_ct_reporter.h
  50. expect_ct_reporter_unittest.cc
  51. host_resolver.cc
  52. host_resolver.h
  53. host_resolver_mdns_listener.cc
  54. host_resolver_mdns_listener.h
  55. host_resolver_unittest.cc
  56. http_auth_cache_copier.cc
  57. http_auth_cache_copier.h
  58. http_cache_data_counter.cc
  59. http_cache_data_counter.h
  60. http_cache_data_counter_unittest.cc
  61. http_cache_data_remover.cc
  62. http_cache_data_remover.h
  63. http_cache_data_remover_unittest.cc
  64. http_server_properties_pref_delegate.cc
  65. http_server_properties_pref_delegate.h
  66. ignore_errors_cert_verifier.cc
  67. ignore_errors_cert_verifier.h
  68. ignore_errors_cert_verifier_unittest.cc
  69. keepalive_statistics_recorder.cc
  70. keepalive_statistics_recorder.h
  71. keepalive_statistics_recorder_unittest.cc
  72. mdns_responder.cc
  73. mdns_responder.h
  74. mdns_responder_unittest.cc
  75. mock_mojo_dhcp_wpad_url_client.cc
  76. mock_mojo_dhcp_wpad_url_client.h
  77. mojo_host_resolver_impl.cc
  78. mojo_host_resolver_impl.h
  79. mojo_host_resolver_impl_unittest.cc
  80. mojo_socket_test_util.cc
  81. mojo_socket_test_util.h
  82. net_log_exporter.cc
  83. net_log_exporter.h
  84. net_log_proxy_sink.cc
  85. net_log_proxy_sink.h
  86. net_log_proxy_sink_unittest.cc
  87. network_change_manager.cc
  88. network_change_manager.h
  89. network_change_manager_unittest.cc
  90. network_context.cc
  91. network_context.h
  92. network_context_unittest.cc
  93. network_qualities_pref_delegate.cc
  94. network_qualities_pref_delegate.h
  95. network_qualities_pref_delegate_unittest.cc
  96. network_quality_estimator_manager.cc
  97. network_quality_estimator_manager.h
  98. network_quality_estimator_manager_unittest.cc
  99. network_sandbox_hook_linux.cc
  100. network_sandbox_hook_linux.h
  101. network_service.cc
  102. network_service.h
  103. network_service_network_delegate.cc
  104. network_service_network_delegate.h
  105. network_service_proxy_delegate.cc
  106. network_service_proxy_delegate.h
  107. network_service_proxy_delegate_unittest.cc
  108. network_service_unittest.cc
  109. nss_temp_certs_cache_chromeos.cc
  110. nss_temp_certs_cache_chromeos.h
  111. nss_temp_certs_cache_chromeos_unittest.cc
  112. OWNERS
  113. pending_callback_chain.cc
  114. pending_callback_chain.h
  115. pending_callback_chain_unittest.cc
  116. proxy_auto_config_library.cc
  117. proxy_auto_config_library.h
  118. proxy_auto_config_library_unittest.cc
  119. proxy_config_service_mojo.cc
  120. proxy_config_service_mojo.h
  121. proxy_config_service_mojo_unittest.cc
  122. proxy_lookup_request.cc
  123. proxy_lookup_request.h
  124. proxy_resolver_factory_mojo.cc
  125. proxy_resolver_factory_mojo.h
  126. proxy_resolver_factory_mojo_unittest.cc
  127. proxy_resolving_client_socket.cc
  128. proxy_resolving_client_socket.h
  129. proxy_resolving_client_socket_factory.cc
  130. proxy_resolving_client_socket_factory.h
  131. proxy_resolving_client_socket_unittest.cc
  132. proxy_resolving_socket_factory_mojo.cc
  133. proxy_resolving_socket_factory_mojo.h
  134. proxy_resolving_socket_mojo.cc
  135. proxy_resolving_socket_mojo.h
  136. proxy_resolving_socket_mojo_unittest.cc
  137. proxy_service_mojo.cc
  138. proxy_service_mojo.h
  139. proxy_service_mojo_unittest.cc
  140. README.md
  141. resolve_host_request.cc
  142. resolve_host_request.h
  143. restricted_cookie_manager.cc
  144. restricted_cookie_manager.h
  145. restricted_cookie_manager_unittest.cc
  146. sec_header_helpers.cc
  147. sec_header_helpers.h
  148. sec_header_helpers_unittest.cc
  149. session_cleanup_cookie_store.cc
  150. session_cleanup_cookie_store.h
  151. session_cleanup_cookie_store_unittest.cc
  152. socket_data_pump.cc
  153. socket_data_pump.h
  154. socket_data_pump_unittest.cc
  155. socket_factory.cc
  156. socket_factory.h
  157. ssl_config_service_mojo.cc
  158. ssl_config_service_mojo.h
  159. ssl_config_service_mojo_unittest.cc
  160. ssl_config_type_converter.cc
  161. ssl_config_type_converter.h
  162. tcp_bound_socket.cc
  163. tcp_bound_socket.h
  164. tcp_bound_socket_unittest.cc
  165. tcp_connected_socket.cc
  166. tcp_connected_socket.h
  167. tcp_server_socket.cc
  168. tcp_server_socket.h
  169. tcp_socket_unittest.cc
  170. test_chunked_data_pipe_getter.cc
  171. test_chunked_data_pipe_getter.h
  172. test_mojo_proxy_resolver_factory.cc
  173. test_mojo_proxy_resolver_factory.h
  174. tls_client_socket.cc
  175. tls_client_socket.h
  176. tls_client_socket_unittest.cc
  177. tls_socket_factory.cc
  178. tls_socket_factory.h
  179. transitional_url_loader_factory_owner.cc
  180. transitional_url_loader_factory_owner.h
  181. transitional_url_loader_factory_owner_unittest.cc
  182. udp_socket.cc
  183. udp_socket.h
  184. udp_socket_unittest.cc
  185. upload_progress_tracker.cc
  186. upload_progress_tracker.h
  187. upload_progress_tracker_unittest.cc
  188. url_loader.cc
  189. url_loader.h
  190. url_loader.md
  191. url_loader_factory.cc
  192. url_loader_factory.h
  193. url_loader_unittest.cc
  194. url_request_context_builder_mojo.cc
  195. url_request_context_builder_mojo.h
  196. url_request_context_builder_mojo_unittest.cc
  197. url_request_context_owner.cc
  198. url_request_context_owner.h
  199. web_bundle_chunked_buffer.cc
  200. web_bundle_chunked_buffer.h
  201. web_bundle_chunked_buffer_unittest.cc
  202. web_bundle_manager.cc
  203. web_bundle_manager.h
  204. web_bundle_manager_unittest.cc
  205. web_bundle_memory_quota_consumer.h
  206. web_bundle_url_loader_factory.cc
  207. web_bundle_url_loader_factory.h
  208. web_bundle_url_loader_factory_unittest.cc
  209. web_transport.cc
  210. web_transport.h
  211. web_transport_unittest.cc
  212. websocket.cc
  213. websocket.h
  214. websocket_factory.cc
  215. websocket_factory.h
  216. websocket_throttler.cc
  217. websocket_throttler.h
  218. websocket_throttler_unittest.cc
services/network/README.md

Network Service

This is a service for networking. It‘s meant to be oblivious to Chrome’s features. Some design goals

  • this only contains features that go over the network. e.g. no file loading, data URLs etc...
  • only the lowest-level of networking should be here. e.g. http, sockets, web sockets. Anything that is built on top of this should be in higher layers.
  • higher level web platform and browser features should be built outside of this code. Safe browsing, Service Worker, extensions, devtools etc... should not have hooks here. The only exception is when it's impossible for these features to function without some hooks in the network service. In that case, we add the minimal code required. Some examples included traffic shaping for devtools, CORB blocking, and CORS.
  • every PostTask, thread hop and process hop (IPC) should be counted carefully as they introduce delays which could harm this performance critical code.
  • NetworkContext and NetworkService are trusted interfaces that aren't meant to be sent to the renderer. Only the browser should have access to them.

See https://bugs.chromium.org/p/chromium/issues/detail?id=598073

See the design doc https://docs.google.com/document/d/1wAHLw9h7gGuqJNCgG1mP1BmLtCGfZ2pys-PdZQ1vg7M/edit?pref=2&pli=1#

Related docs

Where does the network service run?

Note: For more background about this section, see also Multi-process Architecture for an overview of the processes in Chromium.

The network service is designed as a Mojo service that in general doesn't need to be aware of which thread/process it runs on. The browser process launches the network service and decides whether to run it inside the browser process (in-process) or in a dedicated utility process (out-of-process).

The out-of-process configuration is preferred for isolation and stability, and is the default on most platforms. The in-process configuration is the default on Android because of some unresolved issues; see https://crbug.com/1049008. It can also be useful for debugging; for example, it‘s used in Chromium’s --single-process mode.

In the out-of-process case: The network service runs on the IO thread of the utility process (see this comment in content/utility/services.cc for why). The utility process houses only the network service, so there is nothing running on its main thread.

In the in-process case: The network service runs on its own dedicated thread in the browser process. Exception: on Chrome OS, it currently runs on the IO thread; see https://crbug.com/1086738.

How does the network service start?

In the out-of-process case: The browser creates the utility process and asks it to launch the network service. For the browser-side code, see GetNetworkService() in content/browser/network_service_instance_impl.cc. For the utility process code, see GetIOThreadServiceFactory in content/utility/services.cc. This calls RunNetworkService() which creates the network::NetworkService instance. For more background about Chromium's services architecture, see Mojo and Services.

In the in-process case: The browser process starts the network service. See CreateInProcessNetworkService() in content/browser/network_service_instance_impl.cc, which posts a task to create the network::NetworkService instance.

What happens if the network service crashes?

In the out-of-process case: If the network service crashes, it gets restarted in a new utility process. The goal is for the failure to be mostly recoverable. It is important to note that any URLLoaderFactories bound to the Network Service before it crashes become disconnected, and will no longer continue to work. Therefore it is useful to establish reconnection logic if it is detected that the URLLoaderFactory is no longer connected.

For example, a navigation request's URLLoaderFactory comes from StoragePartitionImpl::GetURLLoaderFactoryForBrowserProcessInternal in the browser process. This method has logic to detect if the URLLoaderFactory it would normally return is disconnected. In that case, it creates a new one which is used for all future navigation requests. Since most URLLoaderFactory users use factories that are not created out-of-band, and are provided by some service, reconnection logic is often implemented for free, and is usually not something to worry about.

In the in-process case: If the network service crashes in this case, of course, the entire browser crashes. This is one reason for the goal to always run it out-of-process.

Buildbot

The Network Service Linux buildbot runs browser tests with the network service in non-default but supported configurations. Ideally this bot would be on the CQ, but it is expensive and would affect CQ time, so it's on the main waterfall but not the CQ.

Its steps are:

  • network_service_in_process_browser_tests: Runs browser_tests with the network service in-process (--enable-features=NetworkServiceInProcess). This step is important because Chrome on Android runs with the network service in-process by default (https://crbug.com/1049008). However, browser_tests are not well-supported on Android (https://crbug.com/611756), so we run them on this Linux bot.
  • network_service_in_process_content_browsertests: Same as above but for content_browsertests. We might consider removing this from the bot, since the Android bots run content_browsertests which should give enough coverage.
  • network_service_web_request_proxy_browser_tests: Runs browser_tests while forcing the “network request proxying” code path that is taken when the browser has an extension installed that uses the Web Request API (--enable-features=ForceWebRequestProxyForTest). This step has caught bugs that would be Stable Release Blockers, so it's important to keep it.