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.
8 #include "bindings/core/v8/ScriptPromise.h"
9 #include "bindings/core/v8/ScriptWrappable.h"
10 #include "core/dom/DOMException.h"
11 #include "modules/serviceworkers/CacheQueryOptions.h"
12 #include "public/platform/WebServiceWorkerCache.h"
13 #include "public/platform/WebServiceWorkerCacheError.h"
14 #include "wtf/Forward.h"
15 #include "wtf/Noncopyable.h"
16 #include "wtf/OwnPtr.h"
17 #include "wtf/Vector.h"
18 #include "wtf/text/WTFString.h"
27 class Cache final : public GarbageCollectedFinalized<Cache>, public ScriptWrappable {
28 DEFINE_WRAPPERTYPEINFO();
29 WTF_MAKE_NONCOPYABLE(Cache);
31 static Cache* create(WebServiceWorkerCache*);
34 ScriptPromise match(ScriptState*, Request*, const CacheQueryOptions&);
35 ScriptPromise match(ScriptState*, const String&, const CacheQueryOptions&, ExceptionState&);
36 ScriptPromise matchAll(ScriptState*, Request*, const CacheQueryOptions&);
37 ScriptPromise matchAll(ScriptState*, const String&, const CacheQueryOptions&, ExceptionState&);
38 ScriptPromise add(ScriptState*, Request*);
39 ScriptPromise add(ScriptState*, const String&, ExceptionState&);
40 ScriptPromise addAll(ScriptState*, const Vector<ScriptValue>&);
41 ScriptPromise deleteFunction(ScriptState*, Request*, const CacheQueryOptions&);
42 ScriptPromise deleteFunction(ScriptState*, const String&, const CacheQueryOptions&, ExceptionState&);
43 ScriptPromise put(ScriptState*, Request*, Response*);
44 ScriptPromise put(ScriptState*, const String&, Response*, ExceptionState&);
45 ScriptPromise keys(ScriptState*);
46 ScriptPromise keys(ScriptState*, Request*, const CacheQueryOptions&);
47 ScriptPromise keys(ScriptState*, const String&, const CacheQueryOptions&, ExceptionState&);
49 static PassRefPtrWillBeRawPtr<DOMException> domExceptionForCacheError(WebServiceWorkerCacheError);
51 void trace(Visitor*) { }
54 explicit Cache(WebServiceWorkerCache*);
56 ScriptPromise matchImpl(ScriptState*, const Request*, const CacheQueryOptions&);
57 ScriptPromise matchAllImpl(ScriptState*, const Request*, const CacheQueryOptions&);
58 ScriptPromise addImpl(ScriptState*, const Request*);
59 ScriptPromise addAllImpl(ScriptState*, const Vector<const Request*>);
60 ScriptPromise deleteImpl(ScriptState*, const Request*, const CacheQueryOptions&);
61 ScriptPromise putImpl(ScriptState*, Request*, Response*);
62 ScriptPromise keysImpl(ScriptState*);
63 ScriptPromise keysImpl(ScriptState*, const Request*, const CacheQueryOptions&);
65 OwnPtr<WebServiceWorkerCache> m_webCache;