michael@0: /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: */ michael@0: michael@0: typedef (DOMString or unsigned long) DataStoreKey; michael@0: michael@0: // TODO Bug 957086 - The constructor and the setDataStoreImpl(...) will be michael@0: // removed once the DataStore API is fully rewritten in C++, michael@0: // which currently plays a role of C++ proxy directing to the michael@0: // JS codes implemented by the DataStoreImpl WebIDL. michael@0: michael@0: [Func="Navigator::HasDataStoreSupport", michael@0: ChromeConstructor] michael@0: interface DataStore : EventTarget { michael@0: // Returns the label of the DataSource. michael@0: [GetterThrows] michael@0: readonly attribute DOMString name; michael@0: michael@0: // Returns the origin of the DataSource (e.g., 'facebook.com'). michael@0: // This value is the manifest URL of the owner app. michael@0: [GetterThrows] michael@0: readonly attribute DOMString owner; michael@0: michael@0: // is readOnly a F(current_app, datastore) function? yes michael@0: [GetterThrows] michael@0: readonly attribute boolean readOnly; michael@0: michael@0: // Promise michael@0: [Throws] michael@0: Promise get(DataStoreKey... id); michael@0: michael@0: // Promise michael@0: [Throws] michael@0: Promise put(any obj, DataStoreKey id, optional DOMString revisionId = ""); michael@0: michael@0: // Promise michael@0: [Throws] michael@0: Promise add(any obj, optional DataStoreKey id, michael@0: optional DOMString revisionId = ""); michael@0: michael@0: // Promise michael@0: [Throws] michael@0: Promise remove(DataStoreKey id, optional DOMString revisionId = ""); michael@0: michael@0: // Promise michael@0: [Throws] michael@0: Promise clear(optional DOMString revisionId = ""); michael@0: michael@0: [GetterThrows] michael@0: readonly attribute DOMString revisionId; michael@0: michael@0: attribute EventHandler onchange; michael@0: michael@0: // Promise michael@0: [Throws] michael@0: Promise getLength(); michael@0: michael@0: [NewObject, Throws] michael@0: DataStoreCursor sync(optional DOMString revisionId = ""); michael@0: }; michael@0: michael@0: partial interface DataStore { michael@0: [ChromeOnly, Throws] michael@0: void setDataStoreImpl(DataStoreImpl store); michael@0: }; michael@0: michael@0: // TODO Bug 957086 - The constructor and the setDataStoreCursorImpl(...) will be michael@0: // removed once the DataStore API is fully rewritten in C++, michael@0: // which currently plays a role of C++ proxy directing to the michael@0: // JS codes implemented by the DataStoreCursorImpl WebIDL. michael@0: michael@0: [Pref="dom.datastore.enabled", michael@0: ChromeConstructor] michael@0: interface DataStoreCursor { michael@0: // the DataStore michael@0: [GetterThrows] michael@0: readonly attribute DataStore store; michael@0: michael@0: // Promise michael@0: [Throws] michael@0: Promise next(); michael@0: michael@0: [Throws] michael@0: void close(); michael@0: }; michael@0: michael@0: partial interface DataStoreCursor { michael@0: [ChromeOnly] michael@0: void setDataStoreCursorImpl(DataStoreCursorImpl cursor); michael@0: }; michael@0: michael@0: enum DataStoreOperation { michael@0: "add", michael@0: "update", michael@0: "remove", michael@0: "clear", michael@0: "done" michael@0: }; michael@0: michael@0: dictionary DataStoreTask { michael@0: DOMString revisionId; michael@0: michael@0: DataStoreOperation operation; michael@0: DataStoreKey id; michael@0: any data; michael@0: };