Index: content/browser/service_worker/service_worker_cache_storage.h |
diff --git a/content/browser/service_worker/service_worker_cache_storage.h b/content/browser/service_worker/service_worker_cache_storage.h |
index 291d02958698ea56f71e610303ce06b9f0ef7e70..9ec5a94a752cbce308601e0bf128417759f8a4f6 100644 |
--- a/content/browser/service_worker/service_worker_cache_storage.h |
+++ b/content/browser/service_worker/service_worker_cache_storage.h |
@@ -14,11 +14,10 @@ |
#include "base/threading/thread_checker.h" |
namespace base { |
-class MessageLoopProxy; |
+class SequencedTaskRunner; |
} |
namespace content { |
- |
class ServiceWorkerCache; |
// TODO(jkarlin): Constrain the total bytes used per origin. |
@@ -41,10 +40,9 @@ class ServiceWorkerCacheStorage { |
typedef base::Callback<void(const std::vector<std::string>&, |
CacheStorageError)> StringsAndErrorCallback; |
- ServiceWorkerCacheStorage( |
- const base::FilePath& origin_path, |
- bool memory_only, |
- const scoped_refptr<base::MessageLoopProxy>& callback_loop); |
+ ServiceWorkerCacheStorage(const base::FilePath& origin_path, |
+ bool memory_only, |
+ base::SequencedTaskRunner* cache_task_runner); |
virtual ~ServiceWorkerCacheStorage(); |
@@ -73,10 +71,6 @@ class ServiceWorkerCacheStorage { |
// TODO(jkarlin): Add match() function. |
- void InitializeCacheCallback(const ServiceWorkerCache* cache, |
- const CacheAndErrorCallback& callback, |
- bool success); |
- |
private: |
class MemoryLoader; |
class SimpleCacheLoader; |
@@ -88,16 +82,63 @@ class ServiceWorkerCacheStorage { |
ServiceWorkerCache* GetLoadedCache(const std::string& cache_name) const; |
- void LazyInit(); |
- void InitCache(ServiceWorkerCache* cache); |
- |
+ // Initializer and its callback are below. |
+ void LazyInit(const base::Closure& closure); |
+ void LazyInitDidLoadIndex( |
+ const base::Closure& callback, |
+ scoped_ptr<std::vector<std::string> > indexed_cache_names); |
+ void LazyInitIterateAndLoadCacheName( |
+ const base::Closure& callback, |
+ scoped_ptr<std::vector<std::string> > indexed_cache_names, |
+ std::vector<std::string>::const_iterator iter, |
+ ServiceWorkerCache* cache); |
+ void LazyInitDone(); |
+ |
+ void DidCreateBackend(const ServiceWorkerCache* cache, |
+ const CacheAndErrorCallback& callback, |
+ bool success); |
+ |
+ void AddCacheToMaps(ServiceWorkerCache* cache); |
+ |
+ // The CreateCache callbacks are below. |
+ void CreateCacheDidCreateCache(const std::string& cache_name, |
+ const CacheAndErrorCallback& callback, |
+ ServiceWorkerCache* cache); |
+ void CreateCacheDidWriteIndex(const CacheAndErrorCallback& callback, |
+ ServiceWorkerCache* cache, |
+ bool success); |
+ |
+ // The DeleteCache callbacks are below. |
+ void DeleteCacheDidWriteIndex(const std::string& cache_name, |
+ const BoolAndErrorCallback& callback, |
+ bool success); |
+ void DeleteCacheDidCleanUp(const BoolAndErrorCallback& callback, |
+ bool success); |
+ |
+ // Whether or not we've loaded the list of cache names into memory. |
bool initialized_; |
+ |
+ // The list of operations waiting on initialization. |
+ std::vector<base::Closure> init_callbacks_; |
+ |
+ // The map of ServiceWorkerCache objects to their integer ids that |
+ // ServiceWorkers reference. Owns the cache objects. |
CacheMap cache_map_; |
+ |
+ // The map of cache names to their integer ids. |
NameMap name_map_; |
+ |
+ // The file path for this CacheStorage. |
base::FilePath origin_path_; |
- scoped_refptr<base::MessageLoopProxy> callback_loop_; |
+ |
+ // The TaskRunner to run file IO on. |
+ scoped_refptr<base::SequencedTaskRunner> cache_task_runner_; |
+ |
+ // Performs backend specific operations (memory vs disk). |
scoped_ptr<CacheLoader> cache_loader_; |
+ base::ThreadChecker thread_checker_; |
michaeln
2014/08/11 19:30:17
wdyt of calling this io_thread_checker_ ? it's rea
jkarlin
2014/08/12 14:55:03
Done. Used DCHECK_CURRENTLY_ON(BrowserThread::IO)
|
+ |
DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCacheStorage); |
}; |