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 WebServiceWorkerCacheStorage_h | 5 #ifndef WebServiceWorkerCacheStorage_h |
6 #define WebServiceWorkerCacheStorage_h | 6 #define WebServiceWorkerCacheStorage_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/WebString.h" | 10 #include "public/platform/WebString.h" |
11 #include "public/platform/WebVector.h" | 11 #include "public/platform/WebVector.h" |
12 #include "public/platform/modules/serviceworker/WebServiceWorkerCache.h" | 12 #include "public/platform/modules/serviceworker/WebServiceWorkerCache.h" |
13 #include "public/platform/modules/serviceworker/WebServiceWorkerCacheError.h" | 13 #include "public/platform/modules/serviceworker/WebServiceWorkerCacheError.h" |
14 | 14 |
15 #include <memory> | 15 #include <memory> |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 | 18 |
19 class WebServiceWorkerCache; | 19 class WebServiceWorkerCache; |
20 | 20 |
21 // An interface to the CacheStorage API, implemented by the embedder and passed
in to Blink. Blink's implementation | 21 // An interface to the CacheStorage API, implemented by the embedder and passed |
22 // of the ServiceWorker spec will call these methods to create/open caches, and
expect callbacks from the embedder | 22 // in to Blink. Blink's implementation of the ServiceWorker spec will call these |
23 // after operations complete. | 23 // methods to create/open caches, and expect callbacks from the embedder after |
| 24 // operations complete. |
24 class WebServiceWorkerCacheStorage { | 25 class WebServiceWorkerCacheStorage { |
25 public: | 26 public: |
26 using CacheStorageCallbacks = WebCallbacks<void, WebServiceWorkerCacheError>; | 27 using CacheStorageCallbacks = WebCallbacks<void, WebServiceWorkerCacheError>; |
27 using CacheStorageWithCacheCallbacks = | 28 using CacheStorageWithCacheCallbacks = |
28 WebCallbacks<std::unique_ptr<WebServiceWorkerCache>, | 29 WebCallbacks<std::unique_ptr<WebServiceWorkerCache>, |
29 WebServiceWorkerCacheError>; | 30 WebServiceWorkerCacheError>; |
30 using CacheStorageKeysCallbacks = | 31 using CacheStorageKeysCallbacks = |
31 WebCallbacks<const WebVector<WebString>&, WebServiceWorkerCacheError>; | 32 WebCallbacks<const WebVector<WebString>&, WebServiceWorkerCacheError>; |
32 using CacheStorageMatchCallbacks = | 33 using CacheStorageMatchCallbacks = |
33 WebCallbacks<const WebServiceWorkerResponse&, WebServiceWorkerCacheError>; | 34 WebCallbacks<const WebServiceWorkerResponse&, WebServiceWorkerCacheError>; |
34 | 35 |
35 virtual ~WebServiceWorkerCacheStorage() {} | 36 virtual ~WebServiceWorkerCacheStorage() {} |
36 | 37 |
37 // Ownership of the CacheStorage*Callbacks methods passes to the WebServiceWor
kerCacheStorage instance, which | 38 // Ownership of the CacheStorage*Callbacks methods passes to the |
38 // will delete it after calling onSuccess or onFailure. | 39 // WebServiceWorkerCacheStorage instance, which will delete it after calling |
| 40 // onSuccess or onFailure. |
39 | 41 |
40 // dispatchOpen() can return a WebServiceWorkerCache object. These | 42 // dispatchOpen() can return a WebServiceWorkerCache object. These objects |
41 // objects are owned by Blink and should be destroyed when they are no | 43 // are owned by Blink and should be destroyed when they are no longer needed. |
42 // longer needed. | |
43 virtual void dispatchHas(CacheStorageCallbacks*, | 44 virtual void dispatchHas(CacheStorageCallbacks*, |
44 const WebString& cacheName) = 0; | 45 const WebString& cacheName) = 0; |
45 virtual void dispatchOpen(CacheStorageWithCacheCallbacks*, | 46 virtual void dispatchOpen(CacheStorageWithCacheCallbacks*, |
46 const WebString& cacheName) = 0; | 47 const WebString& cacheName) = 0; |
47 virtual void dispatchDelete(CacheStorageCallbacks*, | 48 virtual void dispatchDelete(CacheStorageCallbacks*, |
48 const WebString& cacheName) = 0; | 49 const WebString& cacheName) = 0; |
49 virtual void dispatchKeys(CacheStorageKeysCallbacks*) = 0; | 50 virtual void dispatchKeys(CacheStorageKeysCallbacks*) = 0; |
50 virtual void dispatchMatch(CacheStorageMatchCallbacks*, | 51 virtual void dispatchMatch(CacheStorageMatchCallbacks*, |
51 const WebServiceWorkerRequest&, | 52 const WebServiceWorkerRequest&, |
52 const WebServiceWorkerCache::QueryParams&) = 0; | 53 const WebServiceWorkerCache::QueryParams&) = 0; |
53 }; | 54 }; |
54 | 55 |
55 } // namespace blink | 56 } // namespace blink |
56 | 57 |
57 #endif // WebServiceWorkerCacheStorage_h | 58 #endif // WebServiceWorkerCacheStorage_h |
OLD | NEW |