1The network stack implements support for Content-Encodings using 2"source streams", which can be composed together and mutate all the incoming 3bytes from a URLRequestJob. Currently, the following streams are implemented: 4 5* gzip (handling "deflate" and "gzip" Content-Encodings) 6* brotli (handling "br" Content-Encoding) 7 8Source streams conceptually form a chain, with the URLRequestJob as both the 9beginning and end of the chain, meaning the URLRequestJob produces raw bytes at 10the end and consumes unencoded bytes at the beginning. For example, to support a 11hypothetical "Content-Encoding: bar,foo", streams would be arranged like so, 12with "X <-- Y" meaning "data flows from Y to X", "X reads data from Y", or 13"X is downstream from Y". 14 15 URLRequestJob <-- BarSourceStream <-- FooSourceStream <-- URLRequestJob 16 (URLRequestSourceStream) 17 18Here URLRequestJob pulls filtered bytes from its upstream, BarSourceStream, 19which pulls filtered bytes from FooSourceStream, which in turn pulls raw bytes 20from URLRequestJob. URLRequestSourceStream is the ultimate upstream, which 21produces the raw data. Every stream in the chain owns its upstream. In this 22case, the ultimate downstream, URLRequestJob, owns its upstream, 23BarSourceStream, which in turn owns FooSourceStream. FooSourceStream owns its 24upstream, URLRequestSourceStream. 25 26All source streams conform to the following interface (named SourceStream in the 27tree): 28 29 int Read(IOBuffer* dest_buffer, size_t buffer_size, 30 const OnReadCompleteCallback& callback); 31 32This function can return either synchronously or asynchronously via the supplied 33callback. The source stream chain is "pull-based", in that data does not 34propagate through the chain until requested by the final consumer of the 35filtered data. 36