This CL adds a new class HttpCache::Writers which will implement multiple cache transactions reading from the network and writing to the cache enabling each of thos

Desktop / Chromium - shivanisha [chromium.org] - 14 July 2017 18:18 EDT

This CL adds a new class HttpCache::Writers which will implement multiple cache transactions reading from the network and writing to the cache enabling each of those transactions to drive reading the response body from the network. This ensures that a slow consumer does not starve other consumers of the same resource.

This CL implements the Writers class in isolation and does not create an instance or integrates it with HttpCache/HttpCache::Transaction. In a follow up CL which will be dependent on parallel validation CL (https://codereview.chromium.org/2721933002/), a Writer object will replace entry->writer. In case of transaction types that do not support shared writing like partial transactions, Writers will only contain one transaction at a time and will have is_exclusive set to true.

The flow of Read() call will be: URLRequestHttpJob -> HttpCache::Transaction::Read() -> HttpCache::Writers::Read()-> HttpNetworkTransaction::Read() HttpCache::Writers will invoke HC::T's callback after writing the read buffer to the cache successfully or on network read failure/ cache write failure. So, in essence, HttpCache::Writers::Read() abstracts away the DoNetworkRead* and DoCacheWriteData* functions of HC::T

HttpCache::Transaction that has invoked Read() is the |active_transaction_| and may be killed at any time by it's consumer.

When a transaction completes writing to the cache, either failure or success, it invokes HttpCache::DoneWritingToEntry as it does now which will invoke the required functionality in Writers. But If |active_transaction_| does not exist, Writers object invokes HttpCache::DoneWritingToEntry itself.

BUG=472740

Review-Url: https://codereview.chromium.org/2886483002 Cr-Commit-Position: refs/heads/master@{#486907}

c6582e1 This CL adds a new class HttpCache::Writers which will implement multiple cache transactions reading from the network and writing to the cache enabling each of those transactions to drive reading the response body from the network. This ensures that a slow consumer does not starve other consumers of the same resource.
net/BUILD.gn | 3 +
net/http/http_cache.h | 3 +
net/http/http_cache_lookup_manager_unittest.cc | 2 +-
net/http/http_cache_transaction.cc | 9 +-
net/http/http_cache_transaction.h | 8 +-
net/http/http_cache_unittest.cc | 20 +-
net/http/http_cache_writers.cc | 443 +++++++++++++++++
net/http/http_cache_writers.h | 227 +++++++++
net/http/http_cache_writers_unittest.cc | 664 +++++++++++++++++++++++++
net/http/http_transaction_test_util.cc | 77 ++-
net/http/http_transaction_test_util.h | 6 +-
net/url_request/url_request_job_unittest.cc | 104 +++-
12 files changed, 1514 insertions(+), 52 deletions(-)

Upstream: git.chromium.org


  • Share