Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: net/docs/life-of-a-url-request.md

Issue 1859793002: Include class relationship diagrams in network stack documentation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Put net_docs.py back for Cronet. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/docs/README.txt ('k') | net/docs/pools.dot » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 ![Object Relationship Diagram for URLRequest lifetime](url_request.svg)
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.
296 314
297 # Additional Topics 315 # Additional Topics
298 316
299 ## HTTP Cache 317 ## HTTP Cache
300 318
301 The HttpCache::Transaction sits between the URLRequestHttpJob and the 319 The HttpCache::Transaction sits between the URLRequestHttpJob and the
302 HttpNetworkTransaction, and implements the HttpTransaction interface, just like 320 HttpNetworkTransaction, and implements the HttpTransaction interface, just like
303 the HttpNetworkTransaction. The HttpCache::Transaction checks if a request can 321 the HttpNetworkTransaction. The HttpCache::Transaction checks if a request can
304 be served out of the cache. If a request needs to be revalidated, it handles 322 be served out of the cache. If a request needs to be revalidated, it handles
305 sending a 204 revalidation request over the network. It may also break a range 323 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
411 layer pools owns are actively in use, even when the higher layer pool considers 429 layer pools owns are actively in use, even when the higher layer pool considers
412 them idle. As a result, when a lower layer pool is at its connection limit and 430 them idle. As a result, when a lower layer pool is at its connection limit and
413 needs to make a new connection, it will ask any higher layer pools pools to 431 needs to make a new connection, it will ask any higher layer pools pools to
414 close an idle connection if they have one, so it can make a new connection. 432 close an idle connection if they have one, so it can make a new connection.
415 433
416 Since sockets in the higher layer pool are also in a group in the lower layer 434 Since sockets in the higher layer pool are also in a group in the lower layer
417 pool, they must have their own distinct group name. This is needed so that, for 435 pool, they must have their own distinct group name. This is needed so that, for
418 instance, SSL and HTTP connections won't be grouped together in the 436 instance, SSL and HTTP connections won't be grouped together in the
419 TcpClientSocketPool, which the SSLClientSocketPool sits on top of. 437 TcpClientSocketPool, which the SSLClientSocketPool sits on top of.
420 438
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 ![Object Relationship Diagram for Socket Pools](pools.svg)
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
421 ### SSL 466 ### SSL
422 467
423 When an SSL connection is needed, the ClientSocketPoolManager assembles the 468 When an SSL connection is needed, the ClientSocketPoolManager assembles the
424 parameters needed both to connect the TCP socket and establish an SSL 469 parameters needed both to connect the TCP socket and establish an SSL
425 connection. It then passes them to the SSLClientSocketPool, which creates 470 connection. It then passes them to the SSLClientSocketPool, which creates
426 an SSLConnectJob using them. The SSLConnectJob's first step is to call into the 471 an SSLConnectJob using them. The SSLConnectJob's first step is to call into the
427 TransportSocketPool to establish a TCP connection. 472 TransportSocketPool to establish a TCP connection.
428 473
429 Once a connection is established by the lower layered pool, the SSLConnectJob 474 Once a connection is established by the lower layered pool, the SSLConnectJob
430 then starts SSL negotiation. Once that's done, the SSL socket is passed back to 475 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
502 connection is established, the first usable connection goes to the highest 547 connection is established, the first usable connection goes to the highest
503 priority socket request. 548 priority socket request.
504 549
505 ## Non-HTTP Schemes 550 ## Non-HTTP Schemes
506 551
507 The URLRequestJobFactory has a ProtocolHander for each supported scheme. 552 The URLRequestJobFactory has a ProtocolHander for each supported scheme.
508 Non-HTTP URLRequests have their own ProtocolHandlers. Some are implemented in 553 Non-HTTP URLRequests have their own ProtocolHandlers. Some are implemented in
509 net/, (like FTP, file, and data, though the renderer handles some data URLs 554 net/, (like FTP, file, and data, though the renderer handles some data URLs
510 internally), and others are implemented in content/ or chrome (like blob, 555 internally), and others are implemented in content/ or chrome (like blob,
511 chrome, and chrome-extension). 556 chrome, and chrome-extension).
OLDNEW
« no previous file with comments | « net/docs/README.txt ('k') | net/docs/pools.dot » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698