| Index: content/browser/service_worker/service_worker_cache_storage.h
|
| diff --git a/content/browser/service_worker/service_worker_fetch_stores.h b/content/browser/service_worker/service_worker_cache_storage.h
|
| similarity index 41%
|
| rename from content/browser/service_worker/service_worker_fetch_stores.h
|
| rename to content/browser/service_worker/service_worker_cache_storage.h
|
| index 84798dc462fb93c4508ea5c04e79617784396f8d..291d02958698ea56f71e610303ce06b9f0ef7e70 100644
|
| --- a/content/browser/service_worker/service_worker_fetch_stores.h
|
| +++ b/content/browser/service_worker/service_worker_cache_storage.h
|
| @@ -2,8 +2,8 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_FETCH_STORES_H_
|
| -#define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_FETCH_STORES_H_
|
| +#ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_H_
|
| +#define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_H_
|
|
|
| #include <map>
|
| #include <string>
|
| @@ -19,88 +19,88 @@ class MessageLoopProxy;
|
|
|
| namespace content {
|
|
|
| -class ServiceWorkerFetchStore;
|
| +class ServiceWorkerCache;
|
|
|
| // TODO(jkarlin): Constrain the total bytes used per origin.
|
| -// The set of stores for a given origin. It is owned by the
|
| -// ServiceWorkerFetchStoresManager. Provided callbacks are called on the
|
| +// The set of caches for a given origin. It is owned by the
|
| +// ServiceWorkerCacheStorageManager. Provided callbacks are called on the
|
| // |callback_loop| provided in the constructor.
|
| -class ServiceWorkerFetchStores {
|
| +class ServiceWorkerCacheStorage {
|
| public:
|
| - enum FetchStoresError {
|
| - FETCH_STORES_ERROR_NO_ERROR,
|
| - FETCH_STORES_ERROR_NOT_IMPLEMENTED,
|
| - FETCH_STORES_ERROR_NOT_FOUND,
|
| - FETCH_STORES_ERROR_EXISTS,
|
| - FETCH_STORES_ERROR_STORAGE,
|
| - FETCH_STORES_ERROR_EMPTY_KEY,
|
| + enum CacheStorageError {
|
| + CACHE_STORAGE_ERROR_NO_ERROR,
|
| + CACHE_STORAGE_ERROR_NOT_IMPLEMENTED,
|
| + CACHE_STORAGE_ERROR_NOT_FOUND,
|
| + CACHE_STORAGE_ERROR_EXISTS,
|
| + CACHE_STORAGE_ERROR_STORAGE,
|
| + CACHE_STORAGE_ERROR_EMPTY_KEY,
|
| };
|
|
|
| - typedef base::Callback<void(bool, FetchStoresError)> BoolAndErrorCallback;
|
| - typedef base::Callback<void(int, FetchStoresError)> StoreAndErrorCallback;
|
| + typedef base::Callback<void(bool, CacheStorageError)> BoolAndErrorCallback;
|
| + typedef base::Callback<void(int, CacheStorageError)> CacheAndErrorCallback;
|
| typedef base::Callback<void(const std::vector<std::string>&,
|
| - FetchStoresError)> StringsAndErrorCallback;
|
| + CacheStorageError)> StringsAndErrorCallback;
|
|
|
| - ServiceWorkerFetchStores(
|
| + ServiceWorkerCacheStorage(
|
| const base::FilePath& origin_path,
|
| bool memory_only,
|
| const scoped_refptr<base::MessageLoopProxy>& callback_loop);
|
|
|
| - virtual ~ServiceWorkerFetchStores();
|
| + virtual ~ServiceWorkerCacheStorage();
|
|
|
| - // Create a ServiceWorkerFetchStore if it doesn't already exist and call the
|
| + // Create a ServiceWorkerCache if it doesn't already exist and call the
|
| // callback with the cache's id. If it already
|
| - // exists the callback is called with FETCH_STORES_ERROR_EXISTS.
|
| - void CreateStore(const std::string& store_name,
|
| - const StoreAndErrorCallback& callback);
|
| + // exists the callback is called with CACHE_STORAGE_ERROR_EXISTS.
|
| + void CreateCache(const std::string& cache_name,
|
| + const CacheAndErrorCallback& callback);
|
|
|
| // Get the cache id for the given key. If not found returns
|
| - // FETCH_STORES_ERROR_NOT_FOUND.
|
| - void GetStore(const std::string& store_name,
|
| - const StoreAndErrorCallback& callback);
|
| + // CACHE_STORAGE_ERROR_NOT_FOUND.
|
| + void GetCache(const std::string& cache_name,
|
| + const CacheAndErrorCallback& callback);
|
|
|
| // Calls the callback with whether or not the cache exists.
|
| - void HasStore(const std::string& store_name,
|
| + void HasCache(const std::string& cache_name,
|
| const BoolAndErrorCallback& callback);
|
|
|
| // Deletes the cache if it exists. If it doesn't exist,
|
| - // FETCH_STORES_ERROR_NOT_FOUND is returned.
|
| - void DeleteStore(const std::string& store_name,
|
| + // CACHE_STORAGE_ERROR_NOT_FOUND is returned.
|
| + void DeleteCache(const std::string& cache_name,
|
| const BoolAndErrorCallback& callback);
|
|
|
| // Calls the callback with a vector of cache names (keys) available.
|
| - void EnumerateStores(const StringsAndErrorCallback& callback);
|
| + void EnumerateCaches(const StringsAndErrorCallback& callback);
|
|
|
| // TODO(jkarlin): Add match() function.
|
|
|
| - void InitializeStoreCallback(const ServiceWorkerFetchStore* store,
|
| - const StoreAndErrorCallback& callback,
|
| + void InitializeCacheCallback(const ServiceWorkerCache* cache,
|
| + const CacheAndErrorCallback& callback,
|
| bool success);
|
|
|
| private:
|
| class MemoryLoader;
|
| class SimpleCacheLoader;
|
| - class StoresLoader;
|
| + class CacheLoader;
|
|
|
| - typedef IDMap<ServiceWorkerFetchStore, IDMapOwnPointer> StoreMap;
|
| - typedef StoreMap::KeyType StoreID;
|
| - typedef std::map<std::string, StoreID> NameMap;
|
| + typedef IDMap<ServiceWorkerCache, IDMapOwnPointer> CacheMap;
|
| + typedef CacheMap::KeyType CacheID;
|
| + typedef std::map<std::string, CacheID> NameMap;
|
|
|
| - ServiceWorkerFetchStore* GetLoadedStore(const std::string& key) const;
|
| + ServiceWorkerCache* GetLoadedCache(const std::string& cache_name) const;
|
|
|
| void LazyInit();
|
| - void InitStore(ServiceWorkerFetchStore* store);
|
| + void InitCache(ServiceWorkerCache* cache);
|
|
|
| bool initialized_;
|
| - StoreMap store_map_;
|
| + CacheMap cache_map_;
|
| NameMap name_map_;
|
| base::FilePath origin_path_;
|
| scoped_refptr<base::MessageLoopProxy> callback_loop_;
|
| - scoped_ptr<StoresLoader> stores_loader_;
|
| + scoped_ptr<CacheLoader> cache_loader_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(ServiceWorkerFetchStores);
|
| + DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCacheStorage);
|
| };
|
|
|
| } // namespace content
|
|
|
| -#endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_FETCH_STORES_H_
|
| +#endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_H_
|
|
|