Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* -*- Mode: idl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "nsISupports.idl"
7 #include "mozIStorageAsyncConnection.idl"
9 interface mozIStorageAggregateFunction;
10 interface mozIStorageCompletionCallback;
11 interface mozIStorageFunction;
12 interface mozIStorageProgressHandler;
13 interface mozIStorageBaseStatement;
14 interface mozIStorageStatement;
15 interface mozIStorageAsyncStatement;
16 interface mozIStorageStatementCallback;
17 interface mozIStoragePendingStatement;
18 interface nsIFile;
20 /**
21 * mozIStorageConnection represents a database connection attached to
22 * a specific file or to the in-memory data storage. It is the
23 * primary interface for interacting with a database, including
24 * creating prepared statements, executing SQL, and examining database
25 * errors.
26 *
27 * @note From the main thread, you should rather use mozIStorageAsyncConnection.
28 *
29 * @threadsafe
30 */
31 [scriptable, uuid(4aa2ac47-8d24-4004-9b31-ec0bd85f0cc3)]
32 interface mozIStorageConnection : mozIStorageAsyncConnection {
33 /**
34 * Closes a database connection. Callers must finalize all statements created
35 * for this connection prior to calling this method. It is illegal to use
36 * call this method if any asynchronous statements have been executed on this
37 * connection.
38 *
39 * @throws NS_ERROR_UNEXPECTED
40 * If any statement has been executed asynchronously on this object.
41 * @throws NS_ERROR_UNEXPECTED
42 * If is called on a thread other than the one that opened it.
43 */
44 void close();
46 /**
47 * Clones a database connection and makes the clone read only if needed.
48 *
49 * @param aReadOnly
50 * If true, the returned database should be put into read-only mode.
51 * Defaults to false.
52 * @return the cloned database connection.
53 *
54 * @throws NS_ERROR_UNEXPECTED
55 * If this connection is a memory database.
56 * @note If your connection is already read-only, you will get a read-only
57 * clone.
58 * @note Due to a bug in SQLite, if you use the shared cache (openDatabase),
59 * you end up with the same privileges as the first connection opened
60 * regardless of what is specified in aReadOnly.
61 * @note The following pragmas are copied over to a read-only clone:
62 * - cache_size
63 * - temp_store
64 * The following pragmas are copied over to a writeable clone:
65 * - cache_size
66 * - temp_store
67 * - foreign_keys
68 * - journal_size_limit
69 * - synchronous
70 * - wal_autocheckpoint
71 *
72 */
73 mozIStorageConnection clone([optional] in boolean aReadOnly);
75 /**
76 * The default size for SQLite database pages used by mozStorage for new
77 * databases.
78 */
79 readonly attribute long defaultPageSize;
81 /**
82 * Indicates if the connection is open and ready to use. This will be false
83 * if the connection failed to open, or it has been closed.
84 */
85 readonly attribute boolean connectionReady;
87 /**
88 * lastInsertRowID returns the row ID from the last INSERT
89 * operation.
90 */
91 readonly attribute long long lastInsertRowID;
93 /**
94 * affectedRows returns the number of database rows that were changed or
95 * inserted or deleted by last operation.
96 */
97 readonly attribute long affectedRows;
99 /**
100 * The last error SQLite error code.
101 */
102 readonly attribute long lastError;
104 /**
105 * The last SQLite error as a string (in english, straight from the
106 * sqlite library).
107 */
108 readonly attribute AUTF8String lastErrorString;
110 /**
111 * The schema version of the database. This should not be used until the
112 * database is ready. The schema will be reported as zero if it is not set.
113 */
114 attribute long schemaVersion;
116 //////////////////////////////////////////////////////////////////////////////
117 //// Statement creation
119 /**
120 * Create a mozIStorageStatement for the given SQL expression. The
121 * expression may use ? to indicate sequential numbered arguments,
122 * ?1, ?2 etc. to indicate specific numbered arguments or :name and
123 * $var to indicate named arguments.
124 *
125 * @param aSQLStatement
126 * The SQL statement to execute.
127 * @return a new mozIStorageStatement
128 */
129 mozIStorageStatement createStatement(in AUTF8String aSQLStatement);
131 /**
132 * Execute a SQL expression, expecting no arguments.
133 *
134 * @param aSQLStatement The SQL statement to execute
135 */
136 void executeSimpleSQL(in AUTF8String aSQLStatement);
138 /**
139 * Check if the given table exists.
140 *
141 * @param aTableName
142 * The table to check
143 * @return TRUE if table exists, FALSE otherwise.
144 */
145 boolean tableExists(in AUTF8String aTableName);
147 /**
148 * Check if the given index exists.
149 *
150 * @param aIndexName The index to check
151 * @return TRUE if the index exists, FALSE otherwise.
152 */
153 boolean indexExists(in AUTF8String aIndexName);
155 //////////////////////////////////////////////////////////////////////////////
156 //// Transactions
158 /**
159 * Returns true if a transaction is active on this connection.
160 */
161 readonly attribute boolean transactionInProgress;
163 /**
164 * Begin a new transaction. sqlite default transactions are deferred.
165 * If a transaction is active, throws an error.
166 */
167 void beginTransaction();
169 /**
170 * Begins a new transaction with the given type.
171 */
172 const int32_t TRANSACTION_DEFERRED = 0;
173 const int32_t TRANSACTION_IMMEDIATE = 1;
174 const int32_t TRANSACTION_EXCLUSIVE = 2;
175 void beginTransactionAs(in int32_t transactionType);
177 /**
178 * Commits the current transaction. If no transaction is active,
179 * @throws NS_ERROR_UNEXPECTED.
180 * @throws NS_ERROR_NOT_INITIALIZED.
181 */
182 void commitTransaction();
184 /**
185 * Rolls back the current transaction. If no transaction is active,
186 * @throws NS_ERROR_UNEXPECTED.
187 * @throws NS_ERROR_NOT_INITIALIZED.
188 */
189 void rollbackTransaction();
191 //////////////////////////////////////////////////////////////////////////////
192 //// Tables
194 /**
195 * Create the table with the given name and schema.
196 *
197 * If the table already exists, NS_ERROR_FAILURE is thrown.
198 * (XXX at some point in the future it will check if the schema is
199 * the same as what is specified, but that doesn't happen currently.)
200 *
201 * @param aTableName
202 * The table name to be created, consisting of [A-Za-z0-9_], and
203 * beginning with a letter.
204 * @param aTableSchema
205 * The schema of the table; what would normally go between the parens
206 * in a CREATE TABLE statement: e.g., "foo INTEGER, bar STRING".
207 *
208 * @throws NS_ERROR_FAILURE
209 * If the table already exists or could not be created for any other
210 * reason.
211 */
212 void createTable(in string aTableName,
213 in string aTableSchema);
215 /**
216 * Controls SQLITE_FCNTL_CHUNK_SIZE setting in sqlite. This helps avoid fragmentation
217 * by growing/shrinking the database file in SQLITE_FCNTL_CHUNK_SIZE increments. To
218 * conserve memory on systems short on storage space, this function will have no effect
219 * on mobile devices or if less than 500MiB of space is left available.
220 *
221 * @param aIncrement
222 * The database file will grow in multiples of chunkSize.
223 * @param aDatabaseName
224 * Sqlite database name. "" means pass NULL for zDbName to sqlite3_file_control.
225 * See http://sqlite.org/c3ref/file_control.html for more details.
226 * @throws NS_ERROR_FILE_TOO_BIG
227 * If the system is short on storage space.
228 */
229 void setGrowthIncrement(in int32_t aIncrement, in AUTF8String aDatabaseName);
231 /**
232 * Enable a predefined virtual table implementation.
233 *
234 * @param aModuleName
235 * The module to enable. Only "filesystem" is currently supported.
236 *
237 * @throws NS_ERROR_FAILURE
238 * For unknown module names.
239 */
240 [noscript] void enableModule(in ACString aModuleName);
241 };