Automated merge with http://hg.mozilla.org/labs/weave
authorAtul Varma <varmaa@toolness.com>
Mon, 30 Jun 2008 23:36:06 -0700
changeset 44863 a861ed0bfdff8bb6327973a9061e48747088c13a
parent 44861 16d47211c135e2bf0e8441062d4ed9c576f09937 (diff)
parent 44862 0587eb06d2906f087672ab7791f0f264f30a1293 (current diff)
child 44865 36412fe43dcefc2cf87494f96396ce338d9be2ee
push id14033
push useredward.lee@engineering.uiuc.edu
push dateWed, 23 Jun 2010 22:21:35 +0000
treeherderautoland@227db4ad8cdf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
Automated merge with http://hg.mozilla.org/labs/weave
--- a/services/sync/locales/en-US/wizard.dtd
+++ b/services/sync/locales/en-US/wizard.dtd
@@ -9,17 +9,17 @@
 <!ENTITY intro-warning.description        "Warning: Use at your own risk! Back up Firefox data before continuing with installation.">
 
 <!ENTITY eula.title                       "Software License Agreement">
 <!ENTITY eula.description                 "Terms and conditions for using this software.">
 <!ENTITY eula.accept                      "I accept the terms of the License Agreement">
 <!ENTITY eula.decline                     "I do NOT accept the terms of the License Agreement">
 
 <!ENTITY welcome.title			  "Setup Options">
-<!ENTITY curUser-title.label              "Set up Another Computer">
+<!ENTITY curUser-title.label              "Set Up Another Computer">
 <!ENTITY curUser.description              "Sign in and associate this computer with your existing Weave account.">
 <!ENTITY newUser-title.label              "Get Started with Weave">
 <!ENTITY newUser.description              "Create a new account and configure the automated backup and synchronization of your browser settings and metadata to a Weave server.">
 
 <!ENTITY verify.title                     "Account Verification (Step 1 of 3)">
 <!ENTITY username.label                   "Username:">
 <!ENTITY password.label                   "Password:">
 <!ENTITY passphrase.label                 "Passphrase:">
