| OLD | NEW |
| 1 # Life of a URLRequest | 1 # Life of a URLRequest |
| 2 | 2 |
| 3 This document is intended as an overview of the core layers of the network | 3 This document is intended as an overview of the core layers of the network |
| 4 stack, their basic responsibilities, how they fit together, and where some of | 4 stack, their basic responsibilities, how they fit together, and where some of |
| 5 the pain points are, without going into too much detail. Though it touches a | 5 the pain points are, without going into too much detail. Though it touches a |
| 6 bit on child processes and the content/loader stack, the focus is on net/ | 6 bit on child processes and the content/loader stack, the focus is on net/ |
| 7 itself. | 7 itself. |
| 8 | 8 |
| 9 It's particularly targeted at people new to the Chrome network stack, but | 9 It's particularly targeted at people new to the Chrome network stack, but |
| 10 should also be useful for team members who may be experts at some parts of the | 10 should also be useful for team members who may be experts at some parts of the |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 request, the response is uncompressed, no matching entry in the cache, and there | 96 request, the response is uncompressed, no matching entry in the cache, and there |
| 97 are no idle sockets connected to the server in the socket pool. | 97 are no idle sockets connected to the server in the socket pool. |
| 98 | 98 |
| 99 Continuing with a "simple" URLRequest, here's a bit more detail on how things | 99 Continuing with a "simple" URLRequest, here's a bit more detail on how things |
| 100 work. | 100 work. |
| 101 | 101 |
| 102 ### Request starts in a child process | 102 ### Request starts in a child process |
| 103 | 103 |
| 104 Summary: | 104 Summary: |
| 105 | 105 |
| 106 * ResourceDispatcher creates an IPCResourceLoaderBridge. | 106 * A user (e.g. the WebURLLoaderImpl for Blink) asks ResourceDispatcher to start |
| 107 * The IPCResourceLoaderBridge asks ResourceDispatcher to start the request. | 107 the request. |
| 108 * ResourceDispatcher sends an IPC to the ResourceDispatcherHost in the | 108 * ResourceDispatcher sends an IPC to the ResourceDispatcherHost in the |
| 109 browser process. | 109 browser process. |
| 110 | 110 |
| 111 Chrome has a single browser process, which handles network requests and tab | 111 Chrome has a single browser process, which handles network requests and tab |
| 112 management, among other things, and multiple child processes, which are | 112 management, among other things, and multiple child processes, which are |
| 113 generally sandboxed so can't send out network requests directly. There are | 113 generally sandboxed so can't send out network requests directly. There are |
| 114 multiple types of child processes (renderer, GPU, plugin, etc). The renderer | 114 multiple types of child processes (renderer, GPU, plugin, etc). The renderer |
| 115 processes are the ones that layout webpages and run HTML. | 115 processes are the ones that layout webpages and run HTML. |
| 116 | 116 |
| 117 Each child process has at most one ResourceDispatcher, which is responsible for | 117 Each child process has at most one ResourceDispatcher, which is responsible for |
| 118 all URL request-related communication with the browser process. When something | 118 all URL request-related communication with the browser process. When something |
| 119 in another process needs to issue a resource request, it calls into the | 119 in another process needs to issue a resource request, it calls into the |
| 120 ResourceDispatcher, which returns an IPCResourceLoaderBridge to the caller. | 120 ResourceDispatcher to start a request. A RequestPeer is passed in to receive |
| 121 The caller uses the bridge to start a request. When started, the | 121 messages related to the request. When started, the |
| 122 ResourceDispatcher assigns the request a per-renderer ID, and then sends the | 122 ResourceDispatcher assigns the request a per-renderer ID, and then sends the |
| 123 ID, along with all information needed to issue the request, to the | 123 ID, along with all information needed to issue the request, to the |
| 124 ResourceDispatcherHost in the browser process. | 124 ResourceDispatcherHost in the browser process. |
| 125 | 125 |
| 126 ### ResourceDispatcherHost sets up the request in the browser process | 126 ### ResourceDispatcherHost sets up the request in the browser process |
| 127 | 127 |
| 128 Summary: | 128 Summary: |
| 129 | 129 |
| 130 * ResourceDispatcherHost uses the URLRequestContext to create the URLRequest. | 130 * ResourceDispatcherHost uses the URLRequestContext to create the URLRequest. |
| 131 * ResourceDispatcherHost creates a ResourceLoader and a chain of | 131 * ResourceDispatcherHost creates a ResourceLoader and a chain of |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 response headers, and then passes them up through both the | 236 response headers, and then passes them up through both the |
| 237 HttpNetworkTransaction and HttpCache::Transaction to the URLRequestHttpJob. The | 237 HttpNetworkTransaction and HttpCache::Transaction to the URLRequestHttpJob. The |
| 238 URLRequestHttpJob saves any cookies, if needed, and then passes the headers up | 238 URLRequestHttpJob saves any cookies, if needed, and then passes the headers up |
| 239 to the URLRequest and on to the ResourceLoader. | 239 to the URLRequest and on to the ResourceLoader. |
| 240 | 240 |
| 241 The ResourceLoader passes them through the chain of ResourceHandlers, and then | 241 The ResourceLoader passes them through the chain of ResourceHandlers, and then |
| 242 they make their way to the AsyncResourceHandler. The AsyncResourceHandler uses | 242 they make their way to the AsyncResourceHandler. The AsyncResourceHandler uses |
| 243 the renderer process ID ("child ID") to figure out which process the request | 243 the renderer process ID ("child ID") to figure out which process the request |
| 244 was associated with, and then sends the headers along with the request ID to | 244 was associated with, and then sends the headers along with the request ID to |
| 245 that process's ResourceDispatcher. The ResourceDispatcher uses the ID to | 245 that process's ResourceDispatcher. The ResourceDispatcher uses the ID to |
| 246 figure out which IPCResourceLoaderBridge the headers should be sent to, which | 246 figure out which RequestPeer the headers should be sent to, which |
| 247 sends them on to whatever created the IPCResourceLoaderBridge in the first | 247 sends them on to the RequestPeer. |
| 248 place. | |
| 249 | 248 |
| 250 ### Response body is read | 249 ### Response body is read |
| 251 | 250 |
| 252 Summary: | 251 Summary: |
| 253 | 252 |
| 254 * AsyncResourceHandler allocates a 512k ring buffer of shared memory to read | 253 * AsyncResourceHandler allocates a 512k ring buffer of shared memory to read |
| 255 the body of the request. | 254 the body of the request. |
| 256 * AsyncResourceHandler tells the ResourceLoader to read the response body to | 255 * AsyncResourceHandler tells the ResourceLoader to read the response body to |
| 257 the buffer, 32kB at a time. | 256 the buffer, 32kB at a time. |
| 258 * AsyncResourceHandler informs the ResourceDispatcher of each read using | 257 * AsyncResourceHandler informs the ResourceDispatcher of each read using |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 connection is established, the first usable connection goes to the highest | 502 connection is established, the first usable connection goes to the highest |
| 504 priority socket request. | 503 priority socket request. |
| 505 | 504 |
| 506 ## Non-HTTP Schemes | 505 ## Non-HTTP Schemes |
| 507 | 506 |
| 508 The URLRequestJobFactory has a ProtocolHander for each supported scheme. | 507 The URLRequestJobFactory has a ProtocolHander for each supported scheme. |
| 509 Non-HTTP URLRequests have their own ProtocolHandlers. Some are implemented in | 508 Non-HTTP URLRequests have their own ProtocolHandlers. Some are implemented in |
| 510 net/, (like FTP, file, and data, though the renderer handles some data URLs | 509 net/, (like FTP, file, and data, though the renderer handles some data URLs |
| 511 internally), and others are implemented in content/ or chrome (like blob, | 510 internally), and others are implemented in content/ or chrome (like blob, |
| 512 chrome, and chrome-extension). | 511 chrome, and chrome-extension). |
| OLD | NEW |