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

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

Issue 1719103002: CacheStorage: Expand cache.keys() method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 4 years, 4 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.cc
diff --git a/content/browser/cache_storage/cache_storage_cache.cc b/content/browser/cache_storage/cache_storage_cache.cc
index 6dc652e7d3d00d2807912fb8ed3ab82d673e9854..caff0ac893174cb5b10631797e93c6197c343489 100644
--- a/content/browser/cache_storage/cache_storage_cache.cc
+++ b/content/browser/cache_storage/cache_storage_cache.cc
@@ -451,7 +451,9 @@ void CacheStorageCache::BatchDidAllOperations(
callback->Run(CACHE_STORAGE_OK);
}
-void CacheStorageCache::Keys(const RequestsCallback& callback) {
+void CacheStorageCache::Keys(std::unique_ptr<ServiceWorkerFetchRequest> request,
+ const CacheStorageCacheQueryParams& options,
+ const RequestsCallback& callback) {
if (backend_state_ == BACKEND_CLOSED) {
callback.Run(CACHE_STORAGE_ERROR_STORAGE, std::unique_ptr<Requests>());
return;
@@ -459,6 +461,7 @@ void CacheStorageCache::Keys(const RequestsCallback& callback) {
scheduler_->ScheduleOperation(
base::Bind(&CacheStorageCache::KeysImpl, weak_ptr_factory_.GetWeakPtr(),
+ base::Passed(std::move(request)), options,
scheduler_->WrapCallbackToRunNext(callback)));
}
@@ -625,11 +628,18 @@ void CacheStorageCache::QueryCacheProcessNextEntry(
return;
}
- if (query_cache_results->options.ignore_search) {
- DCHECK(query_cache_results->request);
+ if (query_cache_results->request &&
+ !query_cache_results->request->url.is_empty()) {
disk_cache::Entry* entry(*iter);
- if (RemoveQueryParam(query_cache_results->request->url) !=
- RemoveQueryParam(GURL(entry->GetKey()))) {
+ GURL requestURL = query_cache_results->request->url;
+ GURL cachedURL = GURL(entry->GetKey());
+
+ if (query_cache_results->options.ignore_search) {
+ requestURL = RemoveQueryParam(requestURL);
+ cachedURL = RemoveQueryParam(cachedURL);
+ }
+
+ if (cachedURL != requestURL) {
QueryCacheProcessNextEntry(std::move(query_cache_results), iter + 1);
return;
}
@@ -1266,16 +1276,17 @@ void CacheStorageCache::DeleteDidOpenEntry(
callback.Run(CACHE_STORAGE_OK);
}
-void CacheStorageCache::KeysImpl(const RequestsCallback& callback) {
+void CacheStorageCache::KeysImpl(
+ std::unique_ptr<ServiceWorkerFetchRequest> request,
+ const CacheStorageCacheQueryParams& options,
+ const RequestsCallback& callback) {
DCHECK_NE(BACKEND_UNINITIALIZED, backend_state_);
if (backend_state_ != BACKEND_OPEN) {
callback.Run(CACHE_STORAGE_ERROR_STORAGE, std::unique_ptr<Requests>());
return;
}
- std::unique_ptr<ServiceWorkerFetchRequest> request(
- new ServiceWorkerFetchRequest);
- QueryCache(std::move(request), CacheStorageCacheQueryParams(),
+ QueryCache(std::move(request), options,
base::Bind(&CacheStorageCache::KeysDidQueryCache,
weak_ptr_factory_.GetWeakPtr(), callback));
}
« no previous file with comments | « content/browser/cache_storage/cache_storage_cache.h ('k') | content/browser/cache_storage/cache_storage_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698