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 // The ProxyInterface is used to allow a single object in Blink to serve as its interface in JavaScript; so that == will | |
dominicc (has gone to gerrit)
2014/08/15 06:20:24
I feel like there's redundancy here with the bit a
gavinp
2014/08/19 21:09:37
How do you like that rewrite?
| |
30 // always test two interfaces to the same cache as equal. | |
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 }; | |
45 | |
46 enum WebServiceWorkerCacheOperationType { | |
47 WebServiceWorkerCacheOperationTypeUndefined, | |
48 WebServiceWorkerCacheOperationTypePut, | |
49 WebServiceWorkerCacheOperationTypeDelete, | |
50 WebServiceWorkerCacheOperationTypeLast = WebServiceWorkerCacheOperationT ypeDelete | |
51 }; | |
52 | |
53 struct BatchOperation { | |
54 BatchOperation() : operationType(WebServiceWorkerCacheOperationTypeUndef ined) { } | |
55 | |
56 WebServiceWorkerCacheOperationType operationType; | |
57 WebServiceWorkerRequest request; | |
58 WebServiceWorkerResponse response; | |
59 QueryParams matchParams; | |
60 }; | |
61 | |
62 WebServiceWorkerCache() : m_proxyInterface(0) { } | |
63 | |
64 void setProxyInterface(ProxyInterface* proxyInterface) { m_proxyInterface = proxyInterface; } | |
65 ProxyInterface* proxyInterface() { return m_proxyInterface; } | |
66 | |
67 // Ownership of the Cache*Callbacks methods passes to the WebServiceWorkerCa che instance, which will delete it after | |
68 // calling onSuccess or onFailure. | |
69 virtual void dispatchMatch(CacheMatchCallbacks*, const WebServiceWorkerReque st&, const QueryParams&) = 0; | |
70 virtual void dispatchMatchAll(CacheWithResponsesCallbacks*, const WebService WorkerRequest&, const QueryParams&) = 0; | |
71 virtual void dispatchKeys(CacheWithRequestsCallbacks*, const WebServiceWorke rRequest*, const QueryParams&) = 0; | |
72 virtual void dispatchBatch(CacheWithResponsesCallbacks*, const WebVector<Bat chOperation>&) = 0; | |
73 | |
74 private: | |
75 ProxyInterface* m_proxyInterface; | |
76 }; | |
77 | |
78 // The pure virtual destructor makes the interface abstract, but we still want a n inline destructor for descendents to call. Thus we | |
79 // use the inline keyword and provide an out of line definition. | |
80 inline WebServiceWorkerCache::ProxyInterface::~ProxyInterface() { } | |
81 | |
82 } // namespace blink | |
83 | |
84 #endif // WebServiceWorkerCache_h | |
OLD | NEW |