dom/webidl/DataStore.webidl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/webidl/DataStore.webidl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,108 @@
     1.4 +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.7 + * You can obtain one at http://mozilla.org/MPL/2.0/.
     1.8 + */
     1.9 +
    1.10 +typedef (DOMString or unsigned long) DataStoreKey;
    1.11 +
    1.12 +// TODO Bug 957086 - The constructor and the setDataStoreImpl(...) will be
    1.13 +//                   removed once the DataStore API is fully rewritten in C++,
    1.14 +//                   which currently plays a role of C++ proxy directing to the
    1.15 +//                   JS codes implemented by the DataStoreImpl WebIDL.
    1.16 +
    1.17 +[Func="Navigator::HasDataStoreSupport",
    1.18 + ChromeConstructor]
    1.19 +interface DataStore : EventTarget {
    1.20 +  // Returns the label of the DataSource.
    1.21 +  [GetterThrows]
    1.22 +  readonly attribute DOMString name;
    1.23 +
    1.24 +  // Returns the origin of the DataSource (e.g., 'facebook.com').
    1.25 +  // This value is the manifest URL of the owner app.
    1.26 +  [GetterThrows]
    1.27 +  readonly attribute DOMString owner;
    1.28 +
    1.29 +  // is readOnly a F(current_app, datastore) function? yes
    1.30 +  [GetterThrows]
    1.31 +  readonly attribute boolean readOnly;
    1.32 +
    1.33 +  // Promise<any>
    1.34 +  [Throws]
    1.35 +  Promise get(DataStoreKey... id);
    1.36 +
    1.37 +  // Promise<void>
    1.38 +  [Throws]
    1.39 +  Promise put(any obj, DataStoreKey id, optional DOMString revisionId = "");
    1.40 +
    1.41 +  // Promise<DataStoreKey>
    1.42 +  [Throws]
    1.43 +  Promise add(any obj, optional DataStoreKey id,
    1.44 +              optional DOMString revisionId = "");
    1.45 +
    1.46 +  // Promise<boolean>
    1.47 +  [Throws]
    1.48 +  Promise remove(DataStoreKey id, optional DOMString revisionId = "");
    1.49 +
    1.50 +  // Promise<void>
    1.51 +  [Throws]
    1.52 +  Promise clear(optional DOMString revisionId = "");
    1.53 +
    1.54 +  [GetterThrows]
    1.55 +  readonly attribute DOMString revisionId;
    1.56 +
    1.57 +  attribute EventHandler onchange;
    1.58 +
    1.59 +  // Promise<unsigned long>
    1.60 +  [Throws]
    1.61 +  Promise getLength();
    1.62 +
    1.63 +  [NewObject, Throws]
    1.64 +  DataStoreCursor sync(optional DOMString revisionId = "");
    1.65 +};
    1.66 +
    1.67 +partial interface DataStore {
    1.68 +  [ChromeOnly, Throws]
    1.69 +  void setDataStoreImpl(DataStoreImpl store);
    1.70 +};
    1.71 +
    1.72 +// TODO Bug 957086 - The constructor and the setDataStoreCursorImpl(...) will be
    1.73 +//                   removed once the DataStore API is fully rewritten in C++,
    1.74 +//                   which currently plays a role of C++ proxy directing to the
    1.75 +//                   JS codes implemented by the DataStoreCursorImpl WebIDL.
    1.76 +
    1.77 +[Pref="dom.datastore.enabled",
    1.78 + ChromeConstructor]
    1.79 +interface DataStoreCursor {
    1.80 +  // the DataStore
    1.81 +  [GetterThrows]
    1.82 +  readonly attribute DataStore store;
    1.83 +
    1.84 +  // Promise<DataStoreTask>
    1.85 +  [Throws]
    1.86 +  Promise next();
    1.87 +
    1.88 +  [Throws]
    1.89 +  void close();
    1.90 +};
    1.91 +
    1.92 +partial interface DataStoreCursor {
    1.93 +  [ChromeOnly]
    1.94 +  void setDataStoreCursorImpl(DataStoreCursorImpl cursor);
    1.95 +};
    1.96 +
    1.97 +enum DataStoreOperation {
    1.98 +  "add",
    1.99 +  "update",
   1.100 +  "remove",
   1.101 +  "clear",
   1.102 +  "done"
   1.103 +};
   1.104 +
   1.105 +dictionary DataStoreTask {
   1.106 +  DOMString revisionId;
   1.107 +
   1.108 +  DataStoreOperation operation;
   1.109 +  DataStoreKey id;
   1.110 +  any data;
   1.111 +};

mercurial