--- a/services/sync/modules/engines/cookies.js
+++ b/services/sync/modules/engines/cookies.js
@@ -141,17 +141,18 @@ CookieStore.prototype = {
     // 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._log.debug("CookieStore got create command for: " + command.GUID);
+
     // this assumes command.data fits the nsICookie2 interface
     if ( !command.data.isSession ) {
       // Add only persistent cookies ( not session cookies )
       this._cookieManager.add( command.data.host,
 			       command.data.path,
 			       command.data.name,
 			       command.data.value,
 			       command.data.isSecure,
@@ -162,32 +163,43 @@ CookieStore.prototype = {
   },
 
   _removeCommand: function CookieStore__removeCommand(command) {
     /* we got a command to remove a cookie from the local browser
        in order to sync with the server.
        command.data appears to be equivalent to what wrap() puts in
        the JSON dictionary. */
 
-    this._log.info("CookieStore got removeCommand: " + command );
+    if (!(command.GUID in this._lookup)) {
+      this._log.warn("Warning! Remove command for unknown item: " + command.GUID);
+      return;
+    }
+
+    this._log.debug("CookieStore got remove command for: " + command.GUID);
 
     /* I think it goes like this, according to
-      http://developer.mozilla.org/en/docs/nsICookieManager
-      the last argument is "always block cookies from this domain?"
-      and the answer is "no". */
+     http://developer.mozilla.org/en/docs/nsICookieManager
+     the last argument is "always block cookies from this domain?"
+     and the answer is "no". */
     this._cookieManager.remove(this._lookup[command.GUID].host,
                                this._lookup[command.GUID].name,
                                this._lookup[command.GUID].path,
-                               false );
+                               false);
   },
 
   _editCommand: function CookieStore__editCommand(command) {
     /* we got a command to change a cookie in the local browser
        in order to sync with the server. */
-    this._log.info("CookieStore got editCommand: " + command );
+
+    if (!(command.GUID in this._lookup)) {
+      this._log.warn("Warning! Edit command for unknown item: " + command.GUID);
+      return;
+    }
+
+    this._log.debug("CookieStore got edit command for: " + command.GUID);
 
     /* Look up the cookie that matches the one in the command: */
     var iter = this._cookieManager.enumerator;
     var matchingCookie = null;
     while (iter.hasMoreElements()){
       let cookie = iter.getNext();
       if (cookie.QueryInterface( Ci.nsICookie ) ){
         // see if host:path:name of cookie matches GUID given in command
--- a/services/sync/modules/remote.js
+++ b/services/sync/modules/remote.js
@@ -530,52 +530,53 @@ RemoteStore.prototype = {
   // deltas from the given snapshot (but may fall back to a full download)
   _getLatestFromSnap: function RStore__getLatestFromSnap(lastSyncSnap) {
     let self = yield;
     let deltas, snap = new SnapshotStore();
     snap.version = this.status.data.maxVersion;
 
     if (lastSyncSnap.version < this.status.data.snapVersion) {
       this._log.trace("Getting latest from snap --> scratch");
-      self.done(yield this._getLatestFromScratch.async(this, self.cb));
+      snap = yield this._getLatestFromScratch.async(this, self.cb);
+      self.done(snap);
       return;
 
     } else if (lastSyncSnap.version >= this.status.data.snapVersion &&
                lastSyncSnap.version < this.status.data.maxVersion) {
       this._log.debug("Using last sync snapshot as starting point for server snapshot");
       snap.data = Utils.deepCopy(lastSyncSnap.data);
       this._log.info("Downloading server deltas");
       deltas = [];
       let min = lastSyncSnap.version + 1;
       let max = this.status.data.maxVersion;
       for (let id = min; id <= max; id++) {
-        deltas.push(yield this._deltas.get(self.cb, id));
+        let delta = yield this._deltas.get(self.cb, id);
+        deltas.push(delta);
       }
 
     } else if (lastSyncSnap.version == this.status.data.maxVersion) {
       this._log.debug("Using last sync snapshot as server snapshot (snap version == max version)");
       this._log.trace("Local snapshot version == server maxVersion");
       snap.data = Utils.deepCopy(lastSyncSnap.data);
       deltas = [];
 
     } else { // lastSyncSnap.version > this.status.data.maxVersion
       this._log.error("Server snapshot is older than local snapshot");
       throw "Server snapshot is older than local snapshot";
     }
 
     try {
       for (var i = 0; i < deltas.length; i++) {
-        snap.applyCommands.async(snap, self.cb, deltas[i]);
-        yield;
+        yield snap.applyCommands.async(snap, self.cb, deltas[i]);
       }
     } catch (e) {
       this._log.warn("Error applying remote deltas to saved snapshot, attempting a full download");
       this._log.debug("Exception: " + Utils.exceptionStr(e));
       this._log.trace("Stack:\n" + Utils.stackTrace(e));
-      snap = this._getLatestFromScratch.async(this, self.cb);
+      snap = yield this._getLatestFromScratch.async(this, self.cb);
     }
 
     self.done(snap);
   },
 
   // get the latest server snapshot.  If a snapshot is given, try to
   // download only the necessary deltas to get to the latest
   _wrap: function RStore__wrap(snapshot) {
--- a/services/sync/modules/stores.js
+++ b/services/sync/modules/stores.js
@@ -107,24 +107,24 @@ Store.prototype = {
 
   // override only if neccessary
   _itemExists: function Store__itemExists(GUID) {
     if (GUID in this._lookup)
       return true;
     else
       return false;
   },
-  
+
   // override these in derived objects
-  
+
   // wrap MUST save the wrapped store in the _lookup property!
   wrap: function Store_wrap() {
     throw "wrap needs to be subclassed";
   },
-  
+
   wipe: function Store_wipe() {
     throw "wipe needs to be subclassed";
   },
 
   _resetGUIDs: function Store__resetGUIDs() {
     let self = yield;
     throw "_resetGUIDs needs to be subclassed";
   },
@@ -196,17 +196,20 @@ SnapshotStore.prototype = {
         if (("parentGUID" in this._data[GUID]) &&
             (this._data[GUID].parentGUID == oldGUID))
           this._data[GUID].parentGUID = newGUID;
       }
     }
     for (let prop in command.data) {
       if (prop == "GUID")
         continue;
-      this._data[command.GUID][prop] = command.data[prop];
+      if (command.GUID in this._data)
+        this._data[command.GUID][prop] = command.data[prop];
+      else
+        this._log.warn("Warning! Edit command for unknown item: " + command.GUID);
     }
   },
 
   save: function SStore_save() {
     this._log.info("Saving snapshot to disk");
 
     let file = Utils.getProfileFile(
       {path: "weave/snapshots/" + this.filename,