Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions
mozIStorageService Interface Reference

The mozIStorageService interface is intended to be implemented by a service that can create storage connections (mozIStorageConnection) to either a well-known profile database or to a specific database file. More...

import "mozIStorageService.idl";

Inheritance diagram for mozIStorageService:
Inheritance graph
[legend]
Collaboration diagram for mozIStorageService:
Collaboration graph
[legend]

List of all members.

Public Member Functions

mozIStorageConnection openSpecialDatabase (in string aStorageKey)
 Get a connection to a named special database storage.
mozIStorageConnection openDatabase (in nsIFile aDatabaseFile)
 Open a connection to the specified file.

Detailed Description

The mozIStorageService interface is intended to be implemented by a service that can create storage connections (mozIStorageConnection) to either a well-known profile database or to a specific database file.

The implementation of this service using sqlite with the async IO module must be created the first time on the main thread. If you want to use it from another thread, you should be sure you call getService from the main thread before accessing it from another thread.

This is the only way to open a database connection.

Definition at line 57 of file mozIStorageService.idl.


Member Function Documentation

Open a connection to the specified file.

==========

DANGER

If you have more than one connection to a file, you MUST use the EXACT SAME NAME for the file each time, including case. The sqlite code uses a simple string compare to see if there is already a connection. Opening a connection to "Foo.sqlite" and "foo.sqlite" will CORRUPT YOUR DATABASE.

Opening connections from more than one thread to the same database will also CORRUPT YOUR DATABASE. All connections share the same sqlite cache, and the cache is not threadsafe.

The connection object returned by this function is not threadsafe. You must use it only from the thread you created it from.

Parameters:
aDatabaseFilea nsIFile of the database to open.
Returns:
a mozIStorageConnection for the requested database file.
Exceptions:
NS_ERROR_FAILUREif any operation fails while opening the database.

Get a connection to a named special database storage.

Parameters:
aStorageKeya string key identifying the type of storage requested. Valid values include: "profile", "memory".
See also:
openDatabase for restrictions on how database connections may be used. For the profile database, you should only access it from the main thread since other callers may also have connections.
Returns:
a new mozIStorageConnection for the requested storage database.
Exceptions:
NS_ERROR_INVALID_ARGif aStorageKey is invalid.

The documentation for this interface was generated from the following file: