mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 511965 - Delay Places syncs after results updates, r=sdwilsh
This commit is contained in:
parent
eaf7e3c442
commit
3f51d0e4e0
@ -222,7 +222,7 @@ nsPlacesDBFlush.prototype = {
|
||||
this._timer = this._newTimer();
|
||||
|
||||
// We need to sync now
|
||||
this._flushWithQueries([kQuerySyncPlacesId, kQuerySyncHistoryVisitsId]);
|
||||
this._delayedFlushWithQueries([kQuerySyncPlacesId, kQuerySyncHistoryVisitsId]);
|
||||
},
|
||||
|
||||
onItemAdded: function(aItemId, aParentId, aIndex)
|
||||
@ -231,14 +231,14 @@ nsPlacesDBFlush.prototype = {
|
||||
// least amount of queries as possible here for performance reasons.
|
||||
if (!this._inBatchMode &&
|
||||
this._bs.getItemType(aItemId) == this._bs.TYPE_BOOKMARK)
|
||||
this._flushWithQueries([kQuerySyncPlacesId]);
|
||||
this._delayedFlushWithQueries([kQuerySyncPlacesId]);
|
||||
},
|
||||
|
||||
onItemChanged: function DBFlush_onItemChanged(aItemId, aProperty,
|
||||
aIsAnnotationProperty, aValue)
|
||||
{
|
||||
if (!this._inBatchMode && aProperty == "uri")
|
||||
this._flushWithQueries([kQuerySyncPlacesId]);
|
||||
this._delayedFlushWithQueries([kQuerySyncPlacesId]);
|
||||
},
|
||||
|
||||
onBeforeItemRemoved: function() { },
|
||||
@ -350,6 +350,22 @@ nsPlacesDBFlush.prototype = {
|
||||
this._db.executeAsync(statements, statements.length, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Enqueues a flush to the main thread, used in observers to avoid flushing
|
||||
* while the original method is still notifying.
|
||||
*/
|
||||
_delayedFlushWithQueries: function DBFlush_delayedflushWithQueries(aQueryNames)
|
||||
{
|
||||
let tm = Cc["@mozilla.org/thread-manager;1"].
|
||||
getService(Ci.nsIThreadManager);
|
||||
let self = this;
|
||||
tm.mainThread.dispatch({
|
||||
run: function() {
|
||||
self._flushWithQueries(aQueryNames);
|
||||
}
|
||||
}, Ci.nsIThread.DISPATCH_NORMAL);
|
||||
},
|
||||
|
||||
/**
|
||||
* Finalizes all of our mozIStorageStatements so we can properly close the
|
||||
* database.
|
||||
|
Loading…
Reference in New Issue
Block a user