зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1381049 - Fix cases of async function definitions without await in Places code. r=mak
MozReview-Commit-ID: 3G3BD5SrJ8b --HG-- extra : rebase_source : 29d06e076a7fda3cf9b2d6089cefb7bd43de1a03
This commit is contained in:
Родитель
a521e2d736
Коммит
de21cc127c
|
@ -247,7 +247,7 @@ var StarUI = {
|
|||
);
|
||||
},
|
||||
|
||||
async _doShowEditBookmarkPanel(aNode, aAnchorElement, aPosition) {
|
||||
_doShowEditBookmarkPanel(aNode, aAnchorElement, aPosition) {
|
||||
if (this.panel.state != "closed")
|
||||
return;
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
"rules": {
|
||||
"require-await": "error"
|
||||
}
|
||||
};
|
|
@ -1191,7 +1191,7 @@ var remove = async function(db, {guids, urls}, onResult = null) {
|
|||
let onResultData = onResult ? [] : null;
|
||||
let pages = [];
|
||||
let hasPagesToRemove = false;
|
||||
await db.execute(query, null, async function(row) {
|
||||
await db.execute(query, null, function(row) {
|
||||
let hasForeign = row.getResultByName("foreign_count") != 0;
|
||||
if (!hasForeign) {
|
||||
hasPagesToRemove = true;
|
||||
|
@ -1275,7 +1275,7 @@ function mergeUpdateInfoIntoPageInfo(updateInfo, pageInfo = {}) {
|
|||
}
|
||||
|
||||
// Inner implementation of History.insert.
|
||||
var insert = async function(db, pageInfo) {
|
||||
var insert = function(db, pageInfo) {
|
||||
let info = convertForUpdatePlaces(pageInfo);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
|
@ -1294,7 +1294,7 @@ var insert = async function(db, pageInfo) {
|
|||
};
|
||||
|
||||
// Inner implementation of History.insertMany.
|
||||
var insertMany = async function(db, pageInfos, onResult, onError) {
|
||||
var insertMany = function(db, pageInfos, onResult, onError) {
|
||||
let infos = [];
|
||||
let onResultData = [];
|
||||
let onErrorData = [];
|
||||
|
|
|
@ -75,11 +75,16 @@ this.PlacesDBUtils = {
|
|||
* Executes integrity check, common and advanced maintenance tasks (like
|
||||
* expiration and vacuum). Will also collect statistics on the database.
|
||||
*
|
||||
* @return a Map[taskName(String) -> Object]. The Object has the following properties:
|
||||
* Note: although this function isn't actually async, we keep it async to
|
||||
* allow us to maintain a simple, consistent API for the tasks within this object.
|
||||
*
|
||||
* @return {Promise}
|
||||
* A promise that resolves with a Map[taskName(String) -> Object].
|
||||
* The Object has the following properties:
|
||||
* - succeeded: boolean
|
||||
* - logs: an array of strings containing the messages logged by the task.
|
||||
*/
|
||||
async checkAndFixDatabase() {
|
||||
async checkAndFixDatabase() { // eslint-disable-line require-await
|
||||
let tasks = [
|
||||
this.checkIntegrity,
|
||||
this.checkCoherence,
|
||||
|
@ -94,10 +99,12 @@ this.PlacesDBUtils = {
|
|||
/**
|
||||
* Forces a full refresh of Places views.
|
||||
*
|
||||
* @return {Promise} resolved when refresh is complete.
|
||||
* @resolves to an array of logs for this task.
|
||||
* Note: although this function isn't actually async, we keep it async to
|
||||
* allow us to maintain a simple, consistent API for the tasks within this object.
|
||||
*
|
||||
* @returns {Array} An empty array.
|
||||
*/
|
||||
async _refreshUI() {
|
||||
async _refreshUI() { // eslint-disable-line require-await
|
||||
// Send batch update notifications to update the UI.
|
||||
let observers = PlacesUtils.history.getObservers();
|
||||
for (let observer of observers) {
|
||||
|
@ -133,11 +140,14 @@ this.PlacesDBUtils = {
|
|||
/**
|
||||
* Checks integrity but does not try to fix the database through a reindex.
|
||||
*
|
||||
* Note: although this function isn't actually async, we keep it async to
|
||||
* allow us to maintain a simple, consistent API for the tasks within this object.
|
||||
*
|
||||
* @return {Promise} resolves if database is sane.
|
||||
* @resolves to an array of logs for this task.
|
||||
* @rejects if we're unable to fix corruption or unable to check status.
|
||||
*/
|
||||
async _checkIntegritySkipReindex() {
|
||||
async _checkIntegritySkipReindex() { // eslint-disable-line require-await
|
||||
return this.checkIntegrity(true);
|
||||
},
|
||||
|
||||
|
@ -203,22 +213,22 @@ this.PlacesDBUtils = {
|
|||
let logs = [];
|
||||
|
||||
let stmts = await PlacesDBUtils._getBoundCoherenceStatements();
|
||||
let allStatementsPromises = [];
|
||||
let coherenceCheck = true;
|
||||
await PlacesUtils.withConnectionWrapper(
|
||||
"PlacesDBUtils: coherence check:",
|
||||
db => db.executeTransaction(async () => {
|
||||
for (let {query, params} of stmts) {
|
||||
params = params ? params : null;
|
||||
allStatementsPromises.push(db.execute(query, params).catch(ex => {
|
||||
try {
|
||||
await db.execute(query, params);
|
||||
} catch (ex) {
|
||||
Cu.reportError(ex);
|
||||
coherenceCheck = false;
|
||||
}));
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
await Promise.all(allStatementsPromises);
|
||||
if (coherenceCheck) {
|
||||
logs.push("The database is coherent");
|
||||
} else {
|
||||
|
@ -757,11 +767,14 @@ this.PlacesDBUtils = {
|
|||
/**
|
||||
* Tries to vacuum the database.
|
||||
*
|
||||
* Note: although this function isn't actually async, we keep it async to
|
||||
* allow us to maintain a simple, consistent API for the tasks within this object.
|
||||
*
|
||||
* @return {Promise} resolves when database is vacuumed.
|
||||
* @resolves to an array of logs for this task.
|
||||
* @rejects if we are unable to vacuum database.
|
||||
*/
|
||||
async vacuum() {
|
||||
async vacuum() { // eslint-disable-line require-await
|
||||
let logs = [];
|
||||
let DBFile = Services.dirsvc.get("ProfD", Ci.nsILocalFile);
|
||||
DBFile.append("places.sqlite");
|
||||
|
@ -787,10 +800,13 @@ this.PlacesDBUtils = {
|
|||
/**
|
||||
* Forces a full expiration on the database.
|
||||
*
|
||||
* Note: although this function isn't actually async, we keep it async to
|
||||
* allow us to maintain a simple, consistent API for the tasks within this object.
|
||||
*
|
||||
* @return {Promise} resolves when the database in cleaned up.
|
||||
* @resolves to an array of logs for this task.
|
||||
*/
|
||||
async expire() {
|
||||
async expire() { // eslint-disable-line require-await
|
||||
let logs = [];
|
||||
|
||||
let expiration = Cc["@mozilla.org/places/expiration;1"]
|
||||
|
@ -883,8 +899,11 @@ this.PlacesDBUtils = {
|
|||
/**
|
||||
* Collects telemetry data and reports it to Telemetry.
|
||||
*
|
||||
* Note: although this function isn't actually async, we keep it async to
|
||||
* allow us to maintain a simple, consistent API for the tasks within this object.
|
||||
*
|
||||
*/
|
||||
async telemetry() {
|
||||
async telemetry() { // eslint-disable-line require-await
|
||||
// This will be populated with one integer property for each probe result,
|
||||
// using the histogram name as key.
|
||||
let probeValues = {};
|
||||
|
@ -1034,7 +1053,9 @@ this.PlacesDBUtils = {
|
|||
* @param tasks
|
||||
* Array of tasks to be executed, in form of pointers to methods in
|
||||
* this module.
|
||||
* @return a Map[taskName(String) -> Object]. The Object has the following properties:
|
||||
* @return {Promise}
|
||||
* A promise that resolves with a Map[taskName(String) -> Object].
|
||||
* The Object has the following properties:
|
||||
* - succeeded: boolean
|
||||
* - logs: an array of strings containing the messages logged by the task
|
||||
*/
|
||||
|
|
|
@ -277,8 +277,11 @@ const BookmarkSyncUtils = PlacesSyncUtils.bookmarks = Object.freeze({
|
|||
* Sync uses this method to reorder all synced children after applying all
|
||||
* incoming records.
|
||||
*
|
||||
* @return {Promise} resolved when reordering is complete.
|
||||
* @rejects if an error happens while reordering.
|
||||
* @throws if the arguments are invalid.
|
||||
*/
|
||||
async order(parentSyncId, childSyncIds) {
|
||||
order(parentSyncId, childSyncIds) {
|
||||
PlacesUtils.SYNC_BOOKMARK_VALIDATORS.syncId(parentSyncId);
|
||||
if (!childSyncIds.length) {
|
||||
return undefined;
|
||||
|
@ -556,7 +559,7 @@ const BookmarkSyncUtils = PlacesSyncUtils.bookmarks = Object.freeze({
|
|||
*
|
||||
* @return {Promise} resolved once all items have been updated.
|
||||
*/
|
||||
async reset() {
|
||||
reset() {
|
||||
return PlacesUtils.withConnectionWrapper(
|
||||
"BookmarkSyncUtils: reset", function(db) {
|
||||
return db.executeTransaction(async function() {
|
||||
|
@ -602,7 +605,7 @@ const BookmarkSyncUtils = PlacesSyncUtils.bookmarks = Object.freeze({
|
|||
* local parent. The bookmarks engine merges these records into the
|
||||
* changeset for the current sync.
|
||||
*/
|
||||
async dedupe(localSyncId, remoteSyncId, remoteParentSyncId) {
|
||||
dedupe(localSyncId, remoteSyncId, remoteParentSyncId) {
|
||||
PlacesUtils.SYNC_BOOKMARK_VALIDATORS.syncId(localSyncId);
|
||||
PlacesUtils.SYNC_BOOKMARK_VALIDATORS.syncId(remoteSyncId);
|
||||
PlacesUtils.SYNC_BOOKMARK_VALIDATORS.syncId(remoteParentSyncId);
|
||||
|
@ -638,7 +641,7 @@ const BookmarkSyncUtils = PlacesSyncUtils.bookmarks = Object.freeze({
|
|||
* @rejects if it's not possible to update the given bookmark.
|
||||
* @throws if the arguments are invalid.
|
||||
*/
|
||||
async update(info) {
|
||||
update(info) {
|
||||
let updateInfo = validateSyncBookmarkObject("BookmarkSyncUtils: update",
|
||||
info, { syncId: { required: true } });
|
||||
|
||||
|
@ -671,7 +674,7 @@ const BookmarkSyncUtils = PlacesSyncUtils.bookmarks = Object.freeze({
|
|||
* @rejects if it's not possible to create the requested bookmark.
|
||||
* @throws if the arguments are invalid.
|
||||
*/
|
||||
async insert(info) {
|
||||
insert(info) {
|
||||
let insertInfo = validateNewBookmark("BookmarkSyncUtils: insert", info);
|
||||
return insertSyncBookmark(insertInfo);
|
||||
},
|
||||
|
@ -2001,8 +2004,12 @@ function markChangesAsSyncing(db, changeRecords) {
|
|||
{ syncStatus: PlacesUtils.bookmarks.SYNC_STATUS.NORMAL });
|
||||
}
|
||||
|
||||
// Removes tombstones for successfully synced items.
|
||||
var removeTombstones = async function(db, guids) {
|
||||
/**
|
||||
* Removes tombstones for successfully synced items.
|
||||
*
|
||||
* @return {Promise}
|
||||
*/
|
||||
var removeTombstones = function(db, guids) {
|
||||
if (!guids.length) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
|
|
@ -567,7 +567,7 @@ var TransactionsManager = {
|
|||
} finally {
|
||||
// We must enqueue clearing batching mode to ensure that any existing
|
||||
// transactions have completed before we clear the batching mode.
|
||||
this._mainEnqueuer.enqueue(async () => {
|
||||
this._mainEnqueuer.enqueue(() => {
|
||||
this._batching = false;
|
||||
this._createdBatchEntry = false;
|
||||
});
|
||||
|
@ -925,8 +925,8 @@ DefineTransaction.defineArrayInputProp("excludingAnnotations",
|
|||
* @resolves to the guid of the new item.
|
||||
*/
|
||||
// TODO: Replace most of this with insertTree.
|
||||
async function createItemsFromBookmarksTree(tree, restoring = false,
|
||||
excludingAnnotations = []) {
|
||||
function createItemsFromBookmarksTree(tree, restoring = false,
|
||||
excludingAnnotations = []) {
|
||||
function extractLivemarkDetails(annos) {
|
||||
let feedURI = null, siteURI = null;
|
||||
annos = annos.filter(anno => {
|
||||
|
@ -1551,7 +1551,7 @@ PT.Tag.prototype = {
|
|||
*/
|
||||
PT.Untag = DefineTransaction(["urls"], ["tags"]);
|
||||
PT.Untag.prototype = {
|
||||
async execute({ urls, tags }) {
|
||||
execute({ urls, tags }) {
|
||||
let onUndo = [], onRedo = [];
|
||||
for (let url of urls) {
|
||||
let uri = Services.io.newURI(url.href);
|
||||
|
|
|
@ -2446,13 +2446,13 @@ XPCOMUtils.defineLazyGetter(this, "gKeywordsCachePromise", () =>
|
|||
}
|
||||
|
||||
if (prop == "keyword") {
|
||||
this._onKeywordChanged(guid, val, oldVal).catch(Cu.reportError);
|
||||
this._onKeywordChanged(guid, val, oldVal);
|
||||
} else if (prop == "uri") {
|
||||
this._onUrlChanged(guid, val, oldVal).catch(Cu.reportError);
|
||||
}
|
||||
},
|
||||
|
||||
async _onKeywordChanged(guid, keyword, href) {
|
||||
_onKeywordChanged(guid, keyword, href) {
|
||||
if (keyword.length == 0) {
|
||||
// We are removing a keyword.
|
||||
let keywords = keywordsForHref(href)
|
||||
|
|
|
@ -5,5 +5,9 @@ module.exports = {
|
|||
"plugin:mozilla/mochitest-test",
|
||||
"plugin:mozilla/chrome-test",
|
||||
"plugin:mozilla/xpcshell-test"
|
||||
]
|
||||
],
|
||||
|
||||
"rules": {
|
||||
"require-await": "off"
|
||||
}
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче