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

Unified Diff: content/browser/cache_storage/cache_storage_cache.h

Issue 2137833002: CacheStorage: Introduce QueryCache algorithm. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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: content/browser/cache_storage/cache_storage_cache.h
diff --git a/content/browser/cache_storage/cache_storage_cache.h b/content/browser/cache_storage/cache_storage_cache.h
index 787e13ad24abb05254174bbcc78b7206de646028..ad302ec5624b9a5581b59e5a07b159465c672fa1 100644
--- a/content/browser/cache_storage/cache_storage_cache.h
+++ b/content/browser/cache_storage/cache_storage_cache.h
@@ -61,6 +61,11 @@ class CONTENT_EXPORT CacheStorageCache {
base::Callback<void(CacheStorageError, std::unique_ptr<Requests>)>;
using SizeCallback = base::Callback<void(int64_t)>;
+ struct QueryCacheResults;
+ using QueryCacheResultsCallback =
+ base::Callback<void(CacheStorageError,
+ std::unique_ptr<QueryCacheResults>)>;
+
enum EntryIndex { INDEX_HEADERS = 0, INDEX_RESPONSE_BODY, INDEX_SIDE_DATA };
static std::unique_ptr<CacheStorageCache> CreateMemoryCache(
@@ -157,8 +162,6 @@ class CONTENT_EXPORT CacheStorageCache {
friend class TestCacheStorageCache;
struct OpenAllEntriesContext;
- struct MatchAllContext;
- struct KeysContext;
struct PutContext;
// The backend progresses from uninitialized, to open, to closed, and cannot
@@ -195,6 +198,21 @@ class CONTENT_EXPORT CacheStorageCache {
const OpenAllEntriesCallback& callback,
int rv);
+ void QueryCache(std::unique_ptr<ServiceWorkerFetchRequest> request,
+ const CacheStorageCacheQueryParams& options,
+ const QueryCacheResultsCallback& callback);
+ void QueryCacheDidOpenAllEntries(
+ std::unique_ptr<QueryCacheResults> query_cache_results,
+ std::unique_ptr<OpenAllEntriesContext> entries_context,
+ CacheStorageError error);
+ void QueryCacheProcessNextEntry(
+ std::unique_ptr<QueryCacheResults> query_cache_results,
+ const Entries::iterator& iter);
+ void QueryCacheDidReadMetadata(
+ std::unique_ptr<QueryCacheResults> query_cache_results,
+ const Entries::iterator& iter,
+ std::unique_ptr<CacheMetadata> metadata);
+
// Match callbacks
void MatchImpl(std::unique_ptr<ServiceWorkerFetchRequest> request,
const ResponseCallback& callback);
@@ -208,16 +226,13 @@ class CONTENT_EXPORT CacheStorageCache {
std::unique_ptr<CacheMetadata> headers);
// MatchAll callbacks
- void MatchAllImpl(std::unique_ptr<MatchAllContext> context);
- void MatchAllDidOpenAllEntries(
- std::unique_ptr<MatchAllContext> context,
- std::unique_ptr<OpenAllEntriesContext> entries_context,
- CacheStorageError error);
- void MatchAllProcessNextEntry(std::unique_ptr<MatchAllContext> context,
- const Entries::iterator& iter);
- void MatchAllDidReadMetadata(std::unique_ptr<MatchAllContext> context,
- const Entries::iterator& iter,
- std::unique_ptr<CacheMetadata> metadata);
+ void MatchAllImpl(std::unique_ptr<ServiceWorkerFetchRequest> request,
+ const CacheStorageCacheQueryParams& options,
+ const ResponsesCallback& callback);
+ void MatchAllDidQueryCache(
+ const ResponsesCallback& callback,
+ CacheStorageError error,
+ std::unique_ptr<QueryCacheResults> query_cache_results);
// WriteSideData callbacks
void WriteSideDataDidGetQuota(const ErrorCallback& callback,
@@ -308,15 +323,10 @@ class CONTENT_EXPORT CacheStorageCache {
// Keys callbacks.
void KeysImpl(const RequestsCallback& callback);
- void KeysDidOpenAllEntries(
- const RequestsCallback& callback,
- std::unique_ptr<OpenAllEntriesContext> entries_context,
- CacheStorageError error);
- void KeysProcessNextEntry(std::unique_ptr<KeysContext> keys_context,
- const Entries::iterator& iter);
- void KeysDidReadMetadata(std::unique_ptr<KeysContext> keys_context,
- const Entries::iterator& iter,
- std::unique_ptr<CacheMetadata> metadata);
+ void KeysDidQueryCache(
+ const RequestsCallback& callback,
+ CacheStorageError error,
+ std::unique_ptr<QueryCacheResults> query_cache_results);
void CloseImpl(const base::Closure& callback);
@@ -353,7 +363,14 @@ class CONTENT_EXPORT CacheStorageCache {
CacheStorageError error,
std::unique_ptr<Requests> requests);
void PendingSizeCallback(const SizeCallback& callback, int64_t size);
+ // TODO(zino): Do we really need this?
+ void PendingQueryCacheResultsCallback(
nhiroki 2016/07/20 15:44:17 You may be able to avoid this pattern after jkarli
zino 2016/07/24 10:14:04 Done.
+ const QueryCacheResultsCallback& callback,
+ CacheStorageError error,
+ std::unique_ptr<QueryCacheResults> results);
+ void PopulateRequestFromMetadata(const CacheMetadata& metadata,
+ ServiceWorkerFetchRequest* request);
void PopulateResponseMetadata(const CacheMetadata& metadata,
ServiceWorkerResponse* response);
std::unique_ptr<storage::BlobDataHandle> PopulateResponseBody(

Powered by Google App Engine
This is Rietveld 408576698