| 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 0c9a85af10e9e1335df76d22b30cc8875c861830..9234b4bdc6c8c2c4389143e8b787e0f092d709fc 100644
|
| --- a/content/browser/cache_storage/cache_storage_cache.cc
|
| +++ b/content/browser/cache_storage/cache_storage_cache.cc
|
| @@ -243,10 +243,19 @@ struct CacheStorageCache::MatchAllContext {
|
|
|
| // The state needed to pass between CacheStorageCache::Keys callbacks.
|
| struct CacheStorageCache::KeysContext {
|
| - explicit KeysContext(const CacheStorageCache::RequestsCallback& callback)
|
| - : original_callback(callback), out_keys(new Requests()) {}
|
| + explicit KeysContext(scoped_ptr<ServiceWorkerFetchRequest> request,
|
| + const CacheStorageCacheQueryParams& match_params,
|
| + const CacheStorageCache::RequestsCallback& callback)
|
| + : request(std::move(request)),
|
| + options(match_params),
|
| + original_callback(callback),
|
| + out_keys(new Requests()) {}
|
| ~KeysContext() {}
|
|
|
| + scoped_ptr<ServiceWorkerFetchRequest> request;
|
| +
|
| + CacheStorageCacheQueryParams options;
|
| +
|
| // The callback passed to the Keys() function.
|
| RequestsCallback original_callback;
|
|
|
| @@ -408,7 +417,9 @@ void CacheStorageCache::BatchDidAllOperations(
|
| callback->Run(CACHE_STORAGE_OK);
|
| }
|
|
|
| -void CacheStorageCache::Keys(const RequestsCallback& callback) {
|
| +void CacheStorageCache::Keys(scoped_ptr<ServiceWorkerFetchRequest> request,
|
| + const CacheStorageCacheQueryParams& match_params,
|
| + const RequestsCallback& callback) {
|
| if (!LazyInitialize()) {
|
| callback.Run(CACHE_STORAGE_ERROR_STORAGE, scoped_ptr<Requests>());
|
| return;
|
| @@ -417,9 +428,12 @@ void CacheStorageCache::Keys(const RequestsCallback& callback) {
|
| RequestsCallback pending_callback =
|
| base::Bind(&CacheStorageCache::PendingRequestsCallback,
|
| weak_ptr_factory_.GetWeakPtr(), callback);
|
| - scheduler_->ScheduleOperation(base::Bind(&CacheStorageCache::KeysImpl,
|
| - weak_ptr_factory_.GetWeakPtr(),
|
| - pending_callback));
|
| +
|
| + scoped_ptr<KeysContext> keys_context(
|
| + new KeysContext(std::move(request), match_params, pending_callback));
|
| + scheduler_->ScheduleOperation(
|
| + base::Bind(&CacheStorageCache::KeysImpl, weak_ptr_factory_.GetWeakPtr(),
|
| + base::Passed(std::move(keys_context))));
|
| }
|
|
|
| void CacheStorageCache::Close(const base::Closure& callback) {
|
| @@ -1118,10 +1132,11 @@ void CacheStorageCache::DeleteDidOpenEntry(
|
| callback.Run(CACHE_STORAGE_OK);
|
| }
|
|
|
| -void CacheStorageCache::KeysImpl(const RequestsCallback& callback) {
|
| +void CacheStorageCache::KeysImpl(scoped_ptr<KeysContext> keys_context) {
|
| DCHECK_NE(BACKEND_UNINITIALIZED, backend_state_);
|
| if (backend_state_ != BACKEND_OPEN) {
|
| - callback.Run(CACHE_STORAGE_ERROR_STORAGE, scoped_ptr<Requests>());
|
| + keys_context->original_callback.Run(CACHE_STORAGE_ERROR_STORAGE,
|
| + scoped_ptr<Requests>());
|
| return;
|
| }
|
|
|
| @@ -1136,19 +1151,19 @@ void CacheStorageCache::KeysImpl(const RequestsCallback& callback) {
|
| // forever if you read data from a cache entry while enumerating.
|
|
|
| OpenAllEntries(base::Bind(&CacheStorageCache::KeysDidOpenAllEntries,
|
| - weak_ptr_factory_.GetWeakPtr(), callback));
|
| + weak_ptr_factory_.GetWeakPtr(),
|
| + base::Passed(std::move(keys_context))));
|
| }
|
|
|
| void CacheStorageCache::KeysDidOpenAllEntries(
|
| - const RequestsCallback& callback,
|
| + scoped_ptr<KeysContext> keys_context,
|
| scoped_ptr<OpenAllEntriesContext> entries_context,
|
| CacheStorageError error) {
|
| if (error != CACHE_STORAGE_OK) {
|
| - callback.Run(error, scoped_ptr<Requests>());
|
| + keys_context->original_callback.Run(error, scoped_ptr<Requests>());
|
| return;
|
| }
|
|
|
| - scoped_ptr<KeysContext> keys_context(new KeysContext(callback));
|
| keys_context->entries_context.swap(entries_context);
|
| Entries::iterator iter = keys_context->entries_context->entries.begin();
|
| KeysProcessNextEntry(std::move(keys_context), iter);
|
| @@ -1164,6 +1179,16 @@ void CacheStorageCache::KeysProcessNextEntry(
|
| return;
|
| }
|
|
|
| + if (keys_context->options.ignore_search) {
|
| + DCHECK(keys_context->request);
|
| + disk_cache::Entry* entry(*iter);
|
| + if (RemoveQueryParam(keys_context->request->url) !=
|
| + RemoveQueryParam(GURL(entry->GetKey()))) {
|
| + KeysProcessNextEntry(std::move(keys_context), iter + 1);
|
| + return;
|
| + }
|
| + }
|
| +
|
| ReadMetadata(*iter, base::Bind(&CacheStorageCache::KeysDidReadMetadata,
|
| weak_ptr_factory_.GetWeakPtr(),
|
| base::Passed(std::move(keys_context)), iter));
|
|
|