| 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 ResourceLoader tells the ResourceHandlers, and the AsyncResourceHandler tells | 286 ResourceLoader tells the ResourceHandlers, and the AsyncResourceHandler tells |
| 287 the ResourceDispatcher the request is complete. The RDH then deletes | 287 the ResourceDispatcher the request is complete. The RDH then deletes |
| 288 ResourceLoader, which deletes the URLRequest and ResourceHandler chain. | 288 ResourceLoader, which deletes the URLRequest and ResourceHandler chain. |
| 289 | 289 |
| 290 When the HttpNetworkTransaction is being torn down, it figures out if the | 290 When the HttpNetworkTransaction is being torn down, it figures out if the |
| 291 socket is reusable. If not, it tells the HttpBasicStream to close the socket. | 291 socket is reusable. If not, it tells the HttpBasicStream to close the socket. |
| 292 Either way, the ClientSocketHandle returns the socket is then returned to the | 292 Either way, the ClientSocketHandle returns the socket is then returned to the |
| 293 socket pool, either for reuse or so the socket pool knows it has another free | 293 socket pool, either for reuse or so the socket pool knows it has another free |
| 294 socket slot. | 294 socket slot. |
| 295 | 295 |
| 296 ### Object Relationships and Ownership | |
| 297 | |
| 298 A sample of the object relationships involved in the above process is | |
| 299 diagramed here: | |
| 300 | |
| 301  | |
| 302 | |
| 303 There are a couple of points in the above diagram that do not come | |
| 304 clear visually: | |
| 305 | |
| 306 * The method that generates the filter chain that is hung off the | |
| 307 URLRequestJob is declared on URLRequestJob, but the only current | |
| 308 implementation of it is on URLRequestHttpJob, so the generation is | |
| 309 shown as happening from that class. | |
| 310 * HttpTransactions of different types are layered; i.e. a | |
| 311 HttpCache::Transaction contains a pointer to an HttpTransaction, but | |
| 312 that pointed-to HttpTransaction generally is an | |
| 313 HttpNetworkTransaction. | |
| 314 | 296 |
| 315 # Additional Topics | 297 # Additional Topics |
| 316 | 298 |
| 317 ## HTTP Cache | 299 ## HTTP Cache |
| 318 | 300 |
| 319 The HttpCache::Transaction sits between the URLRequestHttpJob and the | 301 The HttpCache::Transaction sits between the URLRequestHttpJob and the |
| 320 HttpNetworkTransaction, and implements the HttpTransaction interface, just like | 302 HttpNetworkTransaction, and implements the HttpTransaction interface, just like |
| 321 the HttpNetworkTransaction. The HttpCache::Transaction checks if a request can | 303 the HttpNetworkTransaction. The HttpCache::Transaction checks if a request can |
| 322 be served out of the cache. If a request needs to be revalidated, it handles | 304 be served out of the cache. If a request needs to be revalidated, it handles |
| 323 sending a 204 revalidation request over the network. It may also break a range | 305 sending a 204 revalidation request over the network. It may also break a range |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 layer pools owns are actively in use, even when the higher layer pool considers | 411 layer pools owns are actively in use, even when the higher layer pool considers |
| 430 them idle. As a result, when a lower layer pool is at its connection limit and | 412 them idle. As a result, when a lower layer pool is at its connection limit and |
| 431 needs to make a new connection, it will ask any higher layer pools pools to | 413 needs to make a new connection, it will ask any higher layer pools pools to |
| 432 close an idle connection if they have one, so it can make a new connection. | 414 close an idle connection if they have one, so it can make a new connection. |
| 433 | 415 |
| 434 Since sockets in the higher layer pool are also in a group in the lower layer | 416 Since sockets in the higher layer pool are also in a group in the lower layer |
| 435 pool, they must have their own distinct group name. This is needed so that, for | 417 pool, they must have their own distinct group name. This is needed so that, for |
| 436 instance, SSL and HTTP connections won't be grouped together in the | 418 instance, SSL and HTTP connections won't be grouped together in the |
| 437 TcpClientSocketPool, which the SSLClientSocketPool sits on top of. | 419 TcpClientSocketPool, which the SSLClientSocketPool sits on top of. |
| 438 | 420 |
| 439 ### Socket Pool Class Relationships | |
| 440 | |
| 441 The relationships between the important classes in the socket pools is | |
| 442 shown diagrammatically for the lowest layer socket pool | |
| 443 (TransportSocketPool) below. | |
| 444 | |
| 445  | |
| 446 | |
| 447 The ClientSocketPoolBase is a template class templatized on the class | |
| 448 containing the parameters for the appropriate type of socket (in this | |
| 449 case TransportSocketParams). It contains a pointer to the | |
| 450 ClientSocketPoolBaseHelper, which contains all the type-independent | |
| 451 machinery of the socket pool. | |
| 452 | |
| 453 When socket pools are initialized, they in turn initialize their | |
| 454 templatized ClientSocketPoolBase member with an object with which it | |
| 455 should create connect jobs. That object must derive from | |
| 456 ClientSocketPoolBase::ConnectJobFactory templatized by the same type | |
| 457 as the ClientSocketPoolBase. (In the case of the diagram above, that | |
| 458 object is a TransportConnectJobFactory, which derives from | |
| 459 ClientSocketPoolBase::ConnectJobFactory<TransportSocketParams>.) | |
| 460 Internally, that object is wrapped in a type-unsafe wrapper | |
| 461 (ClientSocketPoolBase::ConnectJobFactoryAdaptor) so that it can be | |
| 462 passed to the initialization of the ClientSocketPoolBaseHelper. This | |
| 463 allows the helper to create connect jobs while preserving a type-safe | |
| 464 API to the initialization of the socket pool. | |
| 465 | |
| 466 ### SSL | 421 ### SSL |
| 467 | 422 |
| 468 When an SSL connection is needed, the ClientSocketPoolManager assembles the | 423 When an SSL connection is needed, the ClientSocketPoolManager assembles the |
| 469 parameters needed both to connect the TCP socket and establish an SSL | 424 parameters needed both to connect the TCP socket and establish an SSL |
| 470 connection. It then passes them to the SSLClientSocketPool, which creates | 425 connection. It then passes them to the SSLClientSocketPool, which creates |
| 471 an SSLConnectJob using them. The SSLConnectJob's first step is to call into the | 426 an SSLConnectJob using them. The SSLConnectJob's first step is to call into the |
| 472 TransportSocketPool to establish a TCP connection. | 427 TransportSocketPool to establish a TCP connection. |
| 473 | 428 |
| 474 Once a connection is established by the lower layered pool, the SSLConnectJob | 429 Once a connection is established by the lower layered pool, the SSLConnectJob |
| 475 then starts SSL negotiation. Once that's done, the SSL socket is passed back to | 430 then starts SSL negotiation. Once that's done, the SSL socket is passed back to |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 connection is established, the first usable connection goes to the highest | 502 connection is established, the first usable connection goes to the highest |
| 548 priority socket request. | 503 priority socket request. |
| 549 | 504 |
| 550 ## Non-HTTP Schemes | 505 ## Non-HTTP Schemes |
| 551 | 506 |
| 552 The URLRequestJobFactory has a ProtocolHander for each supported scheme. | 507 The URLRequestJobFactory has a ProtocolHander for each supported scheme. |
| 553 Non-HTTP URLRequests have their own ProtocolHandlers. Some are implemented in | 508 Non-HTTP URLRequests have their own ProtocolHandlers. Some are implemented in |
| 554 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 |
| 555 internally), and others are implemented in content/ or chrome (like blob, | 510 internally), and others are implemented in content/ or chrome (like blob, |
| 556 chrome, and chrome-extension). | 511 chrome, and chrome-extension). |
| OLD | NEW |