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..cabef2823407c0da080a3e20e2081dd9f1651348 |
| --- /dev/null |
| +++ b/public/platform/WebServiceWorkerCache.h |
| @@ -0,0 +1,85 @@ |
| +// 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" |
|
tkent
2014/09/18 23:35:56
should be "public/platform/WebCommon.h"
gavinp
2014/09/22 16:05:24
Done.
|
| +#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 { |
| + |
| +// The Service Worker Cache API. The embedder provides the implementation of the Cache to Blink. Blink uses the interface |
| +// to operate on entries. |
| +// This object is owned by Blink, and should be destroyed as each Cache instance is no longer in use. |
| +class WebServiceWorkerCache { |
| +public: |
| + typedef WebCallbacks<WebServiceWorkerResponse, WebServiceWorkerCacheError> CacheMatchCallbacks; |
| + typedef WebCallbacks<WebVector<WebServiceWorkerResponse>, WebServiceWorkerCacheError> CacheWithResponsesCallbacks; |
| + typedef WebCallbacks<WebVector<WebServiceWorkerRequest>, WebServiceWorkerCacheError> CacheWithRequestsCallbacks; |
| + |
| + virtual ~WebServiceWorkerCache() { } |
|
gavinp
2014/09/22 16:05:24
So.... how scary is it that this destructor is inl
|
| + |
| + // Blink can store its internal interface to this object as a ProxyInterface in the WebServiceWorkerCache. This allows |
|
jsbell
2014/09/18 21:45:00
I'm not completely thrilled with the naming here,
tkent
2014/09/18 23:35:56
I have the same impression. Can we make WebServic
jsbell
2014/09/19 16:22:47
It is happening on demand; Blink has asked Chromiu
|
| + // Blink to quickly find the correct internal interface when it is passed the same WebServiceWorkerCache object. |
| + class ProxyInterface { |
| + public: |
| + virtual inline ~ProxyInterface() = 0; |
|
tkent
2014/09/18 23:35:56
Is |virtual inline| helpful?
gavinp
2014/09/22 16:05:24
Yes. It's a trivial class, with no members, so inl
jamesr
2014/09/22 16:36:03
No.
Just write this as:
virtual ~ProxyInterface(
|
| + }; |
| + |
| + // Options that affect the scope of searches. |
| + struct QueryParams { |
| + QueryParams() : ignoreSearch(false), ignoreMethod(false), ignoreVary(false), prefixMatch(false) { } |
| + |
| + bool ignoreSearch; |
| + bool ignoreMethod; |
| + bool ignoreVary; |
| + bool prefixMatch; |
| + WebString cacheName; |
| + }; |
| + |
| + enum WebServiceWorkerCacheOperationType { |
|
tkent
2014/09/18 23:35:56
nit: This is an inner enum, and the name can be sh
gavinp
2014/09/22 16:05:24
Done.
|
| + WebServiceWorkerCacheOperationTypeUndefined, |
| + WebServiceWorkerCacheOperationTypePut, |
| + WebServiceWorkerCacheOperationTypeDelete, |
| + WebServiceWorkerCacheOperationTypeLast = WebServiceWorkerCacheOperationTypeDelete |
| + }; |
| + |
| + struct BatchOperation { |
| + BatchOperation() : operationType(WebServiceWorkerCacheOperationTypeUndefined) { } |
| + |
| + WebServiceWorkerCacheOperationType operationType; |
| + WebServiceWorkerRequest request; |
| + WebServiceWorkerResponse response; |
| + QueryParams matchParams; |
| + }; |
| + |
| + WebServiceWorkerCache() : m_proxyInterface(0) { } |
| + |
| + void setProxyInterface(ProxyInterface* proxyInterface) { m_proxyInterface = proxyInterface; } |
| + 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; |
| + |
| +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 |
| +// use the inline keyword and provide an out of line definition. |
| +inline WebServiceWorkerCache::ProxyInterface::~ProxyInterface() { } |
| + |
| +} // namespace blink |
| + |
| +#endif // WebServiceWorkerCache_h |