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

Unified Diff: content/browser/service_worker/service_worker_cache_listener.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_listener.h
diff --git a/content/browser/service_worker/service_worker_cache_listener.h b/content/browser/service_worker/service_worker_cache_listener.h
index 27a6089019946382624155b3db88bf1eb8933ba0..21dc6eed452743b814fb82c9e64b6f3af31d1e31 100644
--- a/content/browser/service_worker/service_worker_cache_listener.h
+++ b/content/browser/service_worker/service_worker_cache_listener.h
@@ -35,12 +35,19 @@ class ServiceWorkerCacheListener : public EmbeddedWorkerInstance::Listener {
const base::string16& cache_name);
void OnCacheStorageKeys(int request_id);
+ // TODO(gavinp,jkarlin): Plumb a message up from the renderer saying that the
+ // renderer is done with a cache id.
+
private:
+ typedef int32_t CacheID; // TODO(jkarlin): Bump to 64 bit.
+ typedef std::map<ServiceWorkerCache*, CacheID> CacheToIDMap;
+ typedef std::map<CacheID, scoped_refptr<ServiceWorkerCache> > IDToCacheMap;
+
void Send(const IPC::Message& message);
void OnCacheStorageGetCallback(
int request_id,
- int cache_id,
+ const scoped_refptr<ServiceWorkerCache>& cache,
ServiceWorkerCacheStorage::CacheStorageError error);
void OnCacheStorageHasCallback(
int request_id,
@@ -48,7 +55,7 @@ class ServiceWorkerCacheListener : public EmbeddedWorkerInstance::Listener {
ServiceWorkerCacheStorage::CacheStorageError error);
void OnCacheStorageCreateCallback(
int request_id,
- int cache_id,
+ const scoped_refptr<ServiceWorkerCache>& cache,
ServiceWorkerCacheStorage::CacheStorageError error);
void OnCacheStorageDeleteCallback(
int request_id,
@@ -59,12 +66,22 @@ class ServiceWorkerCacheListener : public EmbeddedWorkerInstance::Listener {
const std::vector<std::string>& strings,
ServiceWorkerCacheStorage::CacheStorageError error);
+ // Hangs onto a scoped_refptr for the cache if it isn't already doing so.
+ // Returns a unique cache_id. Call DropCacheReference when the client is done
+ // with this cache.
+ CacheID StoreCacheReference(const scoped_refptr<ServiceWorkerCache>& cache);
+ void DropCacheReference(CacheID cache_id);
+
// The ServiceWorkerVersion to use for messaging back to the renderer thread.
ServiceWorkerVersion* version_;
// The ServiceWorkerContextCore should always outlive this.
base::WeakPtr<ServiceWorkerContextCore> context_;
+ IDToCacheMap id_to_cache_map_;
+ CacheToIDMap cache_to_id_map_;
+ CacheID next_cache_id_;
+
base::WeakPtrFactory<ServiceWorkerCacheListener> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCacheListener);

Powered by Google App Engine
This is Rietveld 408576698