fix cooe engine's resetGUIDs method by importing async module; don't call runInBatchMode in bookmark engine's resetGUIDs, it doesn't work atm
authorDan Mills <thunder@mozilla.com>
Sun, 29 Jun 2008 11:44:27 -0700
changeset 44809 441e6591e46494d6232086949c464569b31828de
parent 44808 57ff06d822d8b5fb831b7c3e196451ed01cfa950
child 44810 3ed727005c8365813dc87725a55e22bbe728f4e1
push idunknown
push userunknown
push dateunknown
fix cooe engine's resetGUIDs method by importing async module; don't call runInBatchMode in bookmark engine's resetGUIDs, it doesn't work atm
services/sync/modules/engines/bookmarks.js
services/sync/modules/engines/cookies.js
--- a/services/sync/modules/engines/bookmarks.js
+++ b/services/sync/modules/engines/bookmarks.js
@@ -47,16 +47,17 @@ const OUTGOING_SHARED_ANNO = "weave/shar
 const SERVER_PATH_ANNO = "weave/shared-server-path";
 // Standard names for shared files on the server
 const KEYRING_FILE_NAME = "keyring";
 const SHARED_BOOKMARK_FILE_NAME = "shared_bookmarks";
 // Information for the folder that contains all incoming shares
 const INCOMING_SHARE_ROOT_ANNO = "weave/mounted-shares-folder";
 const INCOMING_SHARE_ROOT_NAME = "Shared Folders";
 
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://weave/log4moz.js");
 Cu.import("resource://weave/dav.js");
 Cu.import("resource://weave/util.js");
 Cu.import("resource://weave/crypto.js");
 Cu.import("resource://weave/async.js");
 Cu.import("resource://weave/engines.js");
 Cu.import("resource://weave/syncCores.js");
 Cu.import("resource://weave/stores.js");
@@ -836,17 +837,17 @@ BookmarksStore.prototype = {
       return this._bms.toolbarFolder;
     case "unfiled":
       return this._bms.unfiledBookmarksFolder;
     default:
       return this._bms.getItemIdForGUID(GUID);
     }
     return null;
   },
-  
+
   _createCommand: function BStore__createCommand(command) {
     let newId;
     let parentId = this._getItemIdForGUID(command.data.parentGUID);
 
     if (parentId < 0) {
       this._log.warn("Creating node with unknown parent -> reparenting to root");
       parentId = this._bms.bookmarksMenuFolder;
     }
@@ -1253,25 +1254,19 @@ BookmarksStore.prototype = {
       for (var i = 0; i < node.childCount; i++) {
         this.__resetGUIDs(node.getChild(i));
       }
     }
   },
 
   _resetGUIDs: function BStore__resetGUIDs() {
     let self = yield;
-    this._bms.runInBatchMode({
-      QueryInterface: XPCOMUtils.generateQI([Ci.nsINavHistoryBatchCallback,
-                                             Ci.nsISupports]),
-      runBatched: function BStore_resetGUIDs_cb(userData) {
-        this.__resetGUIDs(this._getNode(this._bms.bookmarksMenuFolder));
-        this.__resetGUIDs(this._getNode(this._bms.toolbarFolder));
-        this.__resetGUIDs(this._getNode(this._bms.unfiledBookmarksFolder));
-      }
-    });
+    this.__resetGUIDs(this._getNode(this._bms.bookmarksMenuFolder));
+    this.__resetGUIDs(this._getNode(this._bms.toolbarFolder));
+    this.__resetGUIDs(this._getNode(this._bms.unfiledBookmarksFolder));
   }
 };
 BookmarksStore.prototype.__proto__ = new Store();
 
 /*
  * Tracker objects for each engine may need to subclass the
  * getScore routine, which returns the current 'score' for that
  * engine. How the engine decides to set the score is upto it,
--- a/services/sync/modules/engines/cookies.js
+++ b/services/sync/modules/engines/cookies.js
@@ -36,21 +36,24 @@
 
 const EXPORTED_SYMBOLS = ['CookieEngine', 'CookieTracker', 'CookieStore'];
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cu = Components.utils;
 
 Cu.import("resource://weave/log4moz.js");
+Cu.import("resource://weave/async.js");
 Cu.import("resource://weave/engines.js");
 Cu.import("resource://weave/syncCores.js");
 Cu.import("resource://weave/stores.js");
 Cu.import("resource://weave/trackers.js");
 
+Function.prototype.async = Async.sugar;
+
 function CookieEngine(pbeId) {
   this._init(pbeId);
 }
 CookieEngine.prototype = {
   get name() { return "cookies"; },
   get logName() { return "CookieEngine"; },
   get serverPrefix() { return "user-data/cookies/"; },
 
@@ -133,17 +136,17 @@ CookieStore.prototype = {
     // otherwise, use the real one
     if (!this.__cookieManager)
       this.__cookieManager = Cc["@mozilla.org/cookiemanager;1"].
                              getService(Ci.nsICookieManager2);
     // need the 2nd revision of the ICookieManager interface
     // because it supports add() and the 1st one doesn't.
     return this.__cookieManager;
   },
-  
+
   _createCommand: function CookieStore__createCommand(command) {
     /* we got a command to create a cookie in the local browser
        in order to sync with the server. */
 
     this._log.info("CookieStore got createCommand: " + command );
     // this assumes command.data fits the nsICookie2 interface
     if ( !command.data.isSession ) {
       // Add only persistent cookies ( not session cookies )