|
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
|
4 * You can obtain one at http://mozilla.org/MPL/2.0/. |
|
5 */ |
|
6 |
|
7 typedef (DOMString or unsigned long) DataStoreKey; |
|
8 |
|
9 // TODO Bug 957086 - The constructor and the setDataStoreImpl(...) will be |
|
10 // removed once the DataStore API is fully rewritten in C++, |
|
11 // which currently plays a role of C++ proxy directing to the |
|
12 // JS codes implemented by the DataStoreImpl WebIDL. |
|
13 |
|
14 [Func="Navigator::HasDataStoreSupport", |
|
15 ChromeConstructor] |
|
16 interface DataStore : EventTarget { |
|
17 // Returns the label of the DataSource. |
|
18 [GetterThrows] |
|
19 readonly attribute DOMString name; |
|
20 |
|
21 // Returns the origin of the DataSource (e.g., 'facebook.com'). |
|
22 // This value is the manifest URL of the owner app. |
|
23 [GetterThrows] |
|
24 readonly attribute DOMString owner; |
|
25 |
|
26 // is readOnly a F(current_app, datastore) function? yes |
|
27 [GetterThrows] |
|
28 readonly attribute boolean readOnly; |
|
29 |
|
30 // Promise<any> |
|
31 [Throws] |
|
32 Promise get(DataStoreKey... id); |
|
33 |
|
34 // Promise<void> |
|
35 [Throws] |
|
36 Promise put(any obj, DataStoreKey id, optional DOMString revisionId = ""); |
|
37 |
|
38 // Promise<DataStoreKey> |
|
39 [Throws] |
|
40 Promise add(any obj, optional DataStoreKey id, |
|
41 optional DOMString revisionId = ""); |
|
42 |
|
43 // Promise<boolean> |
|
44 [Throws] |
|
45 Promise remove(DataStoreKey id, optional DOMString revisionId = ""); |
|
46 |
|
47 // Promise<void> |
|
48 [Throws] |
|
49 Promise clear(optional DOMString revisionId = ""); |
|
50 |
|
51 [GetterThrows] |
|
52 readonly attribute DOMString revisionId; |
|
53 |
|
54 attribute EventHandler onchange; |
|
55 |
|
56 // Promise<unsigned long> |
|
57 [Throws] |
|
58 Promise getLength(); |
|
59 |
|
60 [NewObject, Throws] |
|
61 DataStoreCursor sync(optional DOMString revisionId = ""); |
|
62 }; |
|
63 |
|
64 partial interface DataStore { |
|
65 [ChromeOnly, Throws] |
|
66 void setDataStoreImpl(DataStoreImpl store); |
|
67 }; |
|
68 |
|
69 // TODO Bug 957086 - The constructor and the setDataStoreCursorImpl(...) will be |
|
70 // removed once the DataStore API is fully rewritten in C++, |
|
71 // which currently plays a role of C++ proxy directing to the |
|
72 // JS codes implemented by the DataStoreCursorImpl WebIDL. |
|
73 |
|
74 [Pref="dom.datastore.enabled", |
|
75 ChromeConstructor] |
|
76 interface DataStoreCursor { |
|
77 // the DataStore |
|
78 [GetterThrows] |
|
79 readonly attribute DataStore store; |
|
80 |
|
81 // Promise<DataStoreTask> |
|
82 [Throws] |
|
83 Promise next(); |
|
84 |
|
85 [Throws] |
|
86 void close(); |
|
87 }; |
|
88 |
|
89 partial interface DataStoreCursor { |
|
90 [ChromeOnly] |
|
91 void setDataStoreCursorImpl(DataStoreCursorImpl cursor); |
|
92 }; |
|
93 |
|
94 enum DataStoreOperation { |
|
95 "add", |
|
96 "update", |
|
97 "remove", |
|
98 "clear", |
|
99 "done" |
|
100 }; |
|
101 |
|
102 dictionary DataStoreTask { |
|
103 DOMString revisionId; |
|
104 |
|
105 DataStoreOperation operation; |
|
106 DataStoreKey id; |
|
107 any data; |
|
108 }; |