bug 441446: set mozBackgroundRequest on XMPP request object when created rather than when used, since it only needs to be set once
authorMyk Melez <myk@mozilla.org>
Tue, 24 Jun 2008 17:45:37 -0700
changeset 44734 fb21be8385f75574c34f6c699b8de2abf06473d7
parent 44712 144c3ff4a5d1eaf40cd4e2bf68a049f8809de090
child 44735 83a955a47d0404e8f5a43e0f11f91a39361efc15
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs441446
bug 441446: set mozBackgroundRequest on XMPP request object when created rather than when used, since it only needs to be set once
services/sync/modules/xmpp/transportLayer.js
--- a/services/sync/modules/xmpp/transportLayer.js
+++ b/services/sync/modules/xmpp/transportLayer.js
@@ -172,21 +172,21 @@ HTTPPollingTransport.prototype = {
     this._callbackObject = null;
     this._useKeys = useKeys;
     this._interval = interval;
     this._outgoingRetryBuffer = "";
     this._retryCount = 0;
     this._retryCap = 0;
   },
 
-  __request: null,
   get _request() {
-    if (!this.__request)
-      this.__request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance( Ci.nsIXMLHttpRequest );
-    return this.__request;
+    let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance( Ci.nsIXMLHttpRequest );
+    request.mozBackgroundRequest = true;
+    this.__defineGetter__("_request", function() request);
+    return this._request;
   },
 
   __hasher: null,
   get _hasher() {
     if (!this.__hasher)
       this.__hasher = Cc["@mozilla.org/security/hash;1"].createInstance( Ci.nsICryptoHash );
     return this.__hasher;
   },
@@ -251,17 +251,16 @@ HTTPPollingTransport.prototype = {
     if ( this._callbackObject != null ) {
       this._callbackObject.onTransportError( errorText );
     }
     this.disconnect();
   },
 
   _doPost: function( requestXml ) {
     var request = this._request;
-    request.mozBackgroundRequest = true;
     var callbackObj = this._callbackObject;
     var self = this;
     var contents = "";
 
     if ( this._useKey ) {
       this._advanceKey();
       contents = this._connectionId + ";" + this._key + "," + requestXml;
     } else {