| Index: net/http/http_cache.h
|
| diff --git a/net/http/http_cache.h b/net/http/http_cache.h
|
| index 2aae2fcf27e1cc0aed6fcbbe3b73eb3c3d293708..f4e467594842bb03fac3e2fb9cb09cb563416879 100644
|
| --- a/net/http/http_cache.h
|
| +++ b/net/http/http_cache.h
|
| @@ -19,6 +19,7 @@
|
| #include <memory>
|
| #include <string>
|
| #include <unordered_map>
|
| +#include <unordered_set>
|
|
|
| #include "base/files/file_path.h"
|
| #include "base/macros.h"
|
| @@ -202,7 +203,7 @@ class NET_EXPORT HttpCache : public HttpTransactionFactory,
|
|
|
| // HttpTransactionFactory implementation:
|
| int CreateTransaction(RequestPriority priority,
|
| - std::unique_ptr<HttpTransaction>* trans) override;
|
| + std::unique_ptr<HttpTransaction>* transaction) override;
|
| HttpCache* GetCache() override;
|
| HttpNetworkSession* GetSession() override;
|
|
|
| @@ -229,15 +230,17 @@ class NET_EXPORT HttpCache : public HttpTransactionFactory,
|
| kNumCacheEntryDataIndices
|
| };
|
|
|
| + class DataAccess;
|
| + class SharedWriters;
|
| + class Transaction;
|
| + using TransactionList = std::list<Transaction*>;
|
| + using TransactionSet = std::unordered_set<Transaction*>;
|
| class MetadataWriter;
|
| class QuicServerInfoFactoryAdaptor;
|
| - class Transaction;
|
| class WorkItem;
|
| - friend class Transaction;
|
| friend class ViewCacheHelper;
|
| struct PendingOp; // Info for an entry under construction.
|
|
|
| - typedef std::list<Transaction*> TransactionList;
|
| typedef std::list<std::unique_ptr<WorkItem>> WorkItemList;
|
|
|
| struct ActiveEntry {
|
| @@ -245,8 +248,10 @@ class NET_EXPORT HttpCache : public HttpTransactionFactory,
|
| ~ActiveEntry();
|
|
|
| disk_cache::Entry* disk_entry;
|
| + // Either writer or shared_writers will be non-null at any point in time.
|
| Transaction* writer;
|
| - TransactionList readers;
|
| + std::unique_ptr<SharedWriters> shared_writers;
|
| + TransactionSet readers;
|
| TransactionList pending_queue;
|
| bool will_process_pending_queue;
|
| bool doomed;
|
| @@ -302,7 +307,8 @@ class NET_EXPORT HttpCache : public HttpTransactionFactory,
|
| // cache entry.
|
| ActiveEntry* ActivateEntry(disk_cache::Entry* disk_entry);
|
|
|
| - // Deletes an ActiveEntry.
|
| + // Deletes an ActiveEntry. Expects writer to be nullptr and containers to be
|
| + // empty: shared_writers, pending_queue and readers.
|
| void DeactivateEntry(ActiveEntry* entry);
|
|
|
| // Deletes an ActiveEntry using an exhaustive search.
|
| @@ -392,6 +398,50 @@ class NET_EXPORT HttpCache : public HttpTransactionFactory,
|
| // Processes the backend creation notification.
|
| void OnBackendCreated(int result, PendingOp* pending_op);
|
|
|
| + // Destroys the entry and any pending queue transactions' callbacks are
|
| + // invoked with ERR_CACHE_RACE that restarts their state machine.
|
| + void DestroyEntryRestartPendingQueue(ActiveEntry* entry);
|
| +
|
| + // Dooms the entry and any pending queue transactions' callbacks are
|
| + // invoked with ERR_CACHE_RACE that restarts their state machine.
|
| + void DoomEntryRestartPendingQueue(const std::string& key, ActiveEntry* entry);
|
| +
|
| + // Writes response info to entry.
|
| + int WriteResponseInfo(ActiveEntry* entry,
|
| + const HttpResponseInfo* response,
|
| + CompletionCallback& callback,
|
| + bool truncated,
|
| + int* io_buf_len);
|
| +
|
| + // Checks if the response is completed based on content length.
|
| + bool IsResponseCompleted(const ActiveEntry* entry,
|
| + const HttpResponseInfo* response);
|
| +
|
| + // Returns true if we should bother attempting to resume this request if it is
|
| + // aborted while in progress. If |has_data| is true, the size of the stored
|
| + // data is considered for the result.
|
| + bool CanResumeEntry(bool has_data,
|
| + const std::string& method,
|
| + const HttpResponseInfo* response,
|
| + ActiveEntry* entry);
|
| +
|
| + // Response data completely written to the cache successfully, or
|
| + // Response data could not be written to the cache successfully, or
|
| + // Response data could not be read from the network successfully.
|
| + // Success is true if the entry was marked as truncated successfully.
|
| + // destroyed is set to true when the calling SharedWiters object is reset.
|
| + void ResponseDoneSharedWriters(ActiveEntry* entry,
|
| + bool success,
|
| + bool* destroyed);
|
| +
|
| + // Resets SharedWriters if entry contains an empty SharedWriters object and
|
| + // calls ProcessPendingQueue.
|
| + void ResetSharedWritersProcessPendingQueue(ActiveEntry* entry);
|
| + void ResetSharedWriters(ActiveEntry* entry);
|
| +
|
| + void RemovedSharedWriterTransaction(Transaction* transaction,
|
| + ActiveEntry* entry);
|
| +
|
| // Variables ----------------------------------------------------------------
|
|
|
| NetLog* net_log_;
|
|
|