This directory contains the implementation for Compression Dictionary Transport with Shared Brotli.
When NetworkContextParams.shared_dictionary_enabled
flag is enabled, a SharedDictionaryManager
is attached to a NetworkContext
. The SharedDictionaryManager
manages SharedDictionaryStorage
, which is created per net::NetworkIsolationKey
. SharedDictionaryStorage
manages compression dictionaries, also known as shared dictionaries.
We have two implementations of SharedDictionaryManager
, SharedDictionaryStorage
, SharedDictionaryWriter
and SharedDictionary
. Classes with an “InMemory” suffix in their name are for incognito mode. And classes with an “OnDisk” suffix are for normal Profiles. (Note: We are currently actively implementing “OnDisk” classes.)
When CorsURLLoader
receives a HTTP response, it calls SharedDictionaryStorage::MaybeCreateWriter()
. If the received header contans an appropriate 'use-as-dictionary'
header, this method returns a SharedDictionaryWriter
. CorsURLLoader
then creates a SharedDictionaryDataPipeWriter
to write the response body to the storege via the SharedDictionaryWriter
.
SharedDictionaryWriterInMemory
just copies the response body to the memory. SharedDictionaryWriterOnDisk
writes the response body to the disk cache using SharedDictionaryDiskCache
class.
When SharedDictionaryWriter
finishes writing the body, SharedDictionaryStorage::OnDictionaryWritten
will be called. SharedDictionaryStorageInMemory
just keeps the dictionary information in the memory. SharedDictionaryStorageOnDisk
will stores the dictionary information to the storage database (Note: Not implemented yet).
We currently set a size limit of 100 MiB per dictionary. This is intended to protect the network services from out-of-memory denial-of-service attacks.
The feature of Compression dictionary transport with Shared Brotli is currently controlled by two flags.
CompressionDictionaryTransportBackend
CompressionDictionaryTransport
<link rel=compression-dictionary>
in the document HTML or “Link: rel=compression-dictionary
” in the HTTP response header. (Note: Not implemented yet.)rel=dictionary
was used instead of rel=compression-dictionary
.