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

Unified Diff: content/browser/cache_storage/cache_storage_dispatcher_host.h

Issue 1107293002: CacheStorage: Merge CacheStorageListener into CacheStorageDispatcherHost (2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@merge_cache_listener_and_dispatcher
Patch Set: Created 5 years, 8 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
« no previous file with comments | « no previous file | content/browser/cache_storage/cache_storage_dispatcher_host.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « no previous file | content/browser/cache_storage/cache_storage_dispatcher_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698