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

Side by Side Diff: public/platform/WebServiceWorkerCache.h

Issue 433793002: Introducing the WebServiceWorkerCache. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: remediate Created 6 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
OLDNEW
(Empty)
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.
4
5 #ifndef WebServiceWorkerCache_h
6 #define WebServiceWorkerCache_h
7
8 #include "WebCommon.h"
9 #include "public/platform/WebCallbacks.h"
10 #include "public/platform/WebServiceWorkerCacheError.h"
11 #include "public/platform/WebServiceWorkerRequest.h"
12 #include "public/platform/WebServiceWorkerResponse.h"
13 #include "public/platform/WebString.h"
14 #include "public/platform/WebVector.h"
15
16 namespace blink {
17
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.
20 // This object is owned by Blink, and should be destroyed as each Cache instance is no longer in use.
21 class WebServiceWorkerCache {
22 public:
23 typedef WebCallbacks<WebServiceWorkerResponse, WebServiceWorkerCacheError> C acheMatchCallbacks;
24 typedef WebCallbacks<WebVector<WebServiceWorkerResponse>, WebServiceWorkerCa cheError> CacheWithResponsesCallbacks;
25 typedef WebCallbacks<WebVector<WebServiceWorkerRequest>, WebServiceWorkerCac heError> CacheWithRequestsCallbacks;
26
27 virtual ~WebServiceWorkerCache() { }
28
29 // The ProxyInterface is used to allow a single object in Blink to serve as its interface in JavaScript; so that == will
30 // always test two interfaces to the same cache as equal.
31 class ProxyInterface {
32 public:
33 virtual inline ~ProxyInterface() = 0;
34 };
35
36 // Options that affect the scope of searches.
37 struct QueryParams {
38 QueryParams() : ignoreSearch(false), ignoreMethod(false), ignoreVary(fal se), prefixMatch(false) { }
39
40 bool ignoreSearch;
41 bool ignoreMethod;
42 bool ignoreVary;
43 bool prefixMatch;
44 };
45
46 enum WebServiceWorkerCacheOperationType {
47 WebServiceWorkerCacheOperationTypeUndefined,
48 WebServiceWorkerCacheOperationTypePut,
49 WebServiceWorkerCacheOperationTypeDelete,
50 WebServiceWorkerCacheOperationTypeLast = WebServiceWorkerCacheOperationT ypeDelete
51 };
52
53 struct BatchOperation {
54 BatchOperation() : operationType(WebServiceWorkerCacheOperationTypeUndef ined) { }
55
56 WebServiceWorkerCacheOperationType operationType;
57 WebServiceWorkerRequest request;
58 WebServiceWorkerResponse response;
59 QueryParams matchParams;
60 };
61
62 WebServiceWorkerCache() : m_proxyInterface(0) { }
63
64 void setProxyInterface(ProxyInterface* proxyInterface) { m_proxyInterface = proxyInterface; }
65 ProxyInterface* proxyInterface() { return m_proxyInterface; }
66
67 // Ownership of the Cache*Callbacks methods passes to the WebServiceWorkerCa che instance, which will delete it after
68 // calling onSuccess or onFailure.
69 virtual void dispatchMatch(CacheMatchCallbacks*, const WebServiceWorkerReque st&, const QueryParams&) = 0;
70 virtual void dispatchMatchAll(CacheWithResponsesCallbacks*, const WebService WorkerRequest&, const QueryParams&) = 0;
71 virtual void dispatchKeys(CacheWithRequestsCallbacks*, const WebServiceWorke rRequest*, const QueryParams&) = 0;
72 virtual void dispatchBatch(CacheWithResponsesCallbacks*, const WebVector<Bat chOperation>&) = 0;
73
74 private:
75 // The Cache is owned by the embedder, and should not be deleted from within Blink; instead use notifyDone(), above.
dominicc (has gone to gerrit) 2014/08/14 02:35:12 Ah... can you clarify what you mean by "the cache"
gavinp 2014/08/14 22:34:07 This comment is vestigial. Removing it.
76
77 ProxyInterface* m_proxyInterface;
78 };
79
80 // The pure virtual destructor makes the interface abstract, but we still want a n inline destructor for descendents to call. Thus we
81 // use the inline keyword and provide an out of line definition.
82 inline WebServiceWorkerCache::ProxyInterface::~ProxyInterface() { }
83
84 } // namespace blink
85
86 #endif // WebServiceWorkerCache_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698