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/.
7 typedef (DOMString or unsigned long) DataStoreKey;
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.
14 [Func="Navigator::HasDataStoreSupport",
16 Exposed=(Window,Worker)]
17 interface DataStore : EventTarget {
18 // Returns the label of the DataSource.
20 readonly attribute DOMString name;
22 // Returns the origin of the DataSource (e.g., 'facebook.com').
23 // This value is the manifest URL of the owner app.
25 readonly attribute DOMString owner;
27 // is readOnly a F(current_app, datastore) function? yes
29 readonly attribute boolean readOnly;
32 Promise<any> get(DataStoreKey... id);
35 Promise<void> put(any obj, DataStoreKey id, optional DOMString revisionId = "");
38 Promise<DataStoreKey> add(any obj, optional DataStoreKey id,
39 optional DOMString revisionId = "");
42 Promise<boolean> remove(DataStoreKey id, optional DOMString revisionId = "");
45 Promise<void> clear(optional DOMString revisionId = "");
48 readonly attribute DOMString revisionId;
50 attribute EventHandler onchange;
53 Promise<unsigned long> getLength();
56 DataStoreCursor sync(optional DOMString revisionId = "");
59 partial interface DataStore {
61 void setDataStoreImpl(DataStoreImpl store);
64 // TODO Bug 957086 - The constructor and the setDataStoreCursorImpl(...) will be
65 // removed once the DataStore API is fully rewritten in C++,
66 // which currently plays a role of C++ proxy directing to the
67 // JS codes implemented by the DataStoreCursorImpl WebIDL.
69 [Func="Navigator::HasDataStoreSupport",
71 Exposed=(Window,Worker)]
72 interface DataStoreCursor {
75 readonly attribute DataStore store;
78 Promise<DataStoreTask> next();
84 partial interface DataStoreCursor {
86 void setDataStoreCursorImpl(DataStoreCursorImpl cursor);
89 enum DataStoreOperation {
97 dictionary DataStoreTask {
100 DataStoreOperation operation;
102 // When |operation| is "clear" or "done", this must return null.
108 dictionary DataStoreRevisionData {
109 DOMString revisionId = "";
110 unsigned long objectId = 0;
111 DOMString operation = "";