OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef WebServiceWorkerCache_h |
| 6 #define WebServiceWorkerCache_h |
| 7 |
| 8 #include "WebCommon.h" |
| 9 #include "public/platform/WebCallbacks.h" |
| 10 #include "public/platform/WebServiceWorkerCacheError.h" |
| 11 #include "public/platform/WebServiceWorkerRequest.h" |
| 12 #include "public/platform/WebServiceWorkerResponse.h" |
| 13 #include "public/platform/WebString.h" |
| 14 #include "public/platform/WebVector.h" |
| 15 |
| 16 namespace blink { |
| 17 |
| 18 // The Service Worker Cache API. The embedder provides the implementation of the
Cache to Blink. Blink uses the interface |
| 19 // to operate on entries. |
| 20 // This object is owned by Blink, and should be destroyed as each Cache instance
is no longer in use. |
| 21 class WebServiceWorkerCache { |
| 22 public: |
| 23 typedef WebCallbacks<WebServiceWorkerResponse, WebServiceWorkerCacheError> C
acheMatchCallbacks; |
| 24 typedef WebCallbacks<WebVector<WebServiceWorkerResponse>, WebServiceWorkerCa
cheError> CacheWithResponsesCallbacks; |
| 25 typedef WebCallbacks<WebVector<WebServiceWorkerRequest>, WebServiceWorkerCac
heError> CacheWithRequestsCallbacks; |
| 26 |
| 27 virtual ~WebServiceWorkerCache() { } |
| 28 |
| 29 // Blink can store its internal interface to this object as a ProxyInterface
in the WebServiceWorkerCache. This allows |
| 30 // blink to quickly find the correct internal interface when it is passed th
e same WebServiceWorkerCache object. |
| 31 class ProxyInterface { |
| 32 public: |
| 33 virtual inline ~ProxyInterface() = 0; |
| 34 }; |
| 35 |
| 36 // Options that affect the scope of searches. |
| 37 struct QueryParams { |
| 38 QueryParams() : ignoreSearch(false), ignoreMethod(false), ignoreVary(fal
se), prefixMatch(false) { } |
| 39 |
| 40 bool ignoreSearch; |
| 41 bool ignoreMethod; |
| 42 bool ignoreVary; |
| 43 bool prefixMatch; |
| 44 WebString cacheName; |
| 45 }; |
| 46 |
| 47 enum WebServiceWorkerCacheOperationType { |
| 48 WebServiceWorkerCacheOperationTypeUndefined, |
| 49 WebServiceWorkerCacheOperationTypePut, |
| 50 WebServiceWorkerCacheOperationTypeDelete, |
| 51 WebServiceWorkerCacheOperationTypeLast = WebServiceWorkerCacheOperationT
ypeDelete |
| 52 }; |
| 53 |
| 54 struct BatchOperation { |
| 55 BatchOperation() : operationType(WebServiceWorkerCacheOperationTypeUndef
ined) { } |
| 56 |
| 57 WebServiceWorkerCacheOperationType operationType; |
| 58 WebServiceWorkerRequest request; |
| 59 WebServiceWorkerResponse response; |
| 60 QueryParams matchParams; |
| 61 }; |
| 62 |
| 63 WebServiceWorkerCache() : m_proxyInterface(0) { } |
| 64 |
| 65 void setProxyInterface(ProxyInterface* proxyInterface) { m_proxyInterface =
proxyInterface; } |
| 66 ProxyInterface* proxyInterface() { return m_proxyInterface; } |
| 67 |
| 68 // Ownership of the Cache*Callbacks methods passes to the WebServiceWorkerCa
che instance, which will delete it after |
| 69 // calling onSuccess or onFailure. |
| 70 virtual void dispatchMatch(CacheMatchCallbacks*, const WebServiceWorkerReque
st&, const QueryParams&) = 0; |
| 71 virtual void dispatchMatchAll(CacheWithResponsesCallbacks*, const WebService
WorkerRequest&, const QueryParams&) = 0; |
| 72 virtual void dispatchKeys(CacheWithRequestsCallbacks*, const WebServiceWorke
rRequest*, const QueryParams&) = 0; |
| 73 virtual void dispatchBatch(CacheWithResponsesCallbacks*, const WebVector<Bat
chOperation>&) = 0; |
| 74 |
| 75 private: |
| 76 ProxyInterface* m_proxyInterface; |
| 77 }; |
| 78 |
| 79 // The pure virtual destructor makes the interface abstract, but we still want a
n inline destructor for descendents to call. Thus we |
| 80 // use the inline keyword and provide an out of line definition. |
| 81 inline WebServiceWorkerCache::ProxyInterface::~ProxyInterface() { } |
| 82 |
| 83 } // namespace blink |
| 84 |
| 85 #endif // WebServiceWorkerCache_h |
OLD | NEW |