Commit 35c70ff6 authored by Matt Falkenhagen's avatar Matt Falkenhagen Committed by Commit Bot

network service: Expand README.

Add more information about the process/threading model of network
service and how it starts.

Change-Id: I0669d6d4cb96eddff494f7c08ac7db575a628cee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2215523
Commit-Queue: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#772137}
parent 3d449d4a
...@@ -12,7 +12,7 @@ Some design goals ...@@ -12,7 +12,7 @@ Some design goals
not have hooks here. The only exception is when it's impossible for these 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 features to function without some hooks in the network service. In that
case, we add the minimal code required. Some examples included traffic case, we add the minimal code required. Some examples included traffic
shaping for devtools and CORB blocking. shaping for devtools, CORB blocking, and CORS.
* every PostTask, thread hop and process hop (IPC) should be counted carefully * every PostTask, thread hop and process hop (IPC) should be counted carefully
as they introduce delays which could harm this performance critical code. as they introduce delays which could harm this performance critical code.
* `NetworkContext` and `NetworkService` are trusted interfaces that aren't * `NetworkContext` and `NetworkService` are trusted interfaces that aren't
...@@ -28,6 +28,60 @@ https://docs.google.com/document/d/1wAHLw9h7gGuqJNCgG1mP1BmLtCGfZ2pys-PdZQ1vg7M/ ...@@ -28,6 +28,60 @@ https://docs.google.com/document/d/1wAHLw9h7gGuqJNCgG1mP1BmLtCGfZ2pys-PdZQ1vg7M/
[URLLoader](url_loader.md) [URLLoader](url_loader.md)
# Where does the network service run?
> Note: For more background about this section, see also [Multi-process
Architecture](https://www.chromium.org/developers/design-documents/multi-process-architecture)
for an overview of the processes in Chromium.
The network service is designed as a [Mojo service](/docs/mojo_and_services.md)
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`](https://www.chromium.org/developers/design-documents/process-models)
mode.
*In the out-of-process case*: The network service runs on the [IO
thread](/docs/threading_and_tasks.md) of the utility process. 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](/docs/mojo_and_services.md).
*In the in-process case*: The browser starts the network service on the IO
thread. 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:
some in-flight requests may fail, but any tabs open will continue to function
and later requests will succeed.
*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 # Buildbot
The [Network Service The [Network Service
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment