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

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

Issue 2056983004: [CacheStorage] Give ownership of all CacheStorageCaches to CacheStorage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 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_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 a12c93d6b6c898c8fb2aaeeec885d40d9b379e6d..e3ab6fa7faf33cfdeeac9fc64716b046ba1e959a 100644
--- a/content/browser/cache_storage/cache_storage_dispatcher_host.cc
+++ b/content/browser/cache_storage/cache_storage_dispatcher_host.cc
@@ -15,6 +15,7 @@
#include "base/trace_event/trace_event.h"
#include "content/browser/bad_message.h"
#include "content/browser/cache_storage/cache_storage_cache.h"
+#include "content/browser/cache_storage/cache_storage_cache_handle.h"
#include "content/browser/cache_storage/cache_storage_context_impl.h"
#include "content/browser/cache_storage/cache_storage_manager.h"
#include "content/common/cache_storage/cache_storage_messages.h"
@@ -222,14 +223,17 @@ void CacheStorageDispatcherHost::OnCacheMatch(
return;
}
- scoped_refptr<CacheStorageCache> cache = it->second;
+ CacheStorageCache* cache = it->second->value();
+ DCHECK(cache);
+
std::unique_ptr<ServiceWorkerFetchRequest> scoped_request(
new ServiceWorkerFetchRequest(request.url, request.method,
request.headers, request.referrer,
request.is_reload));
- cache->Match(std::move(scoped_request),
- base::Bind(&CacheStorageDispatcherHost::OnCacheMatchCallback,
- this, thread_id, request_id, cache));
+ cache->Match(
+ std::move(scoped_request),
+ base::Bind(&CacheStorageDispatcherHost::OnCacheMatchCallback, this,
+ thread_id, request_id, base::Passed(it->second->Clone())));
}
void CacheStorageDispatcherHost::OnCacheMatchAll(
@@ -245,12 +249,13 @@ void CacheStorageDispatcherHost::OnCacheMatchAll(
return;
}
- scoped_refptr<CacheStorageCache> cache = it->second;
+ CacheStorageCache* cache = it->second->value();
+ DCHECK(cache);
if (request.url.is_empty()) {
cache->MatchAll(
std::unique_ptr<ServiceWorkerFetchRequest>(), match_params,
base::Bind(&CacheStorageDispatcherHost::OnCacheMatchAllCallback, this,
- thread_id, request_id, cache));
+ thread_id, request_id, base::Passed(it->second->Clone())));
return;
}
@@ -262,13 +267,14 @@ void CacheStorageDispatcherHost::OnCacheMatchAll(
cache->MatchAll(
std::move(scoped_request), match_params,
base::Bind(&CacheStorageDispatcherHost::OnCacheMatchAllCallback, this,
- thread_id, request_id, cache));
+ thread_id, request_id, base::Passed(it->second->Clone())));
return;
}
cache->Match(
std::move(scoped_request),
base::Bind(&CacheStorageDispatcherHost::OnCacheMatchAllCallbackAdapter,
- this, thread_id, request_id, cache));
+ this, thread_id, request_id,
+ base::Passed(it->second->Clone())));
}
void CacheStorageDispatcherHost::OnCacheKeys(
@@ -284,10 +290,12 @@ void CacheStorageDispatcherHost::OnCacheKeys(
return;
}
- scoped_refptr<CacheStorageCache> cache = it->second;
+ CacheStorageCache* cache = it->second->value();
+ DCHECK(cache);
cache->Keys(base::Bind(&CacheStorageDispatcherHost::OnCacheKeysCallback, this,
- thread_id, request_id, cache));
+ thread_id, request_id,
+ base::Passed(it->second->Clone())));
}
void CacheStorageDispatcherHost::OnCacheBatch(
@@ -301,10 +309,13 @@ void CacheStorageDispatcherHost::OnCacheBatch(
thread_id, request_id, blink::WebServiceWorkerCacheErrorNotFound));
return;
}
- scoped_refptr<CacheStorageCache> cache = it->second;
+
+ CacheStorageCache* cache = it->second->value();
+ DCHECK(cache);
cache->BatchOperation(
- operations, base::Bind(&CacheStorageDispatcherHost::OnCacheBatchCallback,
- this, thread_id, request_id, cache));
+ operations,
+ base::Bind(&CacheStorageDispatcherHost::OnCacheBatchCallback, this,
+ thread_id, request_id, base::Passed(it->second->Clone())));
}
void CacheStorageDispatcherHost::OnCacheClosed(int cache_id) {
@@ -336,14 +347,14 @@ void CacheStorageDispatcherHost::OnCacheStorageHasCallback(
void CacheStorageDispatcherHost::OnCacheStorageOpenCallback(
int thread_id,
int request_id,
- scoped_refptr<CacheStorageCache> cache,
+ std::unique_ptr<CacheStorageCacheHandle> cache_handle,
CacheStorageError error) {
if (error != CACHE_STORAGE_OK) {
Send(new CacheStorageMsg_CacheStorageOpenError(
thread_id, request_id, ToWebServiceWorkerCacheError(error)));
return;
}
- CacheID cache_id = StoreCacheReference(std::move(cache));
+ CacheID cache_id = StoreCacheReference(std::move(cache_handle));
Send(new CacheStorageMsg_CacheStorageOpenSuccess(thread_id, request_id,
cache_id));
}
@@ -402,7 +413,7 @@ void CacheStorageDispatcherHost::OnCacheStorageMatchCallback(
void CacheStorageDispatcherHost::OnCacheMatchCallback(
int thread_id,
int request_id,
- scoped_refptr<CacheStorageCache> cache,
+ std::unique_ptr<CacheStorageCacheHandle> cache_handle,
CacheStorageError error,
std::unique_ptr<ServiceWorkerResponse> response,
std::unique_ptr<storage::BlobDataHandle> blob_data_handle) {
@@ -421,7 +432,7 @@ void CacheStorageDispatcherHost::OnCacheMatchCallback(
void CacheStorageDispatcherHost::OnCacheMatchAllCallbackAdapter(
int thread_id,
int request_id,
- scoped_refptr<CacheStorageCache> cache,
+ std::unique_ptr<CacheStorageCacheHandle> cache_handle,
CacheStorageError error,
std::unique_ptr<ServiceWorkerResponse> response,
std::unique_ptr<storage::BlobDataHandle> blob_data_handle) {
@@ -435,14 +446,14 @@ void CacheStorageDispatcherHost::OnCacheMatchAllCallbackAdapter(
if (blob_data_handle)
blob_data_handles->push_back(*blob_data_handle);
}
- OnCacheMatchAllCallback(thread_id, request_id, std::move(cache), error,
+ OnCacheMatchAllCallback(thread_id, request_id, std::move(cache_handle), error,
std::move(responses), std::move(blob_data_handles));
}
void CacheStorageDispatcherHost::OnCacheMatchAllCallback(
int thread_id,
int request_id,
- scoped_refptr<CacheStorageCache> cache,
+ std::unique_ptr<CacheStorageCacheHandle> cache_handle,
CacheStorageError error,
std::unique_ptr<CacheStorageCache::Responses> responses,
std::unique_ptr<CacheStorageCache::BlobDataHandles> blob_data_handles) {
@@ -462,7 +473,7 @@ void CacheStorageDispatcherHost::OnCacheMatchAllCallback(
void CacheStorageDispatcherHost::OnCacheKeysCallback(
int thread_id,
int request_id,
- scoped_refptr<CacheStorageCache> cache,
+ std::unique_ptr<CacheStorageCacheHandle> cache_handle,
CacheStorageError error,
std::unique_ptr<CacheStorageCache::Requests> requests) {
if (error != CACHE_STORAGE_OK) {
@@ -486,7 +497,7 @@ void CacheStorageDispatcherHost::OnCacheKeysCallback(
void CacheStorageDispatcherHost::OnCacheBatchCallback(
int thread_id,
int request_id,
- scoped_refptr<CacheStorageCache> cache,
+ std::unique_ptr<CacheStorageCacheHandle> cache_handle,
CacheStorageError error) {
if (error != CACHE_STORAGE_OK) {
Send(new CacheStorageMsg_CacheBatchError(
@@ -499,9 +510,9 @@ void CacheStorageDispatcherHost::OnCacheBatchCallback(
CacheStorageDispatcherHost::CacheID
CacheStorageDispatcherHost::StoreCacheReference(
- scoped_refptr<CacheStorageCache> cache) {
+ std::unique_ptr<CacheStorageCacheHandle> cache_handle) {
int cache_id = next_cache_id_++;
- id_to_cache_map_[cache_id] = std::move(cache);
+ id_to_cache_map_[cache_id] = std::move(cache_handle);
return cache_id;
}

Powered by Google App Engine
This is Rietveld 408576698