IndexedDB: API for enumerating databases within an origin

We've received feedback from early users of Chrome's implementation of
IndexedDB requesting the ability to enumerate databases exist within an
origin. We'd like the propose the following API addition to the IndexedDB
API.

TL;DR version:

We add IDBFactory.getDatabaseNames() which asynchronously delivers a
DOMStringList with database names from the current origin. We believe it is
necessary to model this as an async operation because the first access to
the backing store containing this information for each origin may be a
relatively slow operation, and blocking the calling thread is undesirable.

Spec amendments version:

interface IDBFactory (sec 3.2.3) is extended with:

    IDBRequest getDatabaseNames ();

When invoked, this method MUST create a request and return it. The created
request has no source. The method then asynchronously runs the steps for
enumerating databases within an origin. Let *origin* be the origin of the
IDBEnvironment used to access this IDBFactory.

If an error is returned from the steps above, the implementation must set
the errorCode of the request to the code of the error returned and fire a
error event at the request.

If the steps above are successful, the implementation must set the result of
the request to the DOMStringList created by the steps above and fire a
success event at the request.

interface IDBFactorySync (sec 3.3.1) is extended with:

    DOMStringList getDatabaseNames ();

When invoked, this method synchronously runs the steps for enumerating
databases within an origin. Let *origin* be the origin of the
IDBEnvironmentSync used to access this IDBFactorySync.

If an error is returned from the steps above, then the implementation must
throw an IDBDatabaseException with its code and message set to appropriate
values for the error.

If the steps above are successful, the implementation must create a
DOMStringList containing the database names and return it.

And to be pedantic, the algorithm in section 4 parlance:

The steps for enumerating databases are as follows. The algorithm in these
steps takes one arguments - the origin making the enumeration request. It
also optionally takes a *request* when this algorithm is used from an
asynchronous API.

1. If these steps fail for any reason, return a error with the appropriate
code and abort this algorithm.
2. Let *list* be a new empty DOMStringList
3. For each database in the *origin* that does not have its pending delete
flag set, add the *name* of the database to *list* as a new DOMString
4. Return *list*

Received on Wednesday, 21 September 2011 17:18:31 UTC