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

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

Issue 510813002: Organize ServiceWorkerCacheStorage's methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@guarantee2
Patch Set: Rebase Created 6 years, 4 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
« no previous file with comments | « content/browser/service_worker/service_worker_cache_storage.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ab3bc8460341b87ea0fe7b15550d5ba20d2718df..ca8f91711829fa1842d9dc9db93f6483ca4424a6 100644
--- a/content/browser/service_worker/service_worker_cache_storage.cc
+++ b/content/browser/service_worker/service_worker_cache_storage.cc
@@ -563,24 +563,6 @@ void ServiceWorkerCacheStorage::EnumerateCaches(
callback.Run(names, CACHE_STORAGE_ERROR_NO_ERROR);
}
-// static
-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);
-}
-
void ServiceWorkerCacheStorage::LazyInit(const base::Closure& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(!initialized_);
@@ -607,6 +589,33 @@ void ServiceWorkerCacheStorage::LazyInit(const base::Closure& callback) {
weak_factory_.GetWeakPtr()));
}
+ServiceWorkerCacheStorage::CacheContext*
+ServiceWorkerCacheStorage::GetLoadedCache(const std::string& cache_name) const {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ DCHECK(initialized_);
+
+ NameMap::const_iterator name_iter = name_map_.find(cache_name);
+ if (name_iter == name_map_.end())
+ return NULL;
+
+ CacheMap::const_iterator map_iter = cache_map_.find(name_iter->second);
+ DCHECK(map_iter != cache_map_.end());
+ return map_iter->second;
+}
+
+ServiceWorkerCacheStorage::CacheContext*
+ServiceWorkerCacheStorage::AddCacheToMaps(
+ const std::string& cache_name,
+ scoped_ptr<ServiceWorkerCache> cache) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+
+ CacheID id = next_cache_id_++;
+ CacheContext* cache_context = new CacheContext(cache_name, id, cache.Pass());
+ cache_map_.insert(std::make_pair(id, cache_context)); // Takes ownership
+ name_map_.insert(std::make_pair(cache_name, id));
+ return cache_context;
+}
+
// static
void ServiceWorkerCacheStorage::LazyInitDidLoadIndex(
const base::Closure& callback,
@@ -682,19 +691,6 @@ void ServiceWorkerCacheStorage::LazyInitDone(
storage->init_callbacks_.clear();
}
-ServiceWorkerCacheStorage::CacheContext*
-ServiceWorkerCacheStorage::AddCacheToMaps(
- const std::string& cache_name,
- scoped_ptr<ServiceWorkerCache> cache) {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
-
- CacheID id = next_cache_id_++;
- CacheContext* cache_context = new CacheContext(cache_name, id, cache.Pass());
- cache_map_.insert(std::make_pair(id, cache_context)); // Takes ownership
- name_map_.insert(std::make_pair(cache_name, id));
- return cache_context;
-}
-
// static
void ServiceWorkerCacheStorage::CreateCacheDidCreateCache(
const std::string& cache_name,
@@ -762,18 +758,22 @@ void ServiceWorkerCacheStorage::DeleteCacheDidCleanUp(
callback.Run(true, CACHE_STORAGE_ERROR_NO_ERROR);
}
-ServiceWorkerCacheStorage::CacheContext*
-ServiceWorkerCacheStorage::GetLoadedCache(const std::string& cache_name) const {
+// static
+void ServiceWorkerCacheStorage::DidCreateBackend(
+ base::WeakPtr<ServiceWorkerCache> cache,
+ CacheID cache_id,
+ const CacheAndErrorCallback& callback,
+ ServiceWorkerCache::ErrorType error) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- DCHECK(initialized_);
- NameMap::const_iterator name_iter = name_map_.find(cache_name);
- if (name_iter == name_map_.end())
- return NULL;
+ 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;
+ }
- CacheMap::const_iterator map_iter = cache_map_.find(name_iter->second);
- DCHECK(map_iter != cache_map_.end());
- return map_iter->second;
+ callback.Run(cache_id, CACHE_STORAGE_ERROR_NO_ERROR);
}
} // namespace content
« no previous file with comments | « content/browser/service_worker/service_worker_cache_storage.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698