Bug 612255 - Don't handle duplicate batches in nsPlacesDBFlush.
authorMarco Bonardo <mbonardo@mozilla.com>
Mon, 15 Nov 2010 16:51:46 +0100
changeset 57519 23dcbd0c286c9fc1caf014bc89751eba21352504
parent 57518 3cba2bc69c51f5b8edca08a92176c7c20035fa9a
child 57520 54bc059a6ecc7fbec384cc8bba9e14873bf1e4de
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
bugs612255
milestone2.0b8pre
Bug 612255 - Don't handle duplicate batches in nsPlacesDBFlush. r+a=sdwilsh
toolkit/components/places/src/nsPlacesDBFlush.js
--- a/toolkit/components/places/src/nsPlacesDBFlush.js
+++ b/toolkit/components/places/src/nsPlacesDBFlush.js
@@ -150,25 +150,35 @@ nsPlacesDBFlush.prototype = {
     }
   },
 
   //////////////////////////////////////////////////////////////////////////////
   //// nsINavBookmarkObserver
 
   onBeginUpdateBatch: function DBFlush_onBeginUpdateBatch()
   {
+    // Since we observe both history and bookmarks, we can be notified twice
+    // about a batch.
+    if (this._inBatchMode)
+      return;
+
     this._inBatchMode = true;
 
     // We do not want to sync while we are doing batch work.
     this._timer.cancel();
     this._timer = null;
   },
 
   onEndUpdateBatch: function DBFlush_onEndUpdateBatch()
   {
+    // Since we observe both history and bookmarks, we can be notified twice
+    // about a batch.
+    if (!this._inBatchMode)
+      return;
+
     this._inBatchMode = false;
 
     // Restore our timer
     this._timer = this._newTimer();
 
     // We need to sync now
     this._flushWithQueries([kQuerySyncPlacesId, kQuerySyncHistoryVisitsId]);
   },