2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "domstubs.idl"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Interface for client side storage. See
|
2009-05-16 06:59:30 -07:00
|
|
|
* http://www.whatwg.org/specs/web-apps/current-work/multipage/structured.html#storage0
|
2007-03-22 10:30:00 -07:00
|
|
|
* for more information.
|
|
|
|
*
|
|
|
|
* A storage object stores an arbitrary set of key-value pairs, which
|
|
|
|
* may be retrieved, modified and removed as needed. A key may only
|
|
|
|
* exist once within a storage object, and only one value may be
|
|
|
|
* associated with a particular key. Keys are stored in a particular
|
|
|
|
* order with the condition that this order not change by merely changing
|
|
|
|
* the value associated with a key, but the order may change when a
|
|
|
|
* key is added or removed.
|
|
|
|
*/
|
|
|
|
|
2009-05-16 06:59:30 -07:00
|
|
|
[scriptable, uuid(43E5EDAD-1E02-42c4-9D99-C3D9DEE22A20)]
|
2007-03-22 10:30:00 -07:00
|
|
|
interface nsIDOMStorage : nsISupports
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The number of keys stored.
|
|
|
|
*/
|
|
|
|
readonly attribute unsigned long length;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieve the name of the key at a particular index.
|
|
|
|
*
|
|
|
|
* @param index index of the item to retrieve
|
2012-03-29 14:09:09 -07:00
|
|
|
* @returns the key at index, null if there is no key at that index
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
DOMString key(in unsigned long index);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieve an item with a given key
|
|
|
|
*
|
|
|
|
* @param key key to retrieve
|
2009-05-16 06:59:30 -07:00
|
|
|
* @returns found data or empty string if the key was not found
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2012-04-03 00:25:39 -07:00
|
|
|
DOMString getItem([Null(Stringify)] in DOMString key);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Assign a value with a key. If the key does not exist already, a new
|
|
|
|
* key is added associated with that value. If the key already exists,
|
|
|
|
* then the existing value is replaced with a new value.
|
|
|
|
*
|
|
|
|
* @param key key to set
|
|
|
|
* @param data data to associate with the key
|
|
|
|
*/
|
2012-04-03 00:25:39 -07:00
|
|
|
void setItem([Null(Stringify)] in DOMString key, [Null(Stringify)] in DOMString data);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove a key and its corresponding value.
|
|
|
|
*
|
|
|
|
* @param key key to remove
|
|
|
|
*/
|
2012-04-03 00:25:39 -07:00
|
|
|
void removeItem([Null(Stringify)] in DOMString key);
|
2009-05-16 06:59:30 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Clear the content of this storage bound to a domain
|
|
|
|
* or an origin.
|
|
|
|
*/
|
|
|
|
void clear();
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|