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

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

Issue 549493002: Expose ServiceWorkerCache objects to ServiceWorkerCacheStorageManager clients. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refptr3
Patch Set: Fix rebase issue 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.h
diff --git a/content/browser/service_worker/service_worker_cache_storage.h b/content/browser/service_worker/service_worker_cache_storage.h
index fd198ff25841564ed5ea919dee679e9b36c78f21..e15a0f716b2e2fac64c42cdd45f53de4ee1b5bb4 100644
--- a/content/browser/service_worker/service_worker_cache_storage.h
+++ b/content/browser/service_worker/service_worker_cache_storage.h
@@ -34,13 +34,6 @@ namespace content {
// on the IO thread.
class CONTENT_EXPORT 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;
-
- // The CacheID returned on failed cache operations.
- const static int kInvalidCacheID;
-
enum CacheStorageError {
CACHE_STORAGE_ERROR_NO_ERROR,
CACHE_STORAGE_ERROR_NOT_IMPLEMENTED,
@@ -51,7 +44,8 @@ class CONTENT_EXPORT ServiceWorkerCacheStorage {
};
typedef base::Callback<void(bool, CacheStorageError)> BoolAndErrorCallback;
- typedef base::Callback<void(int, CacheStorageError)> CacheAndErrorCallback;
+ typedef base::Callback<void(const scoped_refptr<ServiceWorkerCache>&,
+ CacheStorageError)> CacheAndErrorCallback;
typedef base::Callback<void(const std::vector<std::string>&,
CacheStorageError)> StringsAndErrorCallback;
@@ -93,12 +87,13 @@ class CONTENT_EXPORT ServiceWorkerCacheStorage {
class MemoryLoader;
class SimpleCacheLoader;
class CacheLoader;
- struct CacheContext;
- typedef std::map<CacheID, CacheContext*> CacheMap;
- typedef std::map<std::string, CacheID> NameMap;
+ typedef std::map<std::string, base::WeakPtr<ServiceWorkerCache> > CacheMap;
- CacheContext* GetLoadedCache(const std::string& cache_name) const;
+ // Return a ServiceWorkerCache for the given name if the name is known. If the
+ // ServiceWorkerCache has been deleted, creates a new one.
+ scoped_refptr<ServiceWorkerCache> GetLoadedCache(
+ const std::string& cache_name);
// Initializer and its callback are below.
void LazyInit(const base::Closure& closure);
@@ -106,16 +101,16 @@ class CONTENT_EXPORT ServiceWorkerCacheStorage {
const base::Closure& callback,
scoped_ptr<std::vector<std::string> > indexed_cache_names);
- CacheContext* AddCacheToMaps(const std::string& cache_name,
- scoped_ptr<ServiceWorkerCache> cache);
+ void AddCacheToMap(const std::string& cache_name,
+ base::WeakPtr<ServiceWorkerCache> cache);
// The CreateCache callbacks are below.
- void CreateCacheDidCreateCache(const std::string& cache_name,
- const CacheAndErrorCallback& callback,
- scoped_ptr<ServiceWorkerCache> cache);
+ void CreateCacheDidCreateCache(
+ const std::string& cache_name,
+ const CacheAndErrorCallback& callback,
+ const scoped_refptr<ServiceWorkerCache>& cache);
void CreateCacheDidWriteIndex(const CacheAndErrorCallback& callback,
- base::WeakPtr<ServiceWorkerCache> cache,
- CacheID id,
+ const scoped_refptr<ServiceWorkerCache>& cache,
bool success);
// The DeleteCache callbacks are below.
@@ -131,14 +126,8 @@ class CONTENT_EXPORT ServiceWorkerCacheStorage {
// The list of operations waiting on initialization.
std::vector<base::Closure> init_callbacks_;
- // The map of CacheIDs to their CacheContext objects. Owns the CacheContext
- // object. The CacheIDs are used by JavaScript to reference a
- // ServiceWorkerCache.
+ // The map of cache names to ServiceWorkerCache objects.
CacheMap cache_map_;
- CacheID next_cache_id_; // The next CacheID to use in cache_map_
-
- // The map of cache names to their integer ids.
- NameMap name_map_;
// The file path for this CacheStorage.
base::FilePath origin_path_;
@@ -146,6 +135,9 @@ class CONTENT_EXPORT ServiceWorkerCacheStorage {
// The TaskRunner to run file IO on.
scoped_refptr<base::SequencedTaskRunner> cache_task_runner_;
+ // Whether or not to store data in disk or memory.
+ bool memory_only_;
+
// Performs backend specific operations (memory vs disk).
scoped_ptr<CacheLoader> cache_loader_;

Powered by Google App Engine
This is Rietveld 408576698