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

Unified Diff: content/browser/service_worker/service_worker_cache_storage.cc

Issue 545533002: Move ServiceWorkerCache backend creation to a lazy init function. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@no_pointers_keys
Patch Set: Nits Created 6 years, 3 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/service_worker/service_worker_cache_storage.cc
diff --git a/content/browser/service_worker/service_worker_cache_storage.cc b/content/browser/service_worker/service_worker_cache_storage.cc
index 5409289e81f73ba5d825b5e45f869a28d2c24ab5..a7161f65430ba9d63e7423683fdcbbfa90871292 100644
--- a/content/browser/service_worker/service_worker_cache_storage.cc
+++ b/content/browser/service_worker/service_worker_cache_storage.cc
@@ -447,16 +447,7 @@ void ServiceWorkerCacheStorage::GetCache(
return;
}
- ServiceWorkerCache* cache = cache_context->cache.get();
-
- if (cache->HasCreatedBackend())
- return callback.Run(cache_context->id, CACHE_STORAGE_ERROR_NO_ERROR);
-
- cache->CreateBackend(base::Bind(&ServiceWorkerCacheStorage::DidCreateBackend,
- weak_factory_.GetWeakPtr(),
- cache->AsWeakPtr(),
- cache_context->id,
- callback));
+ callback.Run(cache_context->id, CACHE_STORAGE_ERROR_NO_ERROR);
}
void ServiceWorkerCacheStorage::HasCache(const std::string& cache_name,
@@ -538,23 +529,6 @@ void ServiceWorkerCacheStorage::EnumerateCaches(
callback.Run(names, CACHE_STORAGE_ERROR_NO_ERROR);
}
-void ServiceWorkerCacheStorage::DidCreateBackend(
- base::WeakPtr<ServiceWorkerCache> cache,
- CacheID cache_id,
- const CacheAndErrorCallback& callback,
- ServiceWorkerCache::ErrorType error) {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
-
- if (error != ServiceWorkerCache::ErrorTypeOK || !cache) {
- // TODO(jkarlin): This should delete the directory and try again in case
- // the cache is simply corrupt.
- callback.Run(kInvalidCacheID, CACHE_STORAGE_ERROR_STORAGE);
- return;
- }
-
- callback.Run(cache_id, CACHE_STORAGE_ERROR_NO_ERROR);
-}
-
// Init is run lazily so that it is called on the proper MessageLoop.
void ServiceWorkerCacheStorage::LazyInit(const base::Closure& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
@@ -684,15 +658,11 @@ void ServiceWorkerCacheStorage::CreateCacheDidWriteIndex(
bool success) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (!cache) {
- callback.Run(false, CACHE_STORAGE_ERROR_CLOSING);
+ callback.Run(kInvalidCacheID, CACHE_STORAGE_ERROR_CLOSING);
return;
}
- cache->CreateBackend(base::Bind(&ServiceWorkerCacheStorage::DidCreateBackend,
- weak_factory_.GetWeakPtr(),
- cache,
- id,
- callback));
+ callback.Run(id, CACHE_STORAGE_ERROR_NO_ERROR);
}
void ServiceWorkerCacheStorage::DeleteCacheDidWriteIndex(

Powered by Google App Engine
This is Rietveld 408576698