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