WeaveSvc_processCommands: async + async/yield -> sync.
authorEdward Lee <edilee@mozilla.com>
Fri, 05 Jun 2009 22:21:25 -0700
changeset 45532 48d3eb25f43facfb9cfecb5483dcd2bfda1d762d
parent 45531 c4fc57042f899e0b5580aad4ae5118634c05b151
child 45533 5fd6fe1fd76b1821ecc94b8ab10d2fdb66aa63be
push id14033
push useredward.lee@engineering.uiuc.edu
push dateWed, 23 Jun 2010 22:21:35 +0000
treeherdermozilla-central@227db4ad8cdf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
WeaveSvc_processCommands: async + async/yield -> sync.
services/sync/modules/service.js
--- a/services/sync/modules/service.js
+++ b/services/sync/modules/service.js
@@ -858,17 +858,17 @@ WeaveSvc.prototype = {
     }
 
     this._log.debug("Refreshing client list");
     Clients.sync();
 
     // Process the incoming commands if we have any
     if (Clients.getClients()[Clients.clientID].commands) {
       try {
-        if (!(yield this.processCommands(self.cb))) {
+        if (!(this.processCommands())) {
           this._detailedStatus.setSyncStatus(ABORT_SYNC_COMMAND);
           throw "aborting sync, process commands said so";
         }
 
         // Repeat remoteSetup in-case the commands forced us to reset
         if (!(yield this._remoteSetup.async(this, self.cb)))
           throw "aborting sync, remote setup failed after processing commands";
       }
@@ -1133,23 +1133,20 @@ WeaveSvc.prototype = {
     for (let [i, attr] in Iterator(["args", "desc"]))
       commands[entry[0]][attr] = entry[i + 1];
     return commands;
   }, {}),
 
   /**
    * Check if the local client has any remote commands and perform them.
    *
-   * @param onComplete
-   *        Callback when this method completes
    * @return False to abort sync
    */
-  processCommands: function WeaveSvc_processCommands(onComplete) {
-    let fn = function WeaveSvc__processCommands() {
-      let self = yield;
+  processCommands: function WeaveSvc_processCommands()
+    this._notify("process-commands", "", function() {
       let info = Clients.getInfo(Clients.clientID);
       let commands = info.commands;
 
       // Immediately clear out the commands as we've got them locally
       delete info.commands;
       Clients.setInfo(Clients.clientID, info);
 
       // Process each command in order
@@ -1173,20 +1170,18 @@ WeaveSvc.prototype = {
             break;
 
           default:
             this._log.debug("Received an unknown command: " + command);
             break;
         }
       }
 
-      self.done(true);
-    };
-    this._notifyAsync("process-commands", "", fn).async(this, onComplete);
-  },
+      return true;
+    })(),
 
   /**
    * Prepare to send a command to each remote client. Calling this doesn't
    * actually sync the command data to the server. If the client already has
    * the command/args pair, it won't get a duplicate action.
    *
    * @param command
    *        Command to invoke on remote clients