Update To 11.40.268.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/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"
19
20 namespace blink {
21
22 class ExceptionState;
23 class Response;
24 class Request;
25 class ScriptState;
26
27 class Cache final : public GarbageCollectedFinalized<Cache>, public ScriptWrappable {
28     DEFINE_WRAPPERTYPEINFO();
29     WTF_MAKE_NONCOPYABLE(Cache);
30 public:
31     static Cache* create(WebServiceWorkerCache*);
32
33     // From Cache.idl:
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&);
48
49     static PassRefPtrWillBeRawPtr<DOMException> domExceptionForCacheError(WebServiceWorkerCacheError);
50
51     void trace(Visitor*) { }
52
53 private:
54     explicit Cache(WebServiceWorkerCache*);
55
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&);
64
65     OwnPtr<WebServiceWorkerCache> m_webCache;
66 };
67
68 } // namespace blink
69
70 #endif // Cache_h