| 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 class CacheMatchCallbacks : public WebCallbacks<const WebServiceWorkerRespon
se&, WebServiceWorkerCacheError> { | 23 using CacheMatchCallbacks = WebCallbacks<const WebServiceWorkerResponse&, We
bServiceWorkerCacheError>; |
| 24 public: | 24 using CacheWithResponsesCallbacks = WebCallbacks<const WebVector<WebServiceW
orkerResponse>&, WebServiceWorkerCacheError>; |
| 25 void onSuccess(WebServiceWorkerResponse* r) { onSuccess(*r); } | 25 using CacheWithRequestsCallbacks = WebCallbacks<const WebVector<WebServiceWo
rkerRequest>&, WebServiceWorkerCacheError>; |
| 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 }; | |
| 56 using CacheBatchCallbacks = WebCallbacks<void, WebServiceWorkerCacheError>; | 26 using CacheBatchCallbacks = WebCallbacks<void, WebServiceWorkerCacheError>; |
| 57 | 27 |
| 58 virtual ~WebServiceWorkerCache() { } | 28 virtual ~WebServiceWorkerCache() { } |
| 59 | 29 |
| 60 // Options that affect the scope of searches. | 30 // Options that affect the scope of searches. |
| 61 struct QueryParams { | 31 struct QueryParams { |
| 62 QueryParams() : ignoreSearch(false), ignoreMethod(false), ignoreVary(fal
se) { } | 32 QueryParams() : ignoreSearch(false), ignoreMethod(false), ignoreVary(fal
se) { } |
| 63 | 33 |
| 64 bool ignoreSearch; | 34 bool ignoreSearch; |
| 65 bool ignoreMethod; | 35 bool ignoreMethod; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 89 // calling onSuccess or onFailure. | 59 // calling onSuccess or onFailure. |
| 90 virtual void dispatchMatch(CacheMatchCallbacks*, const WebServiceWorkerReque
st&, const QueryParams&) = 0; | 60 virtual void dispatchMatch(CacheMatchCallbacks*, const WebServiceWorkerReque
st&, const QueryParams&) = 0; |
| 91 virtual void dispatchMatchAll(CacheWithResponsesCallbacks*, const WebService
WorkerRequest&, const QueryParams&) = 0; | 61 virtual void dispatchMatchAll(CacheWithResponsesCallbacks*, const WebService
WorkerRequest&, const QueryParams&) = 0; |
| 92 virtual void dispatchKeys(CacheWithRequestsCallbacks*, const WebServiceWorke
rRequest*, const QueryParams&) = 0; | 62 virtual void dispatchKeys(CacheWithRequestsCallbacks*, const WebServiceWorke
rRequest*, const QueryParams&) = 0; |
| 93 virtual void dispatchBatch(CacheBatchCallbacks*, const WebVector<BatchOperat
ion>&) = 0; | 63 virtual void dispatchBatch(CacheBatchCallbacks*, const WebVector<BatchOperat
ion>&) = 0; |
| 94 }; | 64 }; |
| 95 | 65 |
| 96 } // namespace blink | 66 } // namespace blink |
| 97 | 67 |
| 98 #endif // WebServiceWorkerCache_h | 68 #endif // WebServiceWorkerCache_h |
| OLD | NEW |