Chromium Code Reviews| Index: content/renderer/service_worker/service_worker_cache_storage_dispatcher.h |
| diff --git a/content/renderer/service_worker/service_worker_cache_storage_dispatcher.h b/content/renderer/service_worker/service_worker_cache_storage_dispatcher.h |
| index ec454dca2c96a85fedb19ac4c0d94f609383d9a5..69a736cde2acb603bdde5a5220663d2aadb01d27 100644 |
| --- a/content/renderer/service_worker/service_worker_cache_storage_dispatcher.h |
| +++ b/content/renderer/service_worker/service_worker_cache_storage_dispatcher.h |
| @@ -1,9 +1,10 @@ |
| + |
|
dominicc (has gone to gerrit)
2014/08/15 06:48:35
Delete this blank line.
gavinp
2014/09/03 18:35:25
Done.
|
| // Copyright 2014 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_FETCH_STORES_DISPATCHER_H_ |
| -#define CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_FETCH_STORES_DISPATCHER_H_ |
| +#ifndef CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_DISPATCHER_H_ |
| +#define CONTENT_RENDERER_SERVICE_WORKER_SERVICE_WORKER_CACHE_STORAGE_DISPATCHER_H_ |
| #include <vector> |
| @@ -11,16 +12,20 @@ |
| #include "base/macros.h" |
| #include "base/strings/string16.h" |
| #include "content/public/renderer/render_process_observer.h" |
| +#include "third_party/WebKit/public/platform/WebServiceWorkerCache.h" |
| #include "third_party/WebKit/public/platform/WebServiceWorkerCacheError.h" |
| #include "third_party/WebKit/public/platform/WebServiceWorkerCacheStorage.h" |
| namespace content { |
| +struct ServiceWorkerFetchRequest; |
| class ServiceWorkerScriptContext; |
| +struct ServiceWorkerResponse; |
| // There is one ServiceWorkerCacheStorageDispatcher per |
| // ServiceWorkerScriptContext. It starts CacheStorage operations with messages |
| -// to the browser process and runs callbacks at operation completion. |
| +// to the browser process and runs callbacks at operation completion. As well, |
|
dominicc (has gone to gerrit)
2014/08/15 06:48:35
Can you rephrase to integrate with the existing co
gavinp
2014/09/03 18:35:25
Done.
|
| +// it creates and owns Cache objects and manages their lifetime. |
| class ServiceWorkerCacheStorageDispatcher |
| : public blink::WebServiceWorkerCacheStorage { |
| @@ -29,26 +34,50 @@ class ServiceWorkerCacheStorageDispatcher |
| ServiceWorkerScriptContext* script_context); |
| virtual ~ServiceWorkerCacheStorageDispatcher(); |
| + // Although this class does not register for messages in the normal way, the |
|
dominicc (has gone to gerrit)
2014/08/15 06:48:35
Be direct; the headline here is that ServiceWorker
gavinp
2014/09/03 18:35:25
Done.
|
| + // ServiceWorkerScriptContext calls it with exactly the same semantics for |
| + // receiving messages. |
| bool OnMessageReceived(const IPC::Message& message); |
| - // Message handlers for messages from the browser process. |
| + // Message handlers for CacheStorage messages from the browser process. |
| void OnCacheStorageGetSuccess(int request_id, int cache_id); |
| void OnCacheStorageHasSuccess(int request_id); |
| void OnCacheStorageCreateSuccess(int request_id, int cache_id); |
| void OnCacheStorageDeleteSuccess(int request_id); |
| void OnCacheStorageKeysSuccess(int request_id, |
| - const std::vector<base::string16>& keys); |
| + const std::vector<base::string16>& keys); |
| void OnCacheStorageGetError(int request_id, |
| - blink::WebServiceWorkerCacheError reason); |
| + blink::WebServiceWorkerCacheError reason); |
| void OnCacheStorageHasError(int request_id, |
| - blink::WebServiceWorkerCacheError reason); |
| + blink::WebServiceWorkerCacheError reason); |
| void OnCacheStorageCreateError(int request_id, |
| - blink::WebServiceWorkerCacheError reason); |
| + blink::WebServiceWorkerCacheError reason); |
| void OnCacheStorageDeleteError(int request_id, |
| - blink::WebServiceWorkerCacheError reason); |
| + blink::WebServiceWorkerCacheError reason); |
| void OnCacheStorageKeysError(int request_id, |
| - blink::WebServiceWorkerCacheError reason); |
| + blink::WebServiceWorkerCacheError reason); |
| + |
| + // Message handlers for Cache messages from the browser process. |
| + void OnCacheMatchSuccess(int request_id, |
| + const ServiceWorkerResponse& response); |
| + void OnCacheMatchAllSuccess( |
| + int request_id, |
| + const std::vector<ServiceWorkerResponse>& response); |
| + void OnCacheKeysSuccess( |
| + int request_id, |
| + const std::vector<ServiceWorkerFetchRequest>& response); |
| + void OnCacheBatchSuccess(int request_id, |
| + const std::vector<ServiceWorkerResponse>& response); |
| + |
| + void OnCacheMatchError(int request_id, |
| + blink::WebServiceWorkerCacheError reason); |
| + void OnCacheMatchAllError(int request_id, |
| + blink::WebServiceWorkerCacheError reason); |
| + void OnCacheKeysError(int request_id, |
| + blink::WebServiceWorkerCacheError reason); |
| + void OnCacheBatchError(int request_id, |
| + blink::WebServiceWorkerCacheError reason); |
| // From WebServiceWorkerCacheStorage: |
| virtual void dispatchGet(CacheStorageWithCacheCallbacks* callbacks, |
| @@ -61,13 +90,45 @@ class ServiceWorkerCacheStorageDispatcher |
| const blink::WebString& cacheName); |
| virtual void dispatchKeys(CacheStorageKeysCallbacks* callbacks); |
| + // These methods are used by WebCache to forward events to the browser |
| + // process. |
| + void dispatchMatchForCache( |
| + int cache_id, |
| + blink::WebServiceWorkerCache::CacheMatchCallbacks* callbacks, |
| + const blink::WebServiceWorkerRequest& request, |
| + const blink::WebServiceWorkerCache::QueryParams& query_params); |
| + void dispatchMatchAllForCache( |
| + int cache_id, |
| + blink::WebServiceWorkerCache::CacheWithResponsesCallbacks* callbacks, |
| + const blink::WebServiceWorkerRequest& request, |
| + const blink::WebServiceWorkerCache::QueryParams& query_params); |
| + void dispatchKeysForCache( |
| + int cache_id, |
| + blink::WebServiceWorkerCache::CacheWithRequestsCallbacks* callbacks, |
| + const blink::WebServiceWorkerRequest* request, |
| + const blink::WebServiceWorkerCache::QueryParams& query_params); |
| + void dispatchBatchForCache( |
| + int cache_id, |
| + blink::WebServiceWorkerCache::CacheWithResponsesCallbacks* callbacks, |
| + const blink::WebVector<blink::WebServiceWorkerCache::BatchOperation>& |
| + batch_operations); |
| + |
| private: |
| + class WebCache; |
| + |
| typedef IDMap<CacheStorageCallbacks, IDMapOwnPointer> CallbacksMap; |
| typedef IDMap<CacheStorageWithCacheCallbacks, IDMapOwnPointer> |
| WithCacheCallbacksMap; |
| typedef IDMap<CacheStorageKeysCallbacks, IDMapOwnPointer> |
| KeysCallbacksMap; |
| + typedef IDMap<blink::WebServiceWorkerCache::CacheMatchCallbacks, |
| + IDMapOwnPointer> MatchCallbacksMap; |
| + typedef IDMap<blink::WebServiceWorkerCache::CacheWithResponsesCallbacks, |
| + IDMapOwnPointer> WithResponsesCallbacksMap; |
| + typedef IDMap<blink::WebServiceWorkerCache::CacheWithRequestsCallbacks, |
| + IDMapOwnPointer> WithRequestsCallbacksMap; |
| + |
| // Not owned. The script context containing this object. |
| ServiceWorkerScriptContext* script_context_; |
| @@ -77,6 +138,16 @@ class ServiceWorkerCacheStorageDispatcher |
| CallbacksMap delete_callbacks_; |
| KeysCallbacksMap keys_callbacks_; |
| + // The individual caches created under this CacheStorage object. |
| + IDMap<WebCache, IDMapExternalPointer> web_caches_; |
| + |
| + // These ID maps are held in the CacheStorage object rather than the Cache |
| + // object to ensure that the IDs are unique. |
| + MatchCallbacksMap cache_match_callbacks_; |
| + WithResponsesCallbacksMap cache_match_all_callbacks_; |
| + WithRequestsCallbacksMap cache_keys_callbacks_; |
| + WithResponsesCallbacksMap cache_batch_callbacks_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(ServiceWorkerCacheStorageDispatcher); |
| }; |