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

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: Rebase 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 492e6f228767cd8005795a880d3a25e5d5344a73..6280e4138731a956c2f355ca9f6344dcb03510c8 100644
--- a/content/browser/service_worker/service_worker_cache_storage.cc
+++ b/content/browser/service_worker/service_worker_cache_storage.cc
@@ -437,16 +437,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,
@@ -518,23 +509,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);
@@ -664,15 +638,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