Index: content/browser/cache_storage/cache_storage_dispatcher_host.h |
diff --git a/content/browser/cache_storage/cache_storage_dispatcher_host.h b/content/browser/cache_storage/cache_storage_dispatcher_host.h |
index ed10561795778389ba7464cddc29f18f95e21e7d..7d3833afe2ab7f51229413793ffd0e2bffc63687 100644 |
--- a/content/browser/cache_storage/cache_storage_dispatcher_host.h |
+++ b/content/browser/cache_storage/cache_storage_dispatcher_host.h |
@@ -5,21 +5,18 @@ |
#ifndef CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_DISPATCHER_HOST_H_ |
#define CONTENT_BROWSER_CACHE_STORAGE_CACHE_STORAGE_DISPATCHER_HOST_H_ |
+#include <list> |
+ |
#include "content/browser/cache_storage/cache_storage.h" |
#include "content/public/browser/browser_message_filter.h" |
namespace content { |
class CacheStorageContextImpl; |
-class CacheStorageListener; |
// Handles Cache Storage related messages sent to the browser process from |
// child processes. One host instance exists per child process. All |
-// messages are processed on the IO thread. Currently, all messages are |
-// passed directly to the owned CacheStorageListener instance, which |
-// in turn dispatches calls to the CacheStorageManager owned |
-// by the CacheStorageContextImpl for the entire browsing context. |
-// TODO(jsbell): Merge this with CacheStorageListener crbug.com/439389 |
+// messages are processed on the IO thread. |
class CONTENT_EXPORT CacheStorageDispatcherHost : public BrowserMessageFilter { |
public: |
CacheStorageDispatcherHost(); |
@@ -36,6 +33,11 @@ class CONTENT_EXPORT CacheStorageDispatcherHost : public BrowserMessageFilter { |
friend class BrowserThread; |
friend class base::DeleteHelper<CacheStorageDispatcherHost>; |
+ typedef int32_t CacheID; // TODO(jkarlin): Bump to 64 bit. |
+ typedef std::map<CacheID, scoped_refptr<CacheStorageCache>> IDToCacheMap; |
+ typedef std::map<std::string, std::list<storage::BlobDataHandle>> |
+ UUIDToBlobDataHandleList; |
+ |
~CacheStorageDispatcherHost() override; |
// Called by Init() on IO thread. |
@@ -61,6 +63,24 @@ class CONTENT_EXPORT CacheStorageDispatcherHost : public BrowserMessageFilter { |
const ServiceWorkerFetchRequest& request, |
const CacheStorageCacheQueryParams& match_params); |
+ // The message receiver functions for the Cache API: |
+ void OnCacheMatch(int thread_id, |
+ int request_id, |
+ int cache_id, |
+ const ServiceWorkerFetchRequest& request, |
+ const CacheStorageCacheQueryParams& match_params); |
+ void OnCacheKeys(int thread_id, |
+ int request_id, |
+ int cache_id, |
+ const ServiceWorkerFetchRequest& request, |
+ const CacheStorageCacheQueryParams& match_params); |
+ void OnCacheBatch(int thread_id, |
+ int request_id, |
+ int cache_id, |
+ const std::vector<CacheStorageBatchOperation>& operations); |
+ void OnCacheClosed(int cache_id); |
+ void OnBlobDataHandled(const std::string& uuid); |
+ |
// CacheStorageManager callbacks |
void OnCacheStorageHasCallback(int thread_id, |
int request_id, |
@@ -85,7 +105,52 @@ class CONTENT_EXPORT CacheStorageDispatcherHost : public BrowserMessageFilter { |
scoped_ptr<ServiceWorkerResponse> response, |
scoped_ptr<storage::BlobDataHandle> blob_data_handle); |
- scoped_ptr<CacheStorageListener> cache_listener_; |
+ // Cache callbacks. |
+ void OnCacheMatchCallback( |
+ int thread_id, |
+ int request_id, |
+ const scoped_refptr<CacheStorageCache>& cache, |
+ CacheStorageCache::ErrorType error, |
+ scoped_ptr<ServiceWorkerResponse> response, |
+ scoped_ptr<storage::BlobDataHandle> blob_data_handle); |
+ void OnCacheMatchAll(int thread_id, |
+ int request_id, |
+ int cache_id, |
+ const ServiceWorkerFetchRequest& request, |
+ const CacheStorageCacheQueryParams& match_params); |
+ void OnCacheKeysCallback(int thread_id, |
+ int request_id, |
+ const scoped_refptr<CacheStorageCache>& cache, |
+ CacheStorageCache::ErrorType error, |
+ scoped_ptr<CacheStorageCache::Requests> requests); |
+ void OnCacheDeleteCallback(int thread_id, |
+ int request_id, |
+ const scoped_refptr<CacheStorageCache>& cache, |
+ CacheStorageCache::ErrorType error); |
+ void OnCachePutCallback(int thread_id, |
+ int request_id, |
+ const scoped_refptr<CacheStorageCache>& cache, |
+ CacheStorageCache::ErrorType error, |
+ scoped_ptr<ServiceWorkerResponse> response, |
+ scoped_ptr<storage::BlobDataHandle> blob_data_handle); |
+ |
+ // 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<CacheStorageCache>& cache); |
+ void DropCacheReference(CacheID cache_id); |
+ |
+ // Stores blob handles while waiting for acknowledgement of receipt from the |
+ // renderer. |
+ void StoreBlobDataHandle( |
+ scoped_ptr<storage::BlobDataHandle> blob_data_handle); |
+ void DropBlobDataHandle(std::string uuid); |
+ |
+ IDToCacheMap id_to_cache_map_; |
+ CacheID next_cache_id_ = 0; |
+ |
+ UUIDToBlobDataHandleList blob_handle_store_; |
+ |
scoped_refptr<CacheStorageContextImpl> context_; |
DISALLOW_COPY_AND_ASSIGN(CacheStorageDispatcherHost); |