dom/interfaces/storage/nsIDOMStorage.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/interfaces/storage/nsIDOMStorage.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,68 @@
     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
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "domstubs.idl"
    1.10 +
    1.11 +/**
    1.12 + * Interface for client side storage. See
    1.13 + * http://www.whatwg.org/specs/web-apps/current-work/multipage/structured.html#storage0
    1.14 + * for more information.
    1.15 + *
    1.16 + * A storage object stores an arbitrary set of key-value pairs, which
    1.17 + * may be retrieved, modified and removed as needed. A key may only
    1.18 + * exist once within a storage object, and only one value may be
    1.19 + * associated with a particular key. Keys are stored in a particular
    1.20 + * order with the condition that this order not change by merely changing
    1.21 + * the value associated with a key, but the order may change when a
    1.22 + * key is added or removed.
    1.23 + */
    1.24 +
    1.25 +[scriptable, uuid(43E5EDAD-1E02-42c4-9D99-C3D9DEE22A20)]
    1.26 +interface nsIDOMStorage : nsISupports
    1.27 +{
    1.28 +  /**
    1.29 +   * The number of keys stored.
    1.30 +   */
    1.31 +  readonly attribute unsigned long length;
    1.32 +
    1.33 +  /**
    1.34 +   * Retrieve the name of the key at a particular index.
    1.35 +   *
    1.36 +   * @param index index of the item to retrieve
    1.37 +   * @returns the key at index, null if there is no key at that index
    1.38 +   */
    1.39 +  DOMString key(in unsigned long index);
    1.40 +
    1.41 +  /**
    1.42 +   * Retrieve an item with a given key
    1.43 +   *
    1.44 +   * @param key key to retrieve
    1.45 +   * @returns found data or empty string if the key was not found
    1.46 +   */
    1.47 +  DOMString getItem([Null(Stringify)] in DOMString key);
    1.48 +
    1.49 +  /**
    1.50 +   * Assign a value with a key. If the key does not exist already, a new
    1.51 +   * key is added associated with that value. If the key already exists,
    1.52 +   * then the existing value is replaced with a new value.
    1.53 +   *
    1.54 +   * @param key key to set
    1.55 +   * @param data data to associate with the key
    1.56 +   */
    1.57 +  void setItem([Null(Stringify)] in DOMString key, [Null(Stringify)] in DOMString data);
    1.58 +
    1.59 +  /**
    1.60 +   * Remove a key and its corresponding value.
    1.61 +   *
    1.62 +   * @param key key to remove
    1.63 +   */
    1.64 +  void removeItem([Null(Stringify)] in DOMString key);
    1.65 +
    1.66 +  /**
    1.67 +   * Clear the content of this storage bound to a domain
    1.68 +   * or an origin.
    1.69 +   */
    1.70 +  void clear();
    1.71 +};

mercurial