Chromium Code Reviews| Index: public/platform/WebServiceWorkerCache.h |
| diff --git a/public/platform/WebServiceWorkerCache.h b/public/platform/WebServiceWorkerCache.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..fc1bd3c7ec9d07a27b983399ae14eaa2420370ef |
| --- /dev/null |
| +++ b/public/platform/WebServiceWorkerCache.h |
| @@ -0,0 +1,86 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef WebServiceWorkerCache_h |
| +#define WebServiceWorkerCache_h |
| + |
| +#include "WebCommon.h" |
| +#include "public/platform/WebCallbacks.h" |
| +#include "public/platform/WebServiceWorkerCacheError.h" |
| +#include "public/platform/WebServiceWorkerRequest.h" |
| +#include "public/platform/WebServiceWorkerResponse.h" |
| +#include "public/platform/WebString.h" |
| +#include "public/platform/WebVector.h" |
| + |
| +namespace blink { |
| + |
| +// An interface to the Cache API, implemented by the embedder and passed in to blink. Blink's implementation |
|
dominicc (has gone to gerrit)
2014/08/11 01:40:41
blink -> Blink; below too.
I would only write bli
dominicc (has gone to gerrit)
2014/08/11 01:40:42
Can this be tightened up? "An interface to the Cac
gavinp
2014/08/13 23:25:23
Done.
gavinp
2014/08/13 23:25:23
Done.
|
| +// of the ServiceWorker spec will call these methods to perform operations on stores and the entries in stores, and |
| +// will expect callbacks from the embedder after operations complete. |
| +class WebServiceWorkerCache { |
| +public: |
| + typedef WebCallbacks<WebServiceWorkerResponse, WebServiceWorkerCacheError> CacheMatchCallbacks; |
| + typedef WebCallbacks<WebVector<WebServiceWorkerResponse>, WebServiceWorkerCacheError> CacheWithResponsesCallbacks; |
| + typedef WebCallbacks<WebVector<WebServiceWorkerRequest>, WebServiceWorkerCacheError> CacheWithRequestsCallbacks; |
| + |
| + // The ProxyInterface is used to allow a single object in blink to serve as its interface in JavaScript; so that == will |
| + // always test two interfaces to the same cache as equal. |
| + class ProxyInterface { |
|
dominicc (has gone to gerrit)
2014/08/11 01:40:41
Not sure about naming this ...Interface; what's th
gavinp
2014/09/04 19:47:33
It holds the blink::Cache object, which must be an
|
| + public: |
| + virtual inline ~ProxyInterface() = 0; |
|
dominicc (has gone to gerrit)
2014/08/11 01:40:42
I guess this should be abstract by virtue of this
gavinp
2014/08/13 23:25:23
It should be abstract in order to guard against in
|
| + }; |
| + |
| + // Options that affect the scope of searches. |
| + struct QueryParams { |
| + QueryParams() : ignoreSearch(false), ignoreMethod(false), ignoreVary(false), prefixMatch(false) { } |
|
dominicc (has gone to gerrit)
2014/08/11 01:40:42
Regardless of how the spec has it, would it not be
gavinp
2014/08/13 23:25:23
I like this suggestion. I'll follow up with an upl
|
| + |
| + bool ignoreSearch; |
| + bool ignoreMethod; |
| + bool ignoreVary; |
| + bool prefixMatch; |
| + }; |
| + |
| + enum WebServiceWorkerCacheOperationType { |
| + WebServiceWorkerCacheOperationTypeUndefined, |
| + WebServiceWorkerCacheOperationTypePut, |
| + WebServiceWorkerCacheOperationTypeDelete, |
| + WebServiceWorkerCacheOperationTypeLast = WebServiceWorkerCacheOperationTypeUndefined |
| + }; |
| + |
| + struct BatchOperation { |
| + BatchOperation() : operationType(WebServiceWorkerCacheOperationTypeUndefined) { } |
| + |
| + WebServiceWorkerCacheOperationType operationType; |
| + WebServiceWorkerRequest request; |
| + WebServiceWorkerResponse response; |
| + QueryParams matchParams; |
| + }; |
| + |
| + WebServiceWorkerCache() : m_proxyInterface(0) { } |
| + virtual ~WebServiceWorkerCache() { } |
| + |
| + void setProxyInterface(ProxyInterface* proxyInterface) { m_proxyInterface = proxyInterface; } |
|
dominicc (has gone to gerrit)
2014/08/11 01:40:42
Classes here usually fall into one of four categor
gavinp
2014/08/13 23:25:23
I'm going to set up a VC for us to talk about this
|
| + ProxyInterface* proxyInterface() { return m_proxyInterface; } |
| + |
| + // Ownership of the Cache*Callbacks methods passes to the WebServiceWorkerCache instance, which will delete it after |
| + // calling onSuccess or onFailure. |
| + virtual void dispatchMatch(CacheMatchCallbacks*, const WebServiceWorkerRequest&, const QueryParams&) = 0; |
| + virtual void dispatchMatchAll(CacheWithResponsesCallbacks*, const WebServiceWorkerRequest&, const QueryParams&) = 0; |
| + virtual void dispatchKeys(CacheWithRequestsCallbacks*, const WebServiceWorkerRequest*, const QueryParams&) = 0; |
| + virtual void dispatchBatch(CacheWithResponsesCallbacks*, const WebVector<BatchOperation>&) = 0; |
| + |
| + // Called when blink is no longer using this object. |
| + virtual void notifyDone() = 0; |
|
dominicc (has gone to gerrit)
2014/08/11 01:40:42
This method has a very generic name for a very spe
gavinp
2014/08/13 23:25:23
And it's gone in the latest upload, as I cleared u
|
| + |
| +private: |
| + ProxyInterface* m_proxyInterface; |
| +}; |
| + |
| +// The pure virtual destructor makes the interface abstract, but we still want an inline destructor for descendents to call. Thus we |
|
dominicc (has gone to gerrit)
2014/08/11 01:40:42
If it's mysterious enough to warrant a comment, is
gavinp
2014/08/13 23:25:23
I don't know. I added the comment because the last
dominicc (has gone to gerrit)
2014/08/14 02:35:12
I'm fine with the inline virtual destructor either
|
| +// use the inline keyword and provide an out of line definition. |
| +inline WebServiceWorkerCache::ProxyInterface::~ProxyInterface() { } |
| + |
| +} // namespace blink |
| + |
| +#endif // WebServiceWorkerCache_h |