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 // An interface to the Cache API, implemented by the embedder and passed in to b link. Blink's implementation | |
dominicc (has gone to gerrit)
2014/08/11 01:40:41
blink -> Blink; below too.
I would only write bli
dominicc (has gone to gerrit)
2014/08/11 01:40:42
Can this be tightened up? "An interface to the Cac
gavinp
2014/08/13 23:25:23
Done.
gavinp
2014/08/13 23:25:23
Done.
| |
19 // of the ServiceWorker spec will call these methods to perform operations on st ores and the entries in stores, and | |
20 // will expect callbacks from the embedder after operations complete. | |
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 // The ProxyInterface is used to allow a single object in blink to serve as its interface in JavaScript; so that == will | |
28 // always test two interfaces to the same cache as equal. | |
29 class ProxyInterface { | |
dominicc (has gone to gerrit)
2014/08/11 01:40:41
Not sure about naming this ...Interface; what's th
gavinp
2014/09/04 19:47:33
It holds the blink::Cache object, which must be an
| |
30 public: | |
31 virtual inline ~ProxyInterface() = 0; | |
dominicc (has gone to gerrit)
2014/08/11 01:40:42
I guess this should be abstract by virtue of this
gavinp
2014/08/13 23:25:23
It should be abstract in order to guard against in
| |
32 }; | |
33 | |
34 // Options that affect the scope of searches. | |
35 struct QueryParams { | |
36 QueryParams() : ignoreSearch(false), ignoreMethod(false), ignoreVary(fal se), prefixMatch(false) { } | |
dominicc (has gone to gerrit)
2014/08/11 01:40:42
Regardless of how the spec has it, would it not be
gavinp
2014/08/13 23:25:23
I like this suggestion. I'll follow up with an upl
| |
37 | |
38 bool ignoreSearch; | |
39 bool ignoreMethod; | |
40 bool ignoreVary; | |
41 bool prefixMatch; | |
42 }; | |
43 | |
44 enum WebServiceWorkerCacheOperationType { | |
45 WebServiceWorkerCacheOperationTypeUndefined, | |
46 WebServiceWorkerCacheOperationTypePut, | |
47 WebServiceWorkerCacheOperationTypeDelete, | |
48 WebServiceWorkerCacheOperationTypeLast = WebServiceWorkerCacheOperationT ypeUndefined | |
49 }; | |
50 | |
51 struct BatchOperation { | |
52 BatchOperation() : operationType(WebServiceWorkerCacheOperationTypeUndef ined) { } | |
53 | |
54 WebServiceWorkerCacheOperationType operationType; | |
55 WebServiceWorkerRequest request; | |
56 WebServiceWorkerResponse response; | |
57 QueryParams matchParams; | |
58 }; | |
59 | |
60 WebServiceWorkerCache() : m_proxyInterface(0) { } | |
61 virtual ~WebServiceWorkerCache() { } | |
62 | |
63 void setProxyInterface(ProxyInterface* proxyInterface) { m_proxyInterface = proxyInterface; } | |
dominicc (has gone to gerrit)
2014/08/11 01:40:42
Classes here usually fall into one of four categor
gavinp
2014/08/13 23:25:23
I'm going to set up a VC for us to talk about this
| |
64 ProxyInterface* proxyInterface() { return m_proxyInterface; } | |
65 | |
66 // Ownership of the Cache*Callbacks methods passes to the WebServiceWorkerCa che instance, which will delete it after | |
67 // calling onSuccess or onFailure. | |
68 virtual void dispatchMatch(CacheMatchCallbacks*, const WebServiceWorkerReque st&, const QueryParams&) = 0; | |
69 virtual void dispatchMatchAll(CacheWithResponsesCallbacks*, const WebService WorkerRequest&, const QueryParams&) = 0; | |
70 virtual void dispatchKeys(CacheWithRequestsCallbacks*, const WebServiceWorke rRequest*, const QueryParams&) = 0; | |
71 virtual void dispatchBatch(CacheWithResponsesCallbacks*, const WebVector<Bat chOperation>&) = 0; | |
72 | |
73 // Called when blink is no longer using this object. | |
74 virtual void notifyDone() = 0; | |
dominicc (has gone to gerrit)
2014/08/11 01:40:42
This method has a very generic name for a very spe
gavinp
2014/08/13 23:25:23
And it's gone in the latest upload, as I cleared u
| |
75 | |
76 private: | |
77 ProxyInterface* m_proxyInterface; | |
78 }; | |
79 | |
80 // The pure virtual destructor makes the interface abstract, but we still want a n inline destructor for descendents to call. Thus we | |
dominicc (has gone to gerrit)
2014/08/11 01:40:42
If it's mysterious enough to warrant a comment, is
gavinp
2014/08/13 23:25:23
I don't know. I added the comment because the last
dominicc (has gone to gerrit)
2014/08/14 02:35:12
I'm fine with the inline virtual destructor either
| |
81 // use the inline keyword and provide an out of line definition. | |
82 inline WebServiceWorkerCache::ProxyInterface::~ProxyInterface() { } | |
83 | |
84 } // namespace blink | |
85 | |
86 #endif // WebServiceWorkerCache_h | |
OLD | NEW |