Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / modules / serviceworkers / Cache.h
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 Cache_h
6 #define Cache_h
7
8 #include "bindings/core/v8/ScriptPromise.h"
9 #include "bindings/core/v8/ScriptWrappable.h"
10 #include "core/dom/DOMException.h"
11 #include "modules/serviceworkers/QueryParams.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"
19
20 namespace blink {
21
22 class Response;
23 class Request;
24 class ScriptState;
25
26 class Cache FINAL : public GarbageCollectedFinalized<Cache>, public ScriptWrappable {
27     DEFINE_WRAPPERTYPEINFO();
28     WTF_MAKE_NONCOPYABLE(Cache);
29 public:
30     static Cache* create(WebServiceWorkerCache*);
31
32     // From Cache.idl:
33     ScriptPromise match(ScriptState*, Request*, const QueryParams&);
34     ScriptPromise match(ScriptState*, const String&, const QueryParams&);
35     ScriptPromise matchAll(ScriptState*, Request*, const QueryParams&);
36     ScriptPromise matchAll(ScriptState*, const String&, const QueryParams&);
37     ScriptPromise add(ScriptState*, Request*);
38     ScriptPromise add(ScriptState*, const String&);
39     ScriptPromise addAll(ScriptState*, const Vector<ScriptValue>&);
40     ScriptPromise deleteFunction(ScriptState*, Request*, const QueryParams&);
41     ScriptPromise deleteFunction(ScriptState*, const String&, const QueryParams&);
42     ScriptPromise put(ScriptState*, Request*, Response*);
43     ScriptPromise put(ScriptState*, const String&, Response*);
44     ScriptPromise keys(ScriptState*);
45     ScriptPromise keys(ScriptState*, Request*, const QueryParams&);
46     ScriptPromise keys(ScriptState*, const String&, const QueryParams&);
47
48     static PassRefPtrWillBeRawPtr<DOMException> domExceptionForCacheError(WebServiceWorkerCacheError);
49
50     void trace(Visitor*) { }
51
52 private:
53     explicit Cache(WebServiceWorkerCache*);
54
55     ScriptPromise matchImpl(ScriptState*, Request*, const QueryParams&);
56     ScriptPromise matchAllImpl(ScriptState*, Request*, const QueryParams&);
57     ScriptPromise addImpl(ScriptState*, Request*);
58     ScriptPromise addAllImpl(ScriptState*, Vector<Request*>);
59     ScriptPromise deleteImpl(ScriptState*, Request*, const QueryParams&);
60     ScriptPromise putImpl(ScriptState*, Request*, Response*);
61     ScriptPromise keysImpl(ScriptState*);
62     ScriptPromise keysImpl(ScriptState*, Request*, const QueryParams&);
63
64     OwnPtr<WebServiceWorkerCache> m_webCache;
65 };
66
67 } // namespace blink
68
69 #endif // Cache_h