Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(730)

Unified Diff: net/http/http_cache.h

Issue 455623003: stale-while-revalidate experimental implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add load flag LOAD_ASYNC_REVALIDATION. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/http/http_cache.h
diff --git a/net/http/http_cache.h b/net/http/http_cache.h
index 35bc5b2f7aa386532d3c6923f7730df00333d9d3..77a073dc01b2e3cbc369188321080a44a28dcee1 100644
--- a/net/http/http_cache.h
+++ b/net/http/http_cache.h
@@ -201,6 +201,16 @@ class NET_EXPORT HttpCache : public HttpTransactionFactory,
bypass_lock_for_test_ = true;
}
+ bool use_stale_while_revalidate() const {
+ return use_stale_while_revalidate_;
+ }
+
+ // Enable stale_while_revalidate functionality for testing purposes.
+ void set_use_stale_while_revalidate_for_testing(
+ bool use_stale_while_revalidate) {
+ use_stale_while_revalidate_ = use_stale_while_revalidate;
+ }
+
// HttpTransactionFactory implementation:
virtual int CreateTransaction(RequestPriority priority,
scoped_ptr<HttpTransaction>* trans) OVERRIDE;
@@ -237,9 +247,11 @@ class NET_EXPORT HttpCache : public HttpTransactionFactory,
friend class Transaction;
friend class ViewCacheHelper;
struct PendingOp; // Info for an entry under construction.
+ class AsyncValidation; // Encapsulates a single async revalidation.
typedef std::list<Transaction*> TransactionList;
typedef std::list<WorkItem*> WorkItemList;
+ typedef std::set<AsyncValidation*> AsyncValidationSet;
struct ActiveEntry {
explicit ActiveEntry(disk_cache::Entry* entry);
@@ -374,6 +386,14 @@ class NET_EXPORT HttpCache : public HttpTransactionFactory,
// Resumes processing the pending list of |entry|.
void ProcessPendingQueue(ActiveEntry* entry);
+ // Called by Transaction to perform an asynchronous revalidation. Creates a
+ // new independent transaction as a copy of the original.
+ void PerformAsyncValidation(const HttpRequestInfo& original_request,
+ const BoundNetLog& net_log);
+
+ // Remove |async_validation| from the |async_validations_| set and delete it.
+ void DeleteAsyncValidation(AsyncValidation* async_validation);
+
// Events (called via PostTask) ---------------------------------------------
void OnProcessPendingQueue(ActiveEntry* entry);
@@ -405,6 +425,10 @@ class NET_EXPORT HttpCache : public HttpTransactionFactory,
bool building_backend_;
bool bypass_lock_for_test_;
+ // true if the implementation of Cache-Control: stale-while-revalidate
+ // directive is enabled (either via command-line flag or experiment).
+ bool use_stale_while_revalidate_;
+
Mode mode_;
scoped_ptr<QuicServerInfoFactoryAdaptor> quic_server_info_factory_;
@@ -426,6 +450,10 @@ class NET_EXPORT HttpCache : public HttpTransactionFactory,
scoped_ptr<PlaybackCacheMap> playback_cache_map_;
+ // The set of async validations currently in progress. Invariant: all
+ // live AsyncValidation objects connected to this cache are in this set.
rvargas (doing something else) 2014/09/05 22:52:39 Isn't the invariant the expected behavior? Why doc
Adam Rice 2014/09/09 12:36:45 I have seen people do a lot of weird things in my
+ AsyncValidationSet async_validations_;
+
base::WeakPtrFactory<HttpCache> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(HttpCache);

Powered by Google App Engine
This is Rietveld 408576698