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 566921a76f15e3561b0fcf8076edf26291f4b236..bbadd203ef4149903b8cd5b275ae633ccea56f1e 100644 |
--- a/content/browser/service_worker/service_worker_cache_storage.h |
+++ b/content/browser/service_worker/service_worker_cache_storage.h |
@@ -35,6 +35,10 @@ class ServiceWorkerCache; |
// on the IO thread. |
class ServiceWorkerCacheStorage { |
public: |
+ // TODO(jkarlin): Convert this (and everything that uses it) to int64_t so |
+ // that we don't run out of id space. |
+ typedef int32_t CacheID; |
+ |
enum CacheStorageError { |
CACHE_STORAGE_ERROR_NO_ERROR, |
CACHE_STORAGE_ERROR_NOT_IMPLEMENTED, |
@@ -42,6 +46,7 @@ class ServiceWorkerCacheStorage { |
CACHE_STORAGE_ERROR_EXISTS, |
CACHE_STORAGE_ERROR_STORAGE, |
CACHE_STORAGE_ERROR_EMPTY_KEY, |
+ CACHE_STORAGE_ERROR_CLOSING |
}; |
typedef base::Callback<void(bool, CacheStorageError)> BoolAndErrorCallback; |
@@ -87,12 +92,12 @@ class ServiceWorkerCacheStorage { |
class MemoryLoader; |
class SimpleCacheLoader; |
class CacheLoader; |
+ struct CacheContext; |
- typedef IDMap<ServiceWorkerCache, IDMapOwnPointer> CacheMap; |
- typedef CacheMap::KeyType CacheID; |
+ typedef std::map<CacheID, CacheContext*> CacheMap; |
typedef std::map<std::string, CacheID> NameMap; |
- ServiceWorkerCache* GetLoadedCache(const std::string& cache_name) const; |
+ CacheContext* GetLoadedCache(const std::string& cache_name) const; |
// Initializer and its callback are below. |
void LazyInit(const base::Closure& closure); |
@@ -103,14 +108,17 @@ class ServiceWorkerCacheStorage { |
const base::Closure& callback, |
scoped_ptr<std::vector<std::string> > indexed_cache_names, |
const std::vector<std::string>::const_iterator& iter, |
+ const std::string& cache_name, |
scoped_ptr<ServiceWorkerCache> cache); |
void LazyInitDone(); |
void DidCreateBackend(base::WeakPtr<ServiceWorkerCache> cache, |
+ CacheID cache_id, |
const CacheAndErrorCallback& callback, |
bool success); |
- void AddCacheToMaps(scoped_ptr<ServiceWorkerCache> cache); |
+ CacheContext* AddCacheToMaps(const std::string& cache_name, |
+ scoped_ptr<ServiceWorkerCache> cache); |
// The CreateCache callbacks are below. |
void CreateCacheDidCreateCache(const std::string& cache_name, |
@@ -118,6 +126,7 @@ class ServiceWorkerCacheStorage { |
scoped_ptr<ServiceWorkerCache> cache); |
void CreateCacheDidWriteIndex(const CacheAndErrorCallback& callback, |
base::WeakPtr<ServiceWorkerCache> cache, |
+ CacheID id, |
bool success); |
// The DeleteCache callbacks are below. |
@@ -133,9 +142,11 @@ class ServiceWorkerCacheStorage { |
// 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. |
+ // The map of CacheIds to their CacheContext objects. Owns the CacheContext |
+ // object. The CacheIDs are used by JavaScript to reference a |
falken
2014/08/26 06:31:33
nit: Be consistent about CacheID vs CacheId
jkarlin
2014/08/26 12:03:10
Done.
|
+ // ServiceWorkerCache. |
CacheMap cache_map_; |
+ CacheID next_cache_id_; // The next CacheID to use in cache_map_; |
falken
2014/08/26 06:31:33
nit: no need to end comment with semicolon
jkarlin
2014/08/26 12:03:10
Done.
|
// The map of cache names to their integer ids. |
NameMap name_map_; |