Index: content/browser/cache_storage/cache_storage_dispatcher_host.cc |
diff --git a/content/browser/cache_storage/cache_storage_dispatcher_host.cc b/content/browser/cache_storage/cache_storage_dispatcher_host.cc |
index 79d3f5a884033aab3533b9edcdef23d565608aa0..82f47e780196a8183c844ab39f087eb6f103e4db 100644 |
--- a/content/browser/cache_storage/cache_storage_dispatcher_host.cc |
+++ b/content/browser/cache_storage/cache_storage_dispatcher_host.cc |
@@ -203,9 +203,29 @@ void CacheStorageDispatcherHost::OnCacheMatchAll( |
int cache_id, |
const ServiceWorkerFetchRequest& request, |
const CacheStorageCacheQueryParams& match_params) { |
- // TODO(gavinp,jkarlin): Implement this method. |
- Send(new CacheStorageMsg_CacheMatchAllError( |
- thread_id, request_id, blink::WebServiceWorkerCacheErrorNotImplemented)); |
+ IDToCacheMap::iterator it = id_to_cache_map_.find(cache_id); |
+ if (it == id_to_cache_map_.end()) { |
+ Send(new CacheStorageMsg_CacheMatchError( |
+ thread_id, request_id, blink::WebServiceWorkerCacheErrorNotFound)); |
+ return; |
+ } |
+ |
+ scoped_refptr<CacheStorageCache> cache = it->second; |
+ if (request.url.is_empty()) { |
+ cache->MatchAll( |
+ base::Bind(&CacheStorageDispatcherHost::OnCacheMatchAllCallback, this, |
+ thread_id, request_id, cache)); |
+ return; |
+ } |
+ |
+ scoped_ptr<ServiceWorkerFetchRequest> scoped_request( |
+ new ServiceWorkerFetchRequest(request.url, request.method, |
+ request.headers, request.referrer, |
+ request.is_reload)); |
+ cache->Match( |
+ scoped_request.Pass(), |
+ base::Bind(&CacheStorageDispatcherHost::OnCacheMatchAllCallbackAdapter, |
+ this, thread_id, request_id, cache)); |
} |
void CacheStorageDispatcherHost::OnCacheKeys( |
@@ -355,6 +375,47 @@ void CacheStorageDispatcherHost::OnCacheMatchCallback( |
Send(new CacheStorageMsg_CacheMatchSuccess(thread_id, request_id, *response)); |
} |
+void CacheStorageDispatcherHost::OnCacheMatchAllCallbackAdapter( |
+ int thread_id, |
+ int request_id, |
+ const scoped_refptr<CacheStorageCache>& cache, |
+ CacheStorageError error, |
+ scoped_ptr<ServiceWorkerResponse> response, |
+ scoped_ptr<storage::BlobDataHandle> blob_data_handle) { |
+ std::vector<ServiceWorkerResponse> responses; |
+ ScopedVector<storage::BlobDataHandle> blob_data_handles; |
+ if (error == CACHE_STORAGE_OK) { |
+ DCHECK(response); |
+ responses.push_back(*response); |
+ blob_data_handles.push_back(blob_data_handle.release()); |
+ } |
+ OnCacheMatchAllCallback(thread_id, request_id, cache, error, responses, |
+ blob_data_handles.Pass()); |
+} |
+ |
+void CacheStorageDispatcherHost::OnCacheMatchAllCallback( |
+ int thread_id, |
+ int request_id, |
+ const scoped_refptr<CacheStorageCache>& cache, |
+ CacheStorageError error, |
+ const std::vector<ServiceWorkerResponse>& responses, |
+ ScopedVector<storage::BlobDataHandle> blob_data_handles) { |
+ if (error != CACHE_STORAGE_OK || error != CACHE_STORAGE_ERROR_NOT_FOUND) { |
+ Send(new CacheStorageMsg_CacheMatchAllError( |
+ thread_id, request_id, ToWebServiceWorkerCacheError(error))); |
+ return; |
+ } |
+ |
+ for (storage::BlobDataHandle* handle : blob_data_handles) { |
+ if (handle) |
+ StoreBlobDataHandle(make_scoped_ptr(handle)); |
+ } |
+ blob_data_handles.weak_clear(); |
+ |
+ Send(new CacheStorageMsg_CacheMatchAllSuccess(thread_id, request_id, |
+ responses)); |
+} |
+ |
void CacheStorageDispatcherHost::OnCacheKeysCallback( |
int thread_id, |
int request_id, |
@@ -414,7 +475,7 @@ void CacheStorageDispatcherHost::StoreBlobDataHandle( |
rv.first->second.push_front(storage::BlobDataHandle(*blob_data_handle)); |
} |
-void CacheStorageDispatcherHost::DropBlobDataHandle(std::string uuid) { |
+void CacheStorageDispatcherHost::DropBlobDataHandle(const std::string& uuid) { |
UUIDToBlobDataHandleList::iterator it = blob_handle_store_.find(uuid); |
if (it == blob_handle_store_.end()) |
return; |