storage/public/mozIStorageAsyncConnection.idl

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* -*- Mode: idl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "nsISupports.idl"
michael@0 7
michael@0 8 interface mozIStorageAggregateFunction;
michael@0 9 interface mozIStorageCompletionCallback;
michael@0 10 interface mozIStorageFunction;
michael@0 11 interface mozIStorageProgressHandler;
michael@0 12 interface mozIStorageBaseStatement;
michael@0 13 interface mozIStorageStatement;
michael@0 14 interface mozIStorageAsyncStatement;
michael@0 15 interface mozIStorageStatementCallback;
michael@0 16 interface mozIStoragePendingStatement;
michael@0 17 interface nsIFile;
michael@0 18
michael@0 19 /**
michael@0 20 * mozIStorageAsyncConnection represents an asynchronous database
michael@0 21 * connection attached to a specific file or to an in-memory data
michael@0 22 * storage. It is the primary interface for interacting with a
michael@0 23 * database from the main thread, including creating prepared
michael@0 24 * statements, executing SQL, and examining database errors.
michael@0 25 */
michael@0 26 [scriptable, uuid(8bfd34d5-4ddf-4e4b-89dd-9b14f33534c6)]
michael@0 27 interface mozIStorageAsyncConnection : nsISupports {
michael@0 28 /**
michael@0 29 * Close this database connection, allowing all pending statements
michael@0 30 * to complete first.
michael@0 31 *
michael@0 32 * @param aCallback [optional]
michael@0 33 * A callback that will be notified when the close is completed,
michael@0 34 * with the following arguments:
michael@0 35 * - status: the status of the call
michael@0 36 * - value: |null|
michael@0 37 *
michael@0 38 * @throws NS_ERROR_NOT_SAME_THREAD
michael@0 39 * If is called on a thread other than the one that opened it.
michael@0 40 */
michael@0 41 void asyncClose([optional] in mozIStorageCompletionCallback aCallback);
michael@0 42
michael@0 43 /**
michael@0 44 * Clone a database and make the clone read only if needed.
michael@0 45 *
michael@0 46 * @param aReadOnly
michael@0 47 * If true, the returned database should be put into read-only mode.
michael@0 48 *
michael@0 49 * @param aCallback
michael@0 50 * A callback that will be notified when the operation is complete,
michael@0 51 * with the following arguments:
michael@0 52 * - status: the status of the operation
michael@0 53 * - value: in case of success, an intance of
michael@0 54 * mozIStorageAsyncConnection cloned from this one.
michael@0 55 *
michael@0 56 * @throws NS_ERROR_NOT_SAME_THREAD
michael@0 57 * If is called on a thread other than the one that opened it.
michael@0 58 * @throws NS_ERROR_UNEXPECTED
michael@0 59 * If this connection is a memory database.
michael@0 60 *
michael@0 61 * @note If your connection is already read-only, you will get a read-only
michael@0 62 * clone.
michael@0 63 * @note Due to a bug in SQLite, if you use the shared cache
michael@0 64 * (see mozIStorageService), you end up with the same privileges as the
michael@0 65 * first connection opened regardless of what is specified in aReadOnly.
michael@0 66 * @note The following pragmas are copied over to a read-only clone:
michael@0 67 * - cache_size
michael@0 68 * - temp_store
michael@0 69 * The following pragmas are copied over to a writeable clone:
michael@0 70 * - cache_size
michael@0 71 * - temp_store
michael@0 72 * - foreign_keys
michael@0 73 * - journal_size_limit
michael@0 74 * - synchronous
michael@0 75 * - wal_autocheckpoint
michael@0 76 */
michael@0 77 void asyncClone(in boolean aReadOnly,
michael@0 78 in mozIStorageCompletionCallback aCallback);
michael@0 79
michael@0 80 /**
michael@0 81 * The current database nsIFile. Null if the database
michael@0 82 * connection refers to an in-memory database.
michael@0 83 */
michael@0 84 readonly attribute nsIFile databaseFile;
michael@0 85
michael@0 86 //////////////////////////////////////////////////////////////////////////////
michael@0 87 //// Statement creation
michael@0 88
michael@0 89 /**
michael@0 90 * Create an asynchronous statement for the given SQL. An
michael@0 91 * asynchronous statement can only be used to dispatch asynchronous
michael@0 92 * requests to the asynchronous execution thread and cannot be used
michael@0 93 * to take any synchronous actions on the database.
michael@0 94 *
michael@0 95 * The expression may use ? to indicate sequential numbered arguments,
michael@0 96 * ?1, ?2 etc. to indicate specific numbered arguments or :name and
michael@0 97 * $var to indicate named arguments.
michael@0 98 *
michael@0 99 * @param aSQLStatement
michael@0 100 * The SQL statement to execute.
michael@0 101 * @return a new mozIStorageAsyncStatement
michael@0 102 * @note The statement is created lazily on first execution.
michael@0 103 */
michael@0 104 mozIStorageAsyncStatement createAsyncStatement(in AUTF8String aSQLStatement);
michael@0 105
michael@0 106 /**
michael@0 107 * Execute an array of statements created with this connection using
michael@0 108 * any currently bound parameters. When the array contains multiple
michael@0 109 * statements, the execution is wrapped in a single
michael@0 110 * transaction. These statements can be reused immediately, and
michael@0 111 * reset does not need to be called.
michael@0 112 *
michael@0 113 * @param aStatements
michael@0 114 * The array of statements to execute asynchronously, in the order they
michael@0 115 * are given in the array.
michael@0 116 * @param aNumStatements
michael@0 117 * The number of statements in aStatements.
michael@0 118 * @param aCallback [optional]
michael@0 119 * The callback object that will be notified of progress, errors, and
michael@0 120 * completion.
michael@0 121 * @return an object that can be used to cancel the statements execution.
michael@0 122 *
michael@0 123 * @note If you have any custom defined functions, they must be
michael@0 124 * re-entrant since they can be called on multiple threads.
michael@0 125 */
michael@0 126 mozIStoragePendingStatement executeAsync(
michael@0 127 [array, size_is(aNumStatements)] in mozIStorageBaseStatement aStatements,
michael@0 128 in unsigned long aNumStatements,
michael@0 129 [optional] in mozIStorageStatementCallback aCallback
michael@0 130 );
michael@0 131
michael@0 132 /**
michael@0 133 * Execute asynchronously an SQL expression, expecting no arguments.
michael@0 134 *
michael@0 135 * @param aSQLStatement
michael@0 136 * The SQL statement to execute
michael@0 137 * @param aCallback [optional]
michael@0 138 * The callback object that will be notified of progress, errors, and
michael@0 139 * completion.
michael@0 140 * @return an object that can be used to cancel the statement execution.
michael@0 141 */
michael@0 142 mozIStoragePendingStatement executeSimpleSQLAsync(
michael@0 143 in AUTF8String aSQLStatement,
michael@0 144 [optional] in mozIStorageStatementCallback aCallback);
michael@0 145
michael@0 146 //////////////////////////////////////////////////////////////////////////////
michael@0 147 //// Functions
michael@0 148
michael@0 149 /**
michael@0 150 * Create a new SQL function. If you use your connection on multiple threads,
michael@0 151 * your function needs to be threadsafe, or it should only be called on one
michael@0 152 * thread.
michael@0 153 *
michael@0 154 * @param aFunctionName
michael@0 155 * The name of function to create, as seen in SQL.
michael@0 156 * @param aNumArguments
michael@0 157 * The number of arguments the function takes. Pass -1 for
michael@0 158 * variable-argument functions.
michael@0 159 * @param aFunction
michael@0 160 * The instance of mozIStorageFunction, which implements the function
michael@0 161 * in question.
michael@0 162 */
michael@0 163 void createFunction(in AUTF8String aFunctionName,
michael@0 164 in long aNumArguments,
michael@0 165 in mozIStorageFunction aFunction);
michael@0 166
michael@0 167 /**
michael@0 168 * Create a new SQL aggregate function. If you use your connection on
michael@0 169 * multiple threads, your function needs to be threadsafe, or it should only
michael@0 170 * be called on one thread.
michael@0 171 *
michael@0 172 * @param aFunctionName
michael@0 173 * The name of aggregate function to create, as seen in SQL.
michael@0 174 * @param aNumArguments
michael@0 175 * The number of arguments the function takes. Pass -1 for
michael@0 176 * variable-argument functions.
michael@0 177 * @param aFunction
michael@0 178 * The instance of mozIStorageAggreagteFunction, which implements the
michael@0 179 * function in question.
michael@0 180 */
michael@0 181 void createAggregateFunction(in AUTF8String aFunctionName,
michael@0 182 in long aNumArguments,
michael@0 183 in mozIStorageAggregateFunction aFunction);
michael@0 184 /**
michael@0 185 * Delete custom SQL function (simple or aggregate one).
michael@0 186 *
michael@0 187 * @param aFunctionName
michael@0 188 * The name of function to remove.
michael@0 189 */
michael@0 190 void removeFunction(in AUTF8String aFunctionName);
michael@0 191
michael@0 192 /**
michael@0 193 * Sets a progress handler. Only one handler can be registered at a time.
michael@0 194 * If you need more than one, you need to chain them yourself. This progress
michael@0 195 * handler should be threadsafe if you use this connection object on more than
michael@0 196 * one thread.
michael@0 197 *
michael@0 198 * @param aGranularity
michael@0 199 * The number of SQL virtual machine steps between progress handler
michael@0 200 * callbacks.
michael@0 201 * @param aHandler
michael@0 202 * The instance of mozIStorageProgressHandler.
michael@0 203 * @return previous registered handler.
michael@0 204 */
michael@0 205 mozIStorageProgressHandler setProgressHandler(in int32_t aGranularity,
michael@0 206 in mozIStorageProgressHandler aHandler);
michael@0 207
michael@0 208 /**
michael@0 209 * Remove a progress handler.
michael@0 210 *
michael@0 211 * @return previous registered handler.
michael@0 212 */
michael@0 213 mozIStorageProgressHandler removeProgressHandler();
michael@0 214 };

mercurial