From 589f3222eb81aa606db2e2666df967bb65d7da5d Mon Sep 17 00:00:00 2001 From: Dan Mills Date: Fri, 13 Jun 2008 15:49:18 +0900 Subject: [PATCH] To avoid some async.js warnings: Turn some 'yield' calls into 'return' ones, and don't call 'self.cb' twice in a row when constructing event listeners for XHRs. --- services/sync/modules/dav.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/services/sync/modules/dav.js b/services/sync/modules/dav.js index 66463de72bc..dfcba2cf04f 100644 --- a/services/sync/modules/dav.js +++ b/services/sync/modules/dav.js @@ -127,8 +127,9 @@ DAVCollection.prototype = { let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(); request = request.QueryInterface(Ci.nsIDOMEventTarget); - request.addEventListener("load", new Utils.EventListener(self.cb, "load"), false); - request.addEventListener("error", new Utils.EventListener(self.cb, "error"), false); + let cb = self.cb; + request.addEventListener("load", new Utils.EventListener(cb, "load"), false); + request.addEventListener("error", new Utils.EventListener(cb, "error"), false); request = request.QueryInterface(Ci.nsIXMLHttpRequest); request.open(op, this._baseURL + path, true); @@ -318,7 +319,7 @@ DAVCollection.prototype = { if (this._authProvider._authFailed || resp.status < 200 || resp.status >= 300) { self.done(false); - yield; + return; } self.done(true); @@ -364,7 +365,7 @@ DAVCollection.prototype = { if (DAVLocks['default']) { this._log.debug("Lock called, but we already hold a token"); self.done(DAVLocks['default']); - yield; + return; } this.LOCK("lock", @@ -376,10 +377,8 @@ DAVCollection.prototype = { let resp = yield; if (this._authProvider._authFailed || - resp.status < 200 || resp.status >= 300) { - self.done(); - yield; - } + resp.status < 200 || resp.status >= 300) + return; let tokens = Utils.xpath(resp.responseXML, '//D:locktoken/D:href'); let token = tokens.iterateNext();