2013-10-02 21:27:15 +04:00
|
|
|
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
2013-12-19 13:07:21 +04:00
|
|
|
typedef (DOMString or unsigned long) DataStoreKey;
|
|
|
|
|
2013-12-20 12:17:49 +04:00
|
|
|
// TODO Bug 957086 - The constructor and the setDataStoreImpl(...) will be
|
|
|
|
// removed once the DataStore API is fully rewritten in C++,
|
|
|
|
// which currently plays a role of C++ proxy directing to the
|
|
|
|
// JS codes implemented by the DataStoreImpl WebIDL.
|
|
|
|
|
2014-02-06 21:44:03 +04:00
|
|
|
[Func="Navigator::HasDataStoreSupport",
|
2014-08-05 06:20:34 +04:00
|
|
|
ChromeConstructor,
|
|
|
|
Exposed=(Window,Worker)]
|
2013-10-02 21:27:15 +04:00
|
|
|
interface DataStore : EventTarget {
|
|
|
|
// Returns the label of the DataSource.
|
2013-12-20 12:17:49 +04:00
|
|
|
[GetterThrows]
|
2013-10-02 21:27:15 +04:00
|
|
|
readonly attribute DOMString name;
|
|
|
|
|
|
|
|
// Returns the origin of the DataSource (e.g., 'facebook.com').
|
|
|
|
// This value is the manifest URL of the owner app.
|
2013-12-20 12:17:49 +04:00
|
|
|
[GetterThrows]
|
2013-10-02 21:27:15 +04:00
|
|
|
readonly attribute DOMString owner;
|
|
|
|
|
|
|
|
// is readOnly a F(current_app, datastore) function? yes
|
2013-12-20 12:17:49 +04:00
|
|
|
[GetterThrows]
|
2013-10-02 21:27:15 +04:00
|
|
|
readonly attribute boolean readOnly;
|
|
|
|
|
2013-12-20 12:17:49 +04:00
|
|
|
[Throws]
|
2014-08-01 07:50:30 +04:00
|
|
|
Promise<any> get(DataStoreKey... id);
|
2013-10-02 21:27:15 +04:00
|
|
|
|
2013-12-20 12:17:49 +04:00
|
|
|
[Throws]
|
2014-08-01 07:50:30 +04:00
|
|
|
Promise<void> put(any obj, DataStoreKey id, optional DOMString revisionId = "");
|
2013-10-02 21:27:15 +04:00
|
|
|
|
2013-12-20 12:17:49 +04:00
|
|
|
[Throws]
|
2014-08-01 07:50:30 +04:00
|
|
|
Promise<DataStoreKey> add(any obj, optional DataStoreKey id,
|
|
|
|
optional DOMString revisionId = "");
|
2013-10-02 21:27:15 +04:00
|
|
|
|
2013-12-20 12:17:49 +04:00
|
|
|
[Throws]
|
2014-08-01 07:50:30 +04:00
|
|
|
Promise<boolean> remove(DataStoreKey id, optional DOMString revisionId = "");
|
2013-10-02 21:27:15 +04:00
|
|
|
|
2013-12-20 12:17:49 +04:00
|
|
|
[Throws]
|
2014-08-01 07:50:30 +04:00
|
|
|
Promise<void> clear(optional DOMString revisionId = "");
|
2013-10-02 21:27:15 +04:00
|
|
|
|
2013-12-20 12:17:49 +04:00
|
|
|
[GetterThrows]
|
2013-10-02 21:27:15 +04:00
|
|
|
readonly attribute DOMString revisionId;
|
|
|
|
|
|
|
|
attribute EventHandler onchange;
|
|
|
|
|
2013-12-20 12:17:49 +04:00
|
|
|
[Throws]
|
2014-08-01 07:50:30 +04:00
|
|
|
Promise<unsigned long> getLength();
|
2013-10-03 00:39:54 +04:00
|
|
|
|
2013-12-20 12:17:49 +04:00
|
|
|
[NewObject, Throws]
|
2013-10-03 00:39:54 +04:00
|
|
|
DataStoreCursor sync(optional DOMString revisionId = "");
|
2013-10-02 21:27:15 +04:00
|
|
|
};
|
|
|
|
|
2013-12-20 12:17:49 +04:00
|
|
|
partial interface DataStore {
|
2015-01-21 00:44:14 +03:00
|
|
|
[ChromeOnly, Throws, Exposed=Window]
|
2013-12-20 12:17:49 +04:00
|
|
|
void setDataStoreImpl(DataStoreImpl store);
|
|
|
|
};
|
|
|
|
|
|
|
|
// TODO Bug 957086 - The constructor and the setDataStoreCursorImpl(...) will be
|
|
|
|
// removed once the DataStore API is fully rewritten in C++,
|
|
|
|
// which currently plays a role of C++ proxy directing to the
|
|
|
|
// JS codes implemented by the DataStoreCursorImpl WebIDL.
|
|
|
|
|
2014-08-05 06:20:35 +04:00
|
|
|
[Func="Navigator::HasDataStoreSupport",
|
2014-08-05 06:20:34 +04:00
|
|
|
ChromeConstructor,
|
|
|
|
Exposed=(Window,Worker)]
|
2013-10-03 00:39:54 +04:00
|
|
|
interface DataStoreCursor {
|
|
|
|
// the DataStore
|
2013-12-20 12:17:49 +04:00
|
|
|
[GetterThrows]
|
2013-10-03 00:39:54 +04:00
|
|
|
readonly attribute DataStore store;
|
|
|
|
|
2013-12-20 12:17:49 +04:00
|
|
|
[Throws]
|
2014-08-01 07:50:30 +04:00
|
|
|
Promise<DataStoreTask> next();
|
2013-10-03 00:39:54 +04:00
|
|
|
|
2013-12-20 12:17:49 +04:00
|
|
|
[Throws]
|
2013-10-03 00:39:54 +04:00
|
|
|
void close();
|
|
|
|
};
|
|
|
|
|
2013-12-20 12:17:49 +04:00
|
|
|
partial interface DataStoreCursor {
|
2015-01-21 00:44:14 +03:00
|
|
|
[ChromeOnly, Exposed=Window]
|
2013-12-20 12:17:49 +04:00
|
|
|
void setDataStoreCursorImpl(DataStoreCursorImpl cursor);
|
|
|
|
};
|
|
|
|
|
2013-10-03 00:39:54 +04:00
|
|
|
enum DataStoreOperation {
|
|
|
|
"add",
|
|
|
|
"update",
|
|
|
|
"remove",
|
|
|
|
"clear",
|
|
|
|
"done"
|
|
|
|
};
|
|
|
|
|
|
|
|
dictionary DataStoreTask {
|
|
|
|
DOMString revisionId;
|
|
|
|
|
|
|
|
DataStoreOperation operation;
|
2014-04-28 13:54:38 +04:00
|
|
|
|
|
|
|
// When |operation| is "clear" or "done", this must return null.
|
|
|
|
DataStoreKey? id;
|
2013-10-03 00:39:54 +04:00
|
|
|
any data;
|
|
|
|
};
|
2014-06-03 18:36:46 +04:00
|
|
|
|
|
|
|
// For internal use.
|
|
|
|
dictionary DataStoreRevisionData {
|
|
|
|
DOMString revisionId = "";
|
|
|
|
unsigned long objectId = 0;
|
|
|
|
DOMString operation = "";
|
|
|
|
};
|