Backed out changeset f785bf2e2c51 (bug 941726) for test failures in B2g Desktop Linux & B2G ICS Emulator Opt
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Tue, 03 Dec 2013 12:52:49 +0100
changeset 158592 59228cb34257ad201c5bd69ca0338153fb17758e
parent 158591 e6b278c315bcb08d8b9c8884d501f9fae7df0889
child 158593 160de960beb1270b08a1ebae0c319f8e221c837c
push id37037
push userryanvm@gmail.com
push dateTue, 03 Dec 2013 22:42:39 +0000
treeherdermozilla-inbound@8dfe4e73db8e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs941726
milestone28.0a1
backs outf785bf2e2c5177c2465dcefa211281aa1c32839b
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset f785bf2e2c51 (bug 941726) for test failures in B2g Desktop Linux & B2G ICS Emulator Opt
toolkit/components/jsdownloads/src/DownloadCore.jsm
toolkit/components/jsdownloads/src/DownloadLegacy.js
--- a/toolkit/components/jsdownloads/src/DownloadCore.jsm
+++ b/toolkit/components/jsdownloads/src/DownloadCore.jsm
@@ -2038,48 +2038,38 @@ this.DownloadLegacySaver.prototype = {
           // original one as the failure reason of the download.  Note that on
           // Windows we may get an access denied error instead of a no such file
           // error if the file existed before, and was recently deleted.
           if (!(e2 instanceof OS.File.Error &&
                 (e2.becauseNoSuchFile || e2.becauseAccessDenied))) {
             Cu.reportError(e2);
           }
         }
-        // In case the operation failed, ensure we stop downloading data.  Since
-        // we never re-enter this function, deferCanceled is always available.
-        this.deferCanceled.resolve();
         throw ex;
       } finally {
-        // We don't need the reference to the request anymore.  We must also set
-        // deferCanceled to null in order to free any indirect references it
-        // may hold to the request.
+        // We don't need the reference to the request anymore.
         this.request = null;
-        this.deferCanceled = null;
         // Allow the download to restart through a DownloadCopySaver.
         this.firstExecutionFinished = true;
       }
     }.bind(this));
   },
 
   /**
    * Implements "DownloadSaver.cancel".
    */
   cancel: function DLS_cancel()
   {
     // We may be using a DownloadCopySaver to handle resuming.
     if (this.copySaver) {
       return this.copySaver.cancel.apply(this.copySaver, arguments);
     }
 
-    // If the download hasn't stopped already, resolve deferCanceled so that the
-    // operation is canceled as soon as a cancellation handler is registered.
-    // Note that the handler might not have been registered yet.
-    if (this.deferCanceled) {
-      this.deferCanceled.resolve();
-    }
+    // Cancel the operation as soon as the object is connected.
+    this.deferCanceled.resolve();
   },
 
   /**
    * Implements "DownloadSaver.removePartialData".
    */
   removePartialData: function ()
   {
     // DownloadCopySaver and DownloadLeagcySaver use the same logic for removing
--- a/toolkit/components/jsdownloads/src/DownloadLegacy.js
+++ b/toolkit/components/jsdownloads/src/DownloadLegacy.js
@@ -110,18 +110,17 @@ DownloadLegacyTransfer.prototype = {
 
         download.saver.onTransferStarted(
                          aRequest,
                          this._cancelable instanceof Ci.nsIHelperAppLauncher);
 
         // To handle asynchronous cancellation properly, we should hook up the
         // handler only after we have been notified that the main request
         // started.  We will wait until the main request stopped before
-        // notifying that the download has been canceled.  Since the request has
-        // not completed yet, deferCanceled is guaranteed to be set.
+        // notifying that the download has been canceled.
         return download.saver.deferCanceled.promise.then(() => {
           // Only cancel if the object executing the download is still running.
           if (this._cancelable && !this._componentFailed) {
             this._cancelable.cancel(Cr.NS_ERROR_ABORT);
             if (this._cancelable instanceof Ci.nsIWebBrowserPersist) {
               // This component will not send the STATE_STOP notification.
               download.saver.onTransferFinished(aRequest, Cr.NS_ERROR_ABORT);
               this._cancelable = null;
@@ -235,18 +234,21 @@ DownloadLegacyTransfer.prototype = {
       contentType: contentType,
       launcherPath: launcherPath
     }).then(function DLT_I_onDownload(aDownload) {
       // Legacy components keep partial data when they use a ".part" file.
       if (aTempFile) {
         aDownload.tryToKeepPartialData = true;
       }
 
-      // Start the download before allowing it to be controlled.  Ignore errors.
-      aDownload.start().then(null, () => {});
+      // Start the download before allowing it to be controlled.
+      aDownload.start().then(null, function () {
+        // In case the operation failed, ensure we stop downloading data.
+        aDownload.saver.deferCanceled.resolve();
+      });
 
       // Start processing all the other events received through nsITransfer.
       this._deferDownload.resolve(aDownload);
 
       // Add the download to the list, allowing it to be seen and canceled.
       return Downloads.getList(Downloads.ALL).then(list => list.add(aDownload));
     }.bind(this)).then(null, Cu.reportError);
   },