Generally there’s a mojo::Remote proxy object in the consumer‘s process which also implements the network::mojom::Foo interface. The Mojo interfaces it provides are in the network::mojom namespace. The network service uses the namespace “network” for all its classes. The network service, which lives in //services/network/, wraps //net/ objects, and provides cross-process network APIs and their implementations for the rest of Chrome. The NetworkDelegate is an object pointed to by the URLRequestContext and shared by all requests, and includes callbacks corresponding to most of the URLRequest::Delegate's callbacks, as well as an assortment of other methods. The URLRequest::Delegate interface consists of a small set of callbacks needed to let the embedder drive a request forward. How many “Delegates”?Ī URLRequest informs the consumer of important events for a request using two main interfaces: the URLRequest::Delegate interface and the NetworkDelegate interface. This document does not mention either of these objects much, but at layers above the HttpStreamFactory, objects often grab their dependencies from the URLRequestContext, while the HttpStreamFactory and layers below it generally get their dependencies from the HttpNetworkSession. It also has non-owning pointers to the network stack objects that more directly deal with sockets. It owns the HttpStreamFactory, the socket pools, and the HTTP/2 and QUIC session pools. ![]() The HttpNetworkSession is another major network stack object. Each URLRequest tracks a single request across all redirects until an error occurs, it's canceled, or a final response is received, with a (possibly empty) body. URLs for other schemes, such as file, filesystem, blob, chrome, and data, are managed completely outside of //net. It manages loading URLs with the http, https, ws, and wss schemes. The URLRequest is the main interface used by direct consumers of the network stack. The primary use of the URLRequestContext is to create URLRequest objects using URLRequestContext::CreateRequest(). Creating a context is a rather complicated process usually managed by URLRequestContextBuilder. The context must outlive all requests that use it. The context has non-owning pointers to everything needed to create and issue a URLRequest. The top-level network stack object is the URLRequestContext. ![]() Whenever a class name in this doc has no namespace, it can generally be assumed it's in //net/ and is in the net namespace. The network stack is located in //net/ in the Chrome repo, and uses the namespace “net”. If you notice any inaccuracies in this document, or feel that things could be better explained, please do not hesitate to submit patches. It starts by walking through how a basic request issued by another process works its way through the network stack, and then moves on to discuss how various components plug in. It's particularly targeted at people new to the Chrome network stack, but should also be useful for team members who may be experts at some parts of the stack, but are largely unfamiliar with other components. This document assumes that requests for URLs are mediated through the browser's Network Service, and focuses on all the layers below the Network Service, including key points of integration. Networking in the browser ranges from high level Javascript APIs like fetch(), all the way down to writing encrypted bytes on a socket. This document gives an overview of the browser's lower-layers for networking.
0 Comments
Leave a Reply. |