Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Side by Side Diff: public/platform/modules/serviceworker/WebServiceWorkerCacheStorage.h

Issue 1284173004: [CacheStorage] Use appopriate type parameters for WebCallbacks (1/3). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « public/platform/modules/serviceworker/WebServiceWorkerCache.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/WebPassOwnPtr.h"
10 #include "public/platform/WebServiceWorkerCache.h" 11 #include "public/platform/WebServiceWorkerCache.h"
11 #include "public/platform/WebServiceWorkerCacheError.h" 12 #include "public/platform/WebServiceWorkerCacheError.h"
12 #include "public/platform/WebString.h" 13 #include "public/platform/WebString.h"
13 #include "public/platform/WebVector.h" 14 #include "public/platform/WebVector.h"
14 15
15 namespace blink { 16 namespace blink {
16 17
17 class WebServiceWorkerCache; 18 class WebServiceWorkerCache;
18 19
19 // An interface to the CacheStorage API, implemented by the embedder and passed in to Blink. Blink's implementation 20 // An interface to the CacheStorage API, implemented by the embedder and passed in to Blink. Blink's implementation
20 // of the ServiceWorker spec will call these methods to create/open caches, and expect callbacks from the embedder 21 // of the ServiceWorker spec will call these methods to create/open caches, and expect callbacks from the embedder
21 // after operations complete. 22 // after operations complete.
22 class WebServiceWorkerCacheStorage { 23 class WebServiceWorkerCacheStorage {
23 public: 24 public:
24 typedef WebCallbacks<void, WebServiceWorkerCacheError*> CacheStorageCallback s; 25 class CacheStorageCallbacks : public WebCallbacks<void, WebServiceWorkerCach eError> {
25 typedef WebCallbacks<WebServiceWorkerCache*, WebServiceWorkerCacheError*> Ca cheStorageWithCacheCallbacks; 26 public:
26 typedef WebCallbacks<WebVector<WebString>*, WebServiceWorkerCacheError*> Cac heStorageKeysCallbacks; 27 void onError(WebServiceWorkerCacheError* e)
27 typedef WebCallbacks<WebServiceWorkerResponse*, WebServiceWorkerCacheError*> CacheStorageMatchCallbacks; 28 {
29 onError(*e);
30 delete e;
31 }
32 void onError(WebServiceWorkerCacheError) override {}
33 };
34 class CacheStorageWithCacheCallbacks : public WebCallbacks<WebPassOwnPtr<Web ServiceWorkerCache>, WebServiceWorkerCacheError> {
35 public:
36 void onSuccess(WebServiceWorkerCache* r)
37 {
38 onSuccess(adoptWebPtr(r));
39 }
40 void onError(WebServiceWorkerCacheError* e)
41 {
42 onError(*e);
43 delete e;
44 }
45 void onSuccess(WebPassOwnPtr<WebServiceWorkerCache>) override {}
46 void onError(WebServiceWorkerCacheError) override {}
47 };
48 class CacheStorageKeysCallbacks : public WebCallbacks<const WebVector<WebStr ing>&, WebServiceWorkerCacheError> {
49 public:
50 void onSuccess(WebVector<WebString>* r) { onSuccess(*r); }
51 void onError(WebServiceWorkerCacheError* e)
52 {
53 onError(*e);
54 delete e;
55 }
56 void onSuccess(const WebVector<WebString>&) override {}
57 void onError(WebServiceWorkerCacheError) override {}
58 };
59 class CacheStorageMatchCallbacks : public WebCallbacks<const WebServiceWorke rResponse&, WebServiceWorkerCacheError> {
60 public:
61 void onSuccess(WebServiceWorkerResponse* r) { onSuccess(*r); }
62 void onError(WebServiceWorkerCacheError* e)
63 {
64 onError(*e);
65 delete e;
66 }
67 void onSuccess(const WebServiceWorkerResponse&) override {}
68 void onError(WebServiceWorkerCacheError) override {}
69 };
28 70
29 virtual ~WebServiceWorkerCacheStorage() { } 71 virtual ~WebServiceWorkerCacheStorage() { }
30 72
31 // Ownership of the CacheStorage*Callbacks methods passes to the WebServiceW orkerCacheStorage instance, which 73 // Ownership of the CacheStorage*Callbacks methods passes to the WebServiceW orkerCacheStorage instance, which
32 // will delete it after calling onSuccess or onFailure. 74 // will delete it after calling onSuccess or onFailure.
33 75
34 // dispatchOpen() can return a WebServiceWorkerCache object. These 76 // dispatchOpen() can return a WebServiceWorkerCache object. These
35 // objects are owned by Blink and should be destroyed when they are no 77 // objects are owned by Blink and should be destroyed when they are no
36 // longer needed. 78 // longer needed.
37 virtual void dispatchHas(CacheStorageCallbacks*, const WebString& cacheName) = 0; 79 virtual void dispatchHas(CacheStorageCallbacks*, const WebString& cacheName) = 0;
38 virtual void dispatchOpen(CacheStorageWithCacheCallbacks*, const WebString& cacheName) = 0; 80 virtual void dispatchOpen(CacheStorageWithCacheCallbacks*, const WebString& cacheName) = 0;
39 virtual void dispatchDelete(CacheStorageCallbacks*, const WebString& cacheNa me) = 0; 81 virtual void dispatchDelete(CacheStorageCallbacks*, const WebString& cacheNa me) = 0;
40 virtual void dispatchKeys(CacheStorageKeysCallbacks*) = 0; 82 virtual void dispatchKeys(CacheStorageKeysCallbacks*) = 0;
41 virtual void dispatchMatch(CacheStorageMatchCallbacks*, const WebServiceWork erRequest&, const WebServiceWorkerCache::QueryParams&) = 0; 83 virtual void dispatchMatch(CacheStorageMatchCallbacks*, const WebServiceWork erRequest&, const WebServiceWorkerCache::QueryParams&) = 0;
42 }; 84 };
43 85
44 } // namespace blink 86 } // namespace blink
45 87
46 #endif // WebServiceWorkerCacheStorage_h 88 #endif // WebServiceWorkerCacheStorage_h
OLDNEW
« no previous file with comments | « public/platform/modules/serviceworker/WebServiceWorkerCache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698