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.
5 #ifndef WebServiceWorkerCacheStorage_h
6 #define WebServiceWorkerCacheStorage_h
9 #include "public/platform/WebCallbacks.h"
10 #include "public/platform/WebServiceWorkerCacheError.h"
11 #include "public/platform/WebString.h"
12 #include "public/platform/WebVector.h"
16 class WebServiceWorkerCache;
18 // An interface to the CacheStorage API, implemented by the embedder and passed in to Blink. Blink's implementation
19 // of the ServiceWorker spec will call these methods to create/open caches, and expect callbacks from the embedder
20 // after operations complete.
21 class WebServiceWorkerCacheStorage {
23 typedef WebCallbacks<void, WebServiceWorkerCacheError> CacheStorageCallbacks;
24 typedef WebCallbacks<WebServiceWorkerCache, WebServiceWorkerCacheError> CacheStorageWithCacheCallbacks;
25 typedef WebCallbacks<WebVector<WebString>, WebServiceWorkerCacheError> CacheStorageKeysCallbacks;
27 virtual ~WebServiceWorkerCacheStorage() { }
29 // Ownership of the CacheStorage*Callbacks methods passes to the WebServiceWorkerCacheStorage instance, which
30 // will delete it after calling onSuccess or onFailure.
32 // dispatchOpen() can return a WebServiceWorkerCache object. These
33 // objects are owned by Blink and should be destroyed when they are no
35 virtual void dispatchHas(CacheStorageCallbacks*, const WebString& cacheName) = 0;
36 virtual void dispatchOpen(CacheStorageWithCacheCallbacks*, const WebString& cacheName) = 0;
37 virtual void dispatchDelete(CacheStorageCallbacks*, const WebString& cacheName) = 0;
38 virtual void dispatchKeys(CacheStorageKeysCallbacks*) = 0;
43 #endif // WebServiceWorkerCacheStorage_h