Chromium Code Reviews| Index: net/http/http_cache.h |
| diff --git a/net/http/http_cache.h b/net/http/http_cache.h |
| index 2aae2fcf27e1cc0aed6fcbbe3b73eb3c3d293708..a23344a54fab75a2aa4b2786c2278932c7abfe7a 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; |
| + typedef std::list<Transaction*> TransactionList; |
| + typedef std::unordered_set<Transaction*> TransactionSet; |
|
jkarlin
2017/02/03 18:26:19
This and above should be using instead of typedef
shivanisha
2017/02/06 21:14:10
done.
|
| 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,9 @@ class NET_EXPORT HttpCache : public HttpTransactionFactory, |
| // cache entry. |
| ActiveEntry* ActivateEntry(disk_cache::Entry* disk_entry); |
| - // Deletes an ActiveEntry. |
| + // Deletes an ActiveEntry. Expects all of the transaction pointers to be |
| + // null and containers to be empty: writer, shared_writers, pending_queue |
|
jkarlin
2017/02/03 18:26:19
s/null/nullptr/
shivanisha
2017/02/06 21:14:10
done.
|
| + // and readers. |
| void DeactivateEntry(ActiveEntry* entry); |
| // Deletes an ActiveEntry using an exhaustive search. |
| @@ -392,6 +399,56 @@ 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); |
| + |
| + // Creates a SharedWriters object. The ownership of the network_transaction is |
| + // transferred to a new DataAccess object owned by the SharedWriters object. |
| + void CreateSharedWriters(Transaction* cacheTransaction, |
| + std::unique_ptr<HttpTransaction> network_transaction, |
| + RequestPriority priority); |
| + |
| + // 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_; |