зеркало из https://github.com/mozilla/pjs.git
Bug 553709 - Syncing "Browsing History" uses 100% of a CPU core for extended periods [r=mconnor]
Sync asyncExecute to avoid forcing synchronous waits on disk but keep existing calling conventions (no callbacks) for callers by using Sync.
This commit is contained in:
Родитель
26717b95bc
Коммит
5dbc80dbd3
|
@ -43,6 +43,7 @@ const Cu = Components.utils;
|
||||||
const GUID_ANNO = "weave/guid";
|
const GUID_ANNO = "weave/guid";
|
||||||
|
|
||||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
|
Cu.import("resource://weave/ext/Sync.js");
|
||||||
Cu.import("resource://weave/util.js");
|
Cu.import("resource://weave/util.js");
|
||||||
Cu.import("resource://weave/engines.js");
|
Cu.import("resource://weave/engines.js");
|
||||||
Cu.import("resource://weave/stores.js");
|
Cu.import("resource://weave/stores.js");
|
||||||
|
@ -136,39 +137,52 @@ HistoryStore.prototype = {
|
||||||
|
|
||||||
// See bug 320831 for why we use SQL here
|
// See bug 320831 for why we use SQL here
|
||||||
_getVisits: function HistStore__getVisits(uri) {
|
_getVisits: function HistStore__getVisits(uri) {
|
||||||
let visits = [];
|
this._visitStm.params.url = uri;
|
||||||
if (typeof(uri) != "string")
|
let [exec, execCb] = Sync.withCb(this._visitStm.executeAsync, this._visitStm);
|
||||||
uri = uri.spec;
|
return exec({
|
||||||
|
visits: [],
|
||||||
try {
|
handleResult: function handleResult(results) {
|
||||||
this._visitStm.params.url = uri;
|
let row;
|
||||||
while (this._visitStm.step()) {
|
while ((row = results.getNextRow()) != null) {
|
||||||
visits.push({date: this._visitStm.row.date,
|
this.visits.push({
|
||||||
type: this._visitStm.row.type});
|
date: row.getResultByName("date"),
|
||||||
|
type: row.getResultByName("type")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
handleError: function handleError(error) {
|
||||||
|
execCb.throw(error);
|
||||||
|
},
|
||||||
|
handleCompletion: function handleCompletion(reason) {
|
||||||
|
execCb(this.visits);
|
||||||
}
|
}
|
||||||
} finally {
|
});
|
||||||
this._visitStm.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
return visits;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// See bug 468732 for why we use SQL here
|
// See bug 468732 for why we use SQL here
|
||||||
_findURLByGUID: function HistStore__findURLByGUID(guid) {
|
_findURLByGUID: function HistStore__findURLByGUID(guid) {
|
||||||
try {
|
this._urlStm.params.guid = guid;
|
||||||
this._urlStm.params.guid = guid;
|
let [exec, execCb] = Sync.withCb(this._urlStm.executeAsync, this._urlStm);
|
||||||
if (!this._urlStm.step())
|
return exec({
|
||||||
return null;
|
handleResult: function(results) {
|
||||||
|
// Save the one result and its columns
|
||||||
return {
|
let row = results.getNextRow();
|
||||||
url: this._urlStm.row.url,
|
this.urlInfo = {
|
||||||
title: this._urlStm.row.title,
|
url: row.getResultByName("url"),
|
||||||
frecency: this._urlStm.row.frecency
|
title: row.getResultByName("title"),
|
||||||
};
|
frecency: row.getResultByName("frecency"),
|
||||||
}
|
};
|
||||||
finally {
|
},
|
||||||
this._urlStm.reset();
|
handleError: function(error) {
|
||||||
}
|
execCb.throw(error);
|
||||||
|
},
|
||||||
|
handleCompletion: function(reason) {
|
||||||
|
// Throw in-case for some reason we didn't find the GUID
|
||||||
|
if (this.urlInfo == null)
|
||||||
|
execCb.throw(reason);
|
||||||
|
execCb(this.urlInfo);
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
changeItemID: function HStore_changeItemID(oldID, newID) {
|
changeItemID: function HStore_changeItemID(oldID, newID) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче