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 3284b658000fe4b8e9ffc24e6141aacab98b4b71..65c5636e99d85d1be81296a7367571f4893c0481 100644 |
--- a/content/browser/cache_storage/cache_storage_cache.h |
+++ b/content/browser/cache_storage/cache_storage_cache.h |
@@ -11,6 +11,7 @@ |
#include "base/files/file_path.h" |
#include "base/id_map.h" |
#include "base/memory/ref_counted.h" |
+#include "base/memory/scoped_vector.h" |
#include "base/memory/weak_ptr.h" |
#include "content/common/cache_storage/cache_storage_types.h" |
#include "content/common/service_worker/service_worker_types.h" |
@@ -46,6 +47,11 @@ class CONTENT_EXPORT CacheStorageCache |
base::Callback<void(CacheStorageError, |
scoped_ptr<ServiceWorkerResponse>, |
scoped_ptr<storage::BlobDataHandle>)>; |
+ using Responses = std::vector<ServiceWorkerResponse>; |
+ using ResponsesCallback = |
+ base::Callback<void(CacheStorageError, |
+ scoped_ptr<Responses>, |
+ ScopedVector<storage::BlobDataHandle>)>; |
jkarlin
2015/08/06 15:11:13
Likewise, please make this a scoped_ptr<std::vecto
nhiroki
2015/08/07 13:12:16
Done.
|
using Requests = std::vector<ServiceWorkerFetchRequest>; |
using RequestsCallback = |
base::Callback<void(CacheStorageError, scoped_ptr<Requests>)>; |
@@ -66,6 +72,10 @@ class CONTENT_EXPORT CacheStorageCache |
void Match(scoped_ptr<ServiceWorkerFetchRequest> request, |
const ResponseCallback& callback); |
+ // Returns CACHE_STORAGE_OK and all responses in this cache. If there are no |
+ // responses, returns CACHE_STORAGE_OK and an empty vector. |
+ void MatchAll(const ResponsesCallback& callback); |
+ |
// Runs given batch operations. This corresponds to the Batch Cache Operations |
// algorithm in the spec. |
// |
@@ -104,6 +114,8 @@ class CONTENT_EXPORT CacheStorageCache |
friend class base::RefCounted<CacheStorageCache>; |
friend class TestCacheStorageCache; |
+ struct OpenAllEntriesContext; |
+ struct MatchAllContext; |
struct KeysContext; |
struct PutContext; |
@@ -119,6 +131,9 @@ class CONTENT_EXPORT CacheStorageCache |
using ScopedBackendPtr = scoped_ptr<disk_cache::Backend>; |
using BlobToDiskCacheIDMap = |
IDMap<CacheStorageBlobToDiskCache, IDMapOwnPointer>; |
+ using OpenAllEntriesCallback = |
+ base::Callback<void(scoped_ptr<OpenAllEntriesContext>, |
+ CacheStorageError)>; |
CacheStorageCache( |
const GURL& origin, |
@@ -133,6 +148,12 @@ class CONTENT_EXPORT CacheStorageCache |
// Returns true if the backend is ready to operate. |
bool LazyInitialize(); |
+ // Returns all entries in this cache. |
+ void OpenAllEntries(const OpenAllEntriesCallback& callback); |
+ void DidOpenNextEntry(scoped_ptr<OpenAllEntriesContext> entries_context, |
+ const OpenAllEntriesCallback& callback, |
+ int rv); |
+ |
// Match callbacks |
void MatchImpl(scoped_ptr<ServiceWorkerFetchRequest> request, |
const ResponseCallback& callback); |
@@ -145,6 +166,18 @@ class CONTENT_EXPORT CacheStorageCache |
disk_cache::ScopedEntryPtr entry, |
scoped_ptr<CacheMetadata> headers); |
+ // MatchAll callbacks |
+ void MatchAllImpl(const ResponsesCallback& callback); |
+ void MatchAllDidOpenAllEntries( |
+ const ResponsesCallback& callback, |
+ scoped_ptr<OpenAllEntriesContext> entries_context, |
+ CacheStorageError error); |
+ void MatchAllProcessNextEntry(scoped_ptr<MatchAllContext> context, |
+ const Entries::iterator& iter); |
+ void MatchAllDidReadMetadata(scoped_ptr<MatchAllContext> context, |
+ const Entries::iterator& iter, |
+ scoped_ptr<CacheMetadata> metadata); |
+ |
// Puts the request and response object in the cache. The response body (if |
// present) is stored in the cache, but not the request body. Returns OK on |
// success. |
@@ -179,7 +212,9 @@ class CONTENT_EXPORT CacheStorageCache |
// Keys callbacks. |
void KeysImpl(const RequestsCallback& callback); |
- void KeysDidOpenNextEntry(scoped_ptr<KeysContext> keys_context, int rv); |
+ void KeysDidOpenAllEntries(const RequestsCallback& callback, |
+ scoped_ptr<OpenAllEntriesContext> entries_context, |
+ CacheStorageError error); |
void KeysProcessNextEntry(scoped_ptr<KeysContext> keys_context, |
const Entries::iterator& iter); |
void KeysDidReadMetadata(scoped_ptr<KeysContext> keys_context, |
@@ -206,10 +241,21 @@ class CONTENT_EXPORT CacheStorageCache |
CacheStorageError error, |
scoped_ptr<ServiceWorkerResponse> response, |
scoped_ptr<storage::BlobDataHandle> blob_data_handle); |
+ void PendingResponsesCallback( |
+ const ResponsesCallback& callback, |
+ CacheStorageError error, |
+ scoped_ptr<Responses> responses, |
+ ScopedVector<storage::BlobDataHandle> blob_data_handles); |
void PendingRequestsCallback(const RequestsCallback& callback, |
CacheStorageError error, |
scoped_ptr<Requests> requests); |
+ void PopulateResponseMetadata(const CacheMetadata& metadata, |
+ ServiceWorkerResponse* response); |
+ scoped_ptr<storage::BlobDataHandle> PopulateResponseBody( |
+ disk_cache::ScopedEntryPtr entry, |
+ ServiceWorkerResponse* response); |
+ |
// Be sure to check |backend_state_| before use. |
scoped_ptr<disk_cache::Backend> backend_; |