OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef WebServiceWorkerCache_h | 5 #ifndef WebServiceWorkerCache_h |
6 #define WebServiceWorkerCache_h | 6 #define WebServiceWorkerCache_h |
7 | 7 |
8 #include "public/platform/WebCallbacks.h" | 8 #include "public/platform/WebCallbacks.h" |
9 #include "public/platform/WebCommon.h" | 9 #include "public/platform/WebCommon.h" |
10 #include "public/platform/WebServiceWorkerCacheError.h" | 10 #include "public/platform/WebServiceWorkerCacheError.h" |
11 #include "public/platform/WebServiceWorkerRequest.h" | 11 #include "public/platform/WebServiceWorkerRequest.h" |
12 #include "public/platform/WebServiceWorkerResponse.h" | 12 #include "public/platform/WebServiceWorkerResponse.h" |
13 #include "public/platform/WebString.h" | 13 #include "public/platform/WebString.h" |
14 #include "public/platform/WebVector.h" | 14 #include "public/platform/WebVector.h" |
15 | 15 |
16 namespace blink { | 16 namespace blink { |
17 | 17 |
18 // The Service Worker Cache API. The embedder provides the implementation of the
Cache to Blink. Blink uses the interface | 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. | 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. | 20 // This object is owned by Blink, and should be destroyed as each Cache instance
is no longer in use. |
21 class WebServiceWorkerCache { | 21 class WebServiceWorkerCache { |
22 public: | 22 public: |
23 using CacheMatchCallbacks = WebCallbacks<WebServiceWorkerResponse*, WebServi
ceWorkerCacheError*>; | 23 class CacheMatchCallbacks : public WebCallbacks<const WebServiceWorkerRespon
se&, WebServiceWorkerCacheError> { |
24 using CacheWithResponsesCallbacks = WebCallbacks<WebVector<WebServiceWorkerR
esponse>*, WebServiceWorkerCacheError*>; | 24 public: |
25 using CacheWithRequestsCallbacks = WebCallbacks<WebVector<WebServiceWorkerRe
quest>*, WebServiceWorkerCacheError*>; | 25 void onSuccess(WebServiceWorkerResponse* r) { onSuccess(*r); } |
| 26 void onError(WebServiceWorkerCacheError* e) |
| 27 { |
| 28 onError(*e); |
| 29 delete e; |
| 30 } |
| 31 void onSuccess(const WebServiceWorkerResponse&) override {} |
| 32 void onError(WebServiceWorkerCacheError) override {} |
| 33 }; |
| 34 class CacheWithResponsesCallbacks : public WebCallbacks<const WebVector<WebS
erviceWorkerResponse>&, WebServiceWorkerCacheError> { |
| 35 public: |
| 36 void onSuccess(WebVector<WebServiceWorkerResponse>* r) { onSuccess(*r);
} |
| 37 void onError(WebServiceWorkerCacheError* e) |
| 38 { |
| 39 onError(*e); |
| 40 delete e; |
| 41 } |
| 42 void onSuccess(const WebVector<WebServiceWorkerResponse>&) override {} |
| 43 void onError(WebServiceWorkerCacheError) override {} |
| 44 }; |
| 45 class CacheWithRequestsCallbacks : public WebCallbacks<const WebVector<WebSe
rviceWorkerRequest>&, WebServiceWorkerCacheError> { |
| 46 public: |
| 47 void onSuccess(WebVector<WebServiceWorkerRequest>* r) { onSuccess(*r); } |
| 48 void onError(WebServiceWorkerCacheError* e) |
| 49 { |
| 50 onError(*e); |
| 51 delete e; |
| 52 } |
| 53 void onSuccess(const WebVector<WebServiceWorkerRequest>&) override {} |
| 54 void onError(WebServiceWorkerCacheError) override {} |
| 55 }; |
26 using CacheBatchCallbacks = WebCallbacks<void, WebServiceWorkerCacheError>; | 56 using CacheBatchCallbacks = WebCallbacks<void, WebServiceWorkerCacheError>; |
27 | 57 |
28 virtual ~WebServiceWorkerCache() { } | 58 virtual ~WebServiceWorkerCache() { } |
29 | 59 |
30 // Options that affect the scope of searches. | 60 // Options that affect the scope of searches. |
31 struct QueryParams { | 61 struct QueryParams { |
32 QueryParams() : ignoreSearch(false), ignoreMethod(false), ignoreVary(fal
se) { } | 62 QueryParams() : ignoreSearch(false), ignoreMethod(false), ignoreVary(fal
se) { } |
33 | 63 |
34 bool ignoreSearch; | 64 bool ignoreSearch; |
35 bool ignoreMethod; | 65 bool ignoreMethod; |
(...skipping 23 matching lines...) Expand all Loading... |
59 // calling onSuccess or onFailure. | 89 // calling onSuccess or onFailure. |
60 virtual void dispatchMatch(CacheMatchCallbacks*, const WebServiceWorkerReque
st&, const QueryParams&) = 0; | 90 virtual void dispatchMatch(CacheMatchCallbacks*, const WebServiceWorkerReque
st&, const QueryParams&) = 0; |
61 virtual void dispatchMatchAll(CacheWithResponsesCallbacks*, const WebService
WorkerRequest&, const QueryParams&) = 0; | 91 virtual void dispatchMatchAll(CacheWithResponsesCallbacks*, const WebService
WorkerRequest&, const QueryParams&) = 0; |
62 virtual void dispatchKeys(CacheWithRequestsCallbacks*, const WebServiceWorke
rRequest*, const QueryParams&) = 0; | 92 virtual void dispatchKeys(CacheWithRequestsCallbacks*, const WebServiceWorke
rRequest*, const QueryParams&) = 0; |
63 virtual void dispatchBatch(CacheBatchCallbacks*, const WebVector<BatchOperat
ion>&) = 0; | 93 virtual void dispatchBatch(CacheBatchCallbacks*, const WebVector<BatchOperat
ion>&) = 0; |
64 }; | 94 }; |
65 | 95 |
66 } // namespace blink | 96 } // namespace blink |
67 | 97 |
68 #endif // WebServiceWorkerCache_h | 98 #endif // WebServiceWorkerCache_h |
OLD | NEW |