зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1392070 - Stop using the StopIteration object in Sqlite.jsm. r=mak
MozReview-Commit-ID: BP3RuM5EweE --HG-- extra : rebase_source : 1e0a6ba438e51a851013356faf84d8eb91ff78b6
This commit is contained in:
Родитель
58441e391c
Коммит
35399ee9fc
|
@ -171,9 +171,9 @@ this.PlacesDBUtils = {
|
|||
await db.execute(
|
||||
"PRAGMA integrity_check",
|
||||
null,
|
||||
r => {
|
||||
(r, cancel) => {
|
||||
row = r;
|
||||
throw StopIteration;
|
||||
cancel();
|
||||
});
|
||||
if (row.getResultByIndex(0) === "ok") {
|
||||
logs.push("The database is sane");
|
||||
|
|
|
@ -1699,7 +1699,7 @@ Search.prototype = {
|
|||
return true;
|
||||
},
|
||||
|
||||
_onResultRow(row) {
|
||||
_onResultRow(row, cancel) {
|
||||
if (this._counts[MATCHTYPE.GENERAL] == 0) {
|
||||
TelemetryStopwatch.finish(TELEMETRY_1ST_RESULT, this);
|
||||
}
|
||||
|
@ -1722,7 +1722,7 @@ Search.prototype = {
|
|||
// If the search has been canceled by the user or by _addMatch, or we
|
||||
// fetched enough results, we can stop the underlying Sqlite query.
|
||||
if (!this.pending || this._counts[MATCHTYPE.GENERAL] == Prefs.get("maxRichResults"))
|
||||
throw StopIteration;
|
||||
cancel();
|
||||
},
|
||||
|
||||
_maybeRestyleSearchMatch(match) {
|
||||
|
|
|
@ -1082,7 +1082,7 @@ var ActivityStreamProvider = {
|
|||
let items = [];
|
||||
let queryError = null;
|
||||
let conn = await PlacesUtils.promiseDBConnection();
|
||||
await conn.executeCached(aQuery, params, aRow => {
|
||||
await conn.executeCached(aQuery, params, (aRow, aCancel) => {
|
||||
try {
|
||||
let item = null;
|
||||
// if columns array is given construct an object
|
||||
|
@ -1101,7 +1101,7 @@ var ActivityStreamProvider = {
|
|||
items.push(item);
|
||||
} catch (e) {
|
||||
queryError = e;
|
||||
throw StopIteration;
|
||||
aCancel();
|
||||
}
|
||||
});
|
||||
if (queryError) {
|
||||
|
|
|
@ -771,14 +771,11 @@ ConnectionData.prototype = Object.freeze({
|
|||
handledRow = true;
|
||||
|
||||
try {
|
||||
onRow(row);
|
||||
} catch (e) {
|
||||
if (e instanceof StopIteration) {
|
||||
onRow(row, () => {
|
||||
userCancelled = true;
|
||||
pending.cancel();
|
||||
break;
|
||||
}
|
||||
|
||||
});
|
||||
} catch (e) {
|
||||
self._log.warn("Exception when calling onRow callback", e);
|
||||
}
|
||||
}
|
||||
|
@ -1283,14 +1280,14 @@ OpenedConnection.prototype = Object.freeze({
|
|||
* handler. Otherwise, the buffering may consume unacceptable amounts of
|
||||
* resources.
|
||||
*
|
||||
* If a `StopIteration` is thrown during execution of an `onRow` handler,
|
||||
* the execution of the statement is immediately cancelled. Subsequent
|
||||
* rows will not be processed and no more `onRow` invocations will be made.
|
||||
* The promise is resolved immediately.
|
||||
* If the second parameter of an `onRow` handler is called during execution
|
||||
* of the `onRow` handler, the execution of the statement is immediately
|
||||
* cancelled. Subsequent rows will not be processed and no more `onRow`
|
||||
* invocations will be made. The promise is resolved immediately.
|
||||
*
|
||||
* If a non-`StopIteration` exception is thrown by the `onRow` handler, the
|
||||
* exception is logged and processing of subsequent rows occurs as if nothing
|
||||
* happened. The promise is still resolved (not rejected).
|
||||
* If an exception is thrown by the `onRow` handler, the exception is logged
|
||||
* and processing of subsequent rows occurs as if nothing happened. The
|
||||
* promise is still resolved (not rejected).
|
||||
*
|
||||
* The return value is a promise that will be resolved when the statement
|
||||
* has completed fully.
|
||||
|
|
|
@ -311,11 +311,11 @@ add_task(async function test_on_row_stop_iteration() {
|
|||
}
|
||||
|
||||
let i = 0;
|
||||
let hasResult = await c.execute("SELECT * FROM dirs", null, function onRow(row) {
|
||||
let hasResult = await c.execute("SELECT * FROM dirs", null, function onRow(row, cancel) {
|
||||
i++;
|
||||
|
||||
if (i == 5) {
|
||||
throw StopIteration;
|
||||
cancel();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче