Bug 830415 - Part 1 - Update the header styles of the Downloads API modules. r=mak
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Mon, 24 Jul 2017 12:16:01 +0100
changeset 420036 58dd26b26962b48ab5e1b79a05e35c864ccd52a8
parent 420035 03d1cedf6f127bac8b3f6e7f4f89930bf97bea0c
child 420037 b1826fe01838c61584a50af4d2104eca1fc1b724
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs830415
milestone56.0a1
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
Bug 830415 - Part 1 - Update the header styles of the Downloads API modules. r=mak File comments now consistently provide an overview instead of repeating the object comments. Redundant headers are removed together with other style changes, and mode lines are removed as they are only used by a small fraction of the JSM files in the tree. MozReview-Commit-ID: 42fs7rT2BNM
toolkit/components/jsdownloads/src/DownloadCore.jsm
toolkit/components/jsdownloads/src/DownloadIntegration.jsm
toolkit/components/jsdownloads/src/DownloadLegacy.js
toolkit/components/jsdownloads/src/DownloadList.jsm
toolkit/components/jsdownloads/src/DownloadStore.jsm
toolkit/components/jsdownloads/src/DownloadUIHelper.jsm
toolkit/components/jsdownloads/src/Downloads.jsm
--- a/toolkit/components/jsdownloads/src/DownloadCore.jsm
+++ b/toolkit/components/jsdownloads/src/DownloadCore.jsm
@@ -1,66 +1,31 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80 filetype=javascript: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /**
- * This file includes the following constructors and global objects:
- *
- * Download
- * Represents a single download, with associated state and actions.  This object
- * is transient, though it can be included in a DownloadList so that it can be
- * managed by the user interface and persisted across sessions.
- *
- * DownloadSource
- * Represents the source of a download, for example a document or an URI.
- *
- * DownloadTarget
- * Represents the target of a download, for example a file in the global
- * downloads directory, or a file in the system temporary directory.
- *
- * DownloadError
- * Provides detailed information about a download failure.
- *
- * DownloadSaver
- * Template for an object that actually transfers the data for the download.
- *
- * DownloadCopySaver
- * Saver object that simply copies the entire source file to the target.
- *
- * DownloadLegacySaver
- * Saver object that integrates with the legacy nsITransfer interface.
- *
- * DownloadPDFSaver
- * This DownloadSaver type creates a PDF file from the current document in a
- * given window, specified using the windowRef property of the DownloadSource
- * object associated with the download.
+ * Main implementation of the Downloads API objects. Consumers should get
+ * references to these objects through the "Downloads.jsm" module.
  */
 
 "use strict";
 
 this.EXPORTED_SYMBOLS = [
   "Download",
   "DownloadSource",
   "DownloadTarget",
   "DownloadError",
   "DownloadSaver",
   "DownloadCopySaver",
   "DownloadLegacySaver",
   "DownloadPDFSaver",
 ];
 
-// Globals
-
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cu = Components.utils;
-const Cr = Components.results;
+const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
 
 Cu.import("resource://gre/modules/Integration.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
                                   "resource://gre/modules/FileUtils.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
                                   "resource://gre/modules/NetUtil.jsm");
@@ -133,18 +98,16 @@ function deserializeUnknownProperties(aO
 
 /**
  * This determines the minimum time interval between updates to the number of
  * bytes transferred, and is a limiting factor to the sequence of readings used
  * in calculating the speed of the download.
  */
 const kProgressUpdateIntervalMs = 400;
 
-// Download
-
 /**
  * Represents a single download, with associated state and actions.  This object
  * is transient, though it can be included in a DownloadList so that it can be
  * managed by the user interface and persisted across sessions.
  */
 this.Download = function() {
   this._deferSucceeded = PromiseUtils.defer();
 }
@@ -1220,18 +1183,16 @@ Download.fromSerializable = function(aSe
     property != "source" &&
     property != "target" &&
     property != "error" &&
     property != "saver");
 
   return download;
 };
 
-// DownloadSource
-
 /**
  * Represents the source of a download, for example a document or an URI.
  */
 this.DownloadSource = function() {}
 
 this.DownloadSource.prototype = {
   /**
    * String containing the URI for the download source.
@@ -1345,18 +1306,16 @@ this.DownloadSource.fromSerializable = f
 
     deserializeUnknownProperties(source, aSerializable, property =>
       property != "url" && property != "isPrivate" && property != "referrer");
   }
 
   return source;
 };
 
-// DownloadTarget
-
 /**
  * Represents the target of a download, for example a file in the global
  * downloads directory, or a file in the system temporary directory.
  */
 this.DownloadTarget = function() {}
 
 this.DownloadTarget.prototype = {
   /**
@@ -1472,18 +1431,16 @@ this.DownloadTarget.fromSerializable = f
     }
 
     deserializeUnknownProperties(target, aSerializable, property =>
       property != "path" && property != "partFilePath");
   }
   return target;
 };
 
-// DownloadError
-
 /**
  * Provides detailed information about a download failure.
  *
  * @param aProperties
  *        Object which may contain any of the following properties:
  *          {
  *            result: Result error code, defaulting to Cr.NS_ERROR_FAILURE
  *            message: String error message to be displayed, or null to use the
@@ -1664,18 +1621,16 @@ this.DownloadError.fromSerializable = fu
     property != "becauseBlockedByParentalControls" &&
     property != "becauseBlockedByReputationCheck" &&
     property != "becauseBlockedByRuntimePermissions" &&
     property != "reputationCheckVerdict");
 
   return e;
 };
 
-// DownloadSaver
-
 /**
  * Template for an object that actually transfers the data for the download.
  */
 this.DownloadSaver = function() {}
 
 this.DownloadSaver.prototype = {
   /**
    * Download object for raising notifications and reading properties.
@@ -1814,18 +1769,16 @@ this.DownloadSaver.fromSerializable = fu
       saver = DownloadPDFSaver.fromSerializable(serializable);
       break;
     default:
       throw new Error("Unrecoginzed download saver type.");
   }
   return saver;
 };
 
-// DownloadCopySaver
-
 /**
  * Saver object that simply copies the entire source file to the target.
  */
 this.DownloadCopySaver = function() {}
 
 this.DownloadCopySaver.prototype = {
   __proto__: DownloadSaver.prototype,
 
@@ -2291,18 +2244,16 @@ this.DownloadCopySaver.fromSerializable 
   }
 
   deserializeUnknownProperties(saver, aSerializable, property =>
     property != "entityID" && property != "type");
 
   return saver;
 };
 
-// DownloadLegacySaver
-
 /**
  * Saver object that integrates with the legacy nsITransfer interface.
  *
  * For more background on the process, see the DownloadLegacyTransfer object.
  */
 this.DownloadLegacySaver = function() {
   this.deferExecuted = PromiseUtils.defer();
   this.deferCanceled = PromiseUtils.defer();
@@ -2659,18 +2610,16 @@ this.DownloadLegacySaver.prototype = {
  * Returns a new DownloadLegacySaver object.  This saver type has a
  * deserializable form only when creating a new object in memory, because it
  * cannot be serialized to disk.
  */
 this.DownloadLegacySaver.fromSerializable = function() {
   return new DownloadLegacySaver();
 };
 
-// DownloadPDFSaver
-
 /**
  * This DownloadSaver type creates a PDF file from the current document in a
  * given window, specified using the windowRef property of the DownloadSource
  * object associated with the download.
  *
  * In order to prevent the download from saving a different document than the one
  * originally loaded in the window, any attempt to restart the download will fail.
  *
--- a/toolkit/components/jsdownloads/src/DownloadIntegration.jsm
+++ b/toolkit/components/jsdownloads/src/DownloadIntegration.jsm
@@ -1,32 +1,24 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80 filetype=javascript: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /**
  * Provides functions to integrate with the host application, handling for
  * example the global prompts on shutdown.
  */
 
 "use strict";
 
 this.EXPORTED_SYMBOLS = [
   "DownloadIntegration",
 ];
 
-////////////////////////////////////////////////////////////////////////////////
-//// Globals
-
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cu = Components.utils;
-const Cr = Components.results;
+const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
 
 Cu.import("resource://gre/modules/Integration.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "AsyncShutdown",
                                   "resource://gre/modules/AsyncShutdown.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
                                   "resource://gre/modules/AppConstants.jsm");
@@ -129,19 +121,16 @@ const kVerdictMap = {
   [Ci.nsIApplicationReputationService.VERDICT_UNCOMMON]:
                 Downloads.Error.BLOCK_VERDICT_UNCOMMON,
   [Ci.nsIApplicationReputationService.VERDICT_POTENTIALLY_UNWANTED]:
                 Downloads.Error.BLOCK_VERDICT_POTENTIALLY_UNWANTED,
   [Ci.nsIApplicationReputationService.VERDICT_DANGEROUS_HOST]:
                 Downloads.Error.BLOCK_VERDICT_MALWARE,
 };
 
-////////////////////////////////////////////////////////////////////////////////
-//// DownloadIntegration
-
 /**
  * Provides functions to integrate with the host application, handling for
  * example the global prompts on shutdown.
  */
 this.DownloadIntegration = {
   /**
    * Main DownloadStore object for loading and saving the list of persistent
    * downloads, or null if the download list was never requested and thus it
@@ -794,19 +783,16 @@ this.DownloadIntegration = {
   forceSave() {
     if (this._store) {
       return this._store.save();
     }
     return Promise.resolve();
   },
 };
 
-////////////////////////////////////////////////////////////////////////////////
-//// DownloadObserver
-
 this.DownloadObserver = {
   /**
    * Flag to determine if the observers have been added previously.
    */
   observersAdded: false,
 
   /**
    * Timer used to delay restarting canceled downloads upon waking and returning
@@ -909,19 +895,17 @@ this.DownloadObserver = {
   _resumeOfflineDownloads: function DO_resumeOfflineDownloads() {
     this._wakeTimer = null;
 
     for (let download of this._canceledOfflineDownloads) {
       download.start().catch(() => {});
     }
   },
 
-  ////////////////////////////////////////////////////////////////////////////
-  //// nsIObserver
-
+  // nsIObserver
   observe: function DO_observe(aSubject, aTopic, aData) {
     let downloadsCount;
     let p = DownloadUIHelper.getPrompter();
     switch (aTopic) {
       case "quit-application-requested":
         downloadsCount = this._publicInProgressDownloads.size +
                          this._privateInProgressDownloads.size;
         this._confirmCancelDownloads(aSubject, downloadsCount, p, p.ON_QUIT);
@@ -992,25 +976,19 @@ this.DownloadObserver = {
       case "xpcom-will-shutdown":
         for (let topic of kObserverTopics) {
           Services.obs.removeObserver(this, topic);
         }
         break;
     }
   },
 
-  ////////////////////////////////////////////////////////////////////////////
-  //// nsISupports
-
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver])
 };
 
-////////////////////////////////////////////////////////////////////////////////
-//// DownloadHistoryObserver
-
 /**
  * Registers a Places observer so that operations on download history are
  * reflected on the provided list of downloads.
  *
  * You do not need to keep a reference to this object in order to keep it alive,
  * because the history service already keeps a strong reference to it.
  *
  * @param aList
@@ -1023,44 +1001,37 @@ this.DownloadHistoryObserver = function 
 }
 
 this.DownloadHistoryObserver.prototype = {
   /**
    * DownloadList object linked to this observer.
    */
   _list: null,
 
-  ////////////////////////////////////////////////////////////////////////////
-  //// nsISupports
-
   QueryInterface: XPCOMUtils.generateQI([Ci.nsINavHistoryObserver]),
 
-  ////////////////////////////////////////////////////////////////////////////
-  //// nsINavHistoryObserver
-
+  // nsINavHistoryObserver
   onDeleteURI: function DL_onDeleteURI(aURI, aGUID) {
     this._list.removeFinished(download => aURI.equals(NetUtil.newURI(
                                                       download.source.url)));
   },
 
+  // nsINavHistoryObserver
   onClearHistory: function DL_onClearHistory() {
     this._list.removeFinished();
   },
 
   onTitleChanged: function () {},
   onBeginUpdateBatch: function () {},
   onEndUpdateBatch: function () {},
   onVisit: function () {},
   onPageChanged: function () {},
   onDeleteVisits: function () {},
 };
 
-////////////////////////////////////////////////////////////////////////////////
-//// DownloadAutoSaveView
-
 /**
  * This view can be added to a DownloadList object to trigger a save operation
  * in the given DownloadStore object when a relevant change occurs.  You should
  * call the "initialize" method in order to register the view and load the
  * current state from disk.
  *
  * You do not need to keep a reference to this object in order to keep it alive,
  * because the DownloadList object already keeps a strong reference to it.
@@ -1126,29 +1097,28 @@ this.DownloadAutoSaveView.prototype = {
    * Called when the list of downloads changed, this triggers the asynchronous
    * serialization of the list of downloads.
    */
   saveSoon: function ()
   {
     this._writer.arm();
   },
 
-  //////////////////////////////////////////////////////////////////////////////
-  //// DownloadList view
-
+  // DownloadList callback
   onDownloadAdded: function (aDownload)
   {
     if (gCombinedDownloadIntegration.shouldPersistDownload(aDownload)) {
       this._downloadsMap.set(aDownload, aDownload.getSerializationHash());
       if (this._initialized) {
         this.saveSoon();
       }
     }
   },
 
+  // DownloadList callback
   onDownloadChanged: function (aDownload)
   {
     if (!gCombinedDownloadIntegration.shouldPersistDownload(aDownload)) {
       if (this._downloadsMap.has(aDownload)) {
         this._downloadsMap.delete(aDownload);
         this.saveSoon();
       }
       return;
@@ -1156,16 +1126,17 @@ this.DownloadAutoSaveView.prototype = {
 
     let hash = aDownload.getSerializationHash();
     if (this._downloadsMap.get(aDownload) != hash) {
       this._downloadsMap.set(aDownload, hash);
       this.saveSoon();
     }
   },
 
+  // DownloadList callback
   onDownloadRemoved: function (aDownload)
   {
     if (this._downloadsMap.has(aDownload)) {
       this._downloadsMap.delete(aDownload);
       this.saveSoon();
     }
   },
 };
--- a/toolkit/components/jsdownloads/src/DownloadLegacy.js
+++ b/toolkit/components/jsdownloads/src/DownloadLegacy.js
@@ -1,42 +1,33 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /**
  * This component implements the XPCOM interfaces required for integration with
  * the legacy download components.
  *
  * New code is expected to use the "Downloads.jsm" module directly, without
  * going through the interfaces implemented in this XPCOM component.  These
  * interfaces are only maintained for backwards compatibility with components
  * that still work synchronously on the main thread.
  */
 
 "use strict";
 
-// Globals
-
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cu = Components.utils;
-const Cr = Components.results;
+const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "Downloads",
                                   "resource://gre/modules/Downloads.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "PromiseUtils",
                                   "resource://gre/modules/PromiseUtils.jsm");
 
-// DownloadLegacyTransfer
-
 /**
  * nsITransfer implementation that provides a bridge to a Download object.
  *
  * Legacy downloads work differently than the JavaScript implementation.  In the
  * latter, the caller only provides the properties for the Download object and
  * the entire process is handled by the "start" method.  In the legacy
  * implementation, the caller must create a separate object to execute the
  * download, and then make the download visible to the user by hooking it up to
@@ -62,24 +53,22 @@ XPCOMUtils.defineLazyModuleGetter(this, 
  */
 function DownloadLegacyTransfer() {
   this._deferDownload = PromiseUtils.defer();
 }
 
 DownloadLegacyTransfer.prototype = {
   classID: Components.ID("{1b4c85df-cbdd-4bb6-b04e-613caece083c}"),
 
-  // nsISupports
 
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
                                          Ci.nsIWebProgressListener2,
                                          Ci.nsITransfer]),
 
   // nsIWebProgressListener
-
   onStateChange: function DLT_onStateChange(aWebProgress, aRequest, aStateFlags,
                                             aStatus) {
     if (!Components.isSuccessCode(aStatus)) {
       this._componentFailed = true;
     }
 
     if ((aStateFlags & Ci.nsIWebProgressListener.STATE_START) &&
         (aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK)) {
@@ -148,28 +137,30 @@ DownloadLegacyTransfer.prototype = {
         download.saver.onTransferFinished(aStatus);
       }).catch(Cu.reportError);
 
       // Release the reference to the component executing the download.
       this._cancelable = null;
     }
   },
 
+  // nsIWebProgressListener
   onProgressChange: function DLT_onProgressChange(aWebProgress, aRequest,
                                                   aCurSelfProgress,
                                                   aMaxSelfProgress,
                                                   aCurTotalProgress,
                                                   aMaxTotalProgress) {
     this.onProgressChange64(aWebProgress, aRequest, aCurSelfProgress,
                             aMaxSelfProgress, aCurTotalProgress,
                             aMaxTotalProgress);
   },
 
   onLocationChange() { },
 
+  // nsIWebProgressListener
   onStatusChange: function DLT_onStatusChange(aWebProgress, aRequest, aStatus,
                                               aMessage) {
     // The status change may optionally be received in addition to the state
     // change, but if no network request actually started, it is possible that
     // we only receive a status change with an error status code.
     if (!Components.isSuccessCode(aStatus)) {
       this._componentFailed = true;
 
@@ -178,37 +169,36 @@ DownloadLegacyTransfer.prototype = {
         aDownload.saver.onTransferFinished(aStatus);
       }).catch(Cu.reportError);
     }
   },
 
   onSecurityChange() { },
 
   // nsIWebProgressListener2
-
   onProgressChange64: function DLT_onProgressChange64(aWebProgress, aRequest,
                                                       aCurSelfProgress,
                                                       aMaxSelfProgress,
                                                       aCurTotalProgress,
                                                       aMaxTotalProgress) {
     // Wait for the associated Download object to be available.
     this._deferDownload.promise.then(function DLT_OPC64_onDownload(aDownload) {
       aDownload.saver.onProgressBytes(aCurTotalProgress, aMaxTotalProgress);
     }).catch(Cu.reportError);
   },
 
+  // nsIWebProgressListener2
   onRefreshAttempted: function DLT_onRefreshAttempted(aWebProgress, aRefreshURI,
                                                       aMillis, aSameURI) {
     // Indicate that refreshes and redirects are allowed by default.  However,
     // note that download components don't usually call this method at all.
     return true;
   },
 
   // nsITransfer
-
   init: function DLT_init(aSource, aTarget, aDisplayName, aMIMEInfo, aStartTime,
                           aTempFile, aCancelable, aIsPrivate) {
     this._cancelable = aCancelable;
 
     let launchWhenSucceeded = false, contentType = null, launcherPath = null;
 
     if (aMIMEInfo instanceof Ci.nsIMIMEInfo) {
       launchWhenSucceeded =
@@ -257,18 +247,16 @@ DownloadLegacyTransfer.prototype = {
   setSignatureInfo(signatureInfo) {
     this._signatureInfo = signatureInfo;
   },
 
   setRedirects(redirects) {
     this._redirects = redirects;
   },
 
-  // Private methods and properties
-
   /**
    * This deferred object contains a promise that is resolved with the Download
    * object associated with this nsITransfer instance, when it is available.
    */
   _deferDownload: null,
 
   /**
    * Reference to the component that is executing the download.  This component
@@ -289,11 +277,9 @@ DownloadLegacyTransfer.prototype = {
   _sha256Hash: null,
 
   /**
    * Save the signature info in a serialized protobuf of the downloaded file.
    */
   _signatureInfo: null,
 };
 
-// Module
-
 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([DownloadLegacyTransfer]);
--- a/toolkit/components/jsdownloads/src/DownloadList.jsm
+++ b/toolkit/components/jsdownloads/src/DownloadList.jsm
@@ -1,48 +1,28 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80 filetype=javascript: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /**
- * This file includes the following constructors and global objects:
- *
- * DownloadList
- * Represents a collection of Download objects that can be viewed and managed by
- * the user interface, and persisted across sessions.
- *
- * DownloadCombinedList
- * Provides a unified, unordered list combining public and private downloads.
- *
- * DownloadSummary
- * Provides an aggregated view on the contents of a DownloadList.
+ * Provides collections of Download objects and aggregate views on them.
  */
 
 "use strict";
 
 this.EXPORTED_SYMBOLS = [
   "DownloadList",
   "DownloadCombinedList",
   "DownloadSummary",
 ];
 
-// Globals
-
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cu = Components.utils;
-const Cr = Components.results;
+const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
-
-// DownloadList
-
 /**
  * Represents a collection of Download objects that can be viewed and managed by
  * the user interface, and persisted across sessions.
  */
 this.DownloadList = function() {
   this._downloads = [];
   this._views = new Set();
 }
@@ -249,18 +229,16 @@ this.DownloadList.prototype = {
           // processing the other downloads in the list.
           download.finalize(true).catch(Cu.reportError);
         }
       }
     })().catch(Cu.reportError);
   },
 };
 
-// DownloadCombinedList
-
 /**
  * Provides a unified, unordered list combining public and private downloads.
  *
  * Download objects added to this list are also added to one of the two
  * underlying lists, based on their "source.isPrivate" property.  Views on this
  * list will receive notifications for both public and private downloads.
  *
  * @param aPublicList
@@ -330,38 +308,37 @@ this.DownloadCombinedList.prototype = {
    */
   remove(aDownload) {
     if (aDownload.source.isPrivate) {
       return this._privateList.remove(aDownload);
     }
     return this._publicList.remove(aDownload);
   },
 
-  // DownloadList view
-
+  // DownloadList callback
   onDownloadAdded(aDownload) {
     this._downloads.push(aDownload);
     this._notifyAllViews("onDownloadAdded", aDownload);
   },
 
+  // DownloadList callback
   onDownloadChanged(aDownload) {
     this._notifyAllViews("onDownloadChanged", aDownload);
   },
 
+  // DownloadList callback
   onDownloadRemoved(aDownload) {
     let index = this._downloads.indexOf(aDownload);
     if (index != -1) {
       this._downloads.splice(index, 1);
     }
     this._notifyAllViews("onDownloadRemoved", aDownload);
   },
 };
 
-// DownloadSummary
-
 /**
  * Provides an aggregated view on the contents of a DownloadList.
  */
 this.DownloadSummary = function() {
   this._downloads = [];
   this._views = new Set();
 }
 
@@ -519,29 +496,30 @@ this.DownloadSummary.prototype = {
           view.onSummaryChanged();
         }
       } catch (ex) {
         Cu.reportError(ex);
       }
     }
   },
 
-  // DownloadList view
-
+  // DownloadList callback
   onDownloadAdded(aDownload) {
     this._downloads.push(aDownload);
     if (this._list) {
       this._onListChanged();
     }
   },
 
+  // DownloadList callback
   onDownloadChanged(aDownload) {
     this._onListChanged();
   },
 
+  // DownloadList callback
   onDownloadRemoved(aDownload) {
     let index = this._downloads.indexOf(aDownload);
     if (index != -1) {
       this._downloads.splice(index, 1);
     }
     this._onListChanged();
   },
 };
--- a/toolkit/components/jsdownloads/src/DownloadStore.jsm
+++ b/toolkit/components/jsdownloads/src/DownloadStore.jsm
@@ -1,10 +1,8 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80 filetype=javascript: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /**
  * Handles serialization of Download objects and persistence into a file, so
  * that the state of downloads can be restored across sessions.
  *
@@ -29,40 +27,33 @@
  */
 
 "use strict";
 
 this.EXPORTED_SYMBOLS = [
   "DownloadStore",
 ];
 
-// Globals
-
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cu = Components.utils;
-const Cr = Components.results;
+const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "Downloads",
                                   "resource://gre/modules/Downloads.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "OS",
                                   "resource://gre/modules/osfile.jsm")
 
 XPCOMUtils.defineLazyGetter(this, "gTextDecoder", function() {
   return new TextDecoder();
 });
 
 XPCOMUtils.defineLazyGetter(this, "gTextEncoder", function() {
   return new TextEncoder();
 });
 
-// DownloadStore
-
 /**
  * Handles serialization of Download objects and persistence into a file, so
  * that the state of downloads can be restored across sessions.
  *
  * @param aList
  *        DownloadList object to be populated or serialized.
  * @param aPath
  *        String containing the file path where data should be saved.
--- a/toolkit/components/jsdownloads/src/DownloadUIHelper.jsm
+++ b/toolkit/components/jsdownloads/src/DownloadUIHelper.jsm
@@ -1,30 +1,23 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80 filetype=javascript: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /**
  * Provides functions to handle status and messages in the user interface.
  */
 
 "use strict";
 
 this.EXPORTED_SYMBOLS = [
   "DownloadUIHelper",
 ];
 
-// Globals
-
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cu = Components.utils;
-const Cr = Components.results;
+const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/AppConstants.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "OS",
                                   "resource://gre/modules/osfile.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "Services",
                                   "resource://gre/modules/Services.jsm");
@@ -36,18 +29,16 @@ const kStringsRequiringFormatting = {
   fileExecutableSecurityWarning: true,
   cancelDownloadsOKTextMultiple: true,
   quitCancelDownloadsAlertMsgMultiple: true,
   quitCancelDownloadsAlertMsgMacMultiple: true,
   offlineCancelDownloadsAlertMsgMultiple: true,
   leavePrivateBrowsingWindowsCancelDownloadsAlertMsgMultiple2: true
 };
 
-// DownloadUIHelper
-
 /**
  * Provides functions to handle status and messages in the user interface.
  */
 this.DownloadUIHelper = {
   /**
    * Returns an object that can be used to display prompts related to downloads.
    *
    * The prompts may be either anchored to a specified window, or anchored to
@@ -87,18 +78,16 @@ XPCOMUtils.defineLazyGetter(DownloadUIHe
       };
     } else {
       strings[stringName] = string.value;
     }
   }
   return strings;
 });
 
-// DownloadPrompter
-
 /**
  * Allows displaying prompts related to downloads.
  *
  * @param aParent
  *        The nsIDOMWindow to which prompts should be attached, or null to
  *        attach prompts to the most recently active window.
  */
 this.DownloadPrompter = function(aParent) {
--- a/toolkit/components/jsdownloads/src/Downloads.jsm
+++ b/toolkit/components/jsdownloads/src/Downloads.jsm
@@ -1,30 +1,23 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80 filetype=javascript: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /**
  * Main entry point to get references to all the back-end objects.
  */
 
 "use strict";
 
 this.EXPORTED_SYMBOLS = [
   "Downloads",
 ];
 
-// Globals
-
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const Cu = Components.utils;
-const Cr = Components.results;
+const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
 
 Cu.import("resource://gre/modules/Integration.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/DownloadCore.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "DownloadCombinedList",
                                   "resource://gre/modules/DownloadList.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "DownloadList",
@@ -33,18 +26,16 @@ XPCOMUtils.defineLazyModuleGetter(this, 
                                   "resource://gre/modules/DownloadList.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "DownloadUIHelper",
                                   "resource://gre/modules/DownloadUIHelper.jsm");
 
 /* global DownloadIntegration */
 Integration.downloads.defineModuleGetter(this, "DownloadIntegration",
             "resource://gre/modules/DownloadIntegration.jsm");
 
-// Downloads
-
 /**
  * This object is exposed directly to the consumers of this JavaScript module,
  * and provides the only entry point to get references to back-end objects.
  */
 this.Downloads = {
   /**
    * Work on downloads that were not started from a private browsing window.
    */