[go: nahoru, domu]

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