Bug 790438 - Assign names to anonymous functions in Download manager module aboutDownloads.js. r=margaret
authorAiishwarya Sivaraman <aiishwarya.sivaraman@gmail.com>
Wed, 26 Sep 2012 18:56:49 -0400
changeset 108319 d73da596f3fd7093e72946faed3da882bb1ade01
parent 108318 e4be135eff48ba0d22309e8926b91ba290e6c423
child 108320 d0d8848ffd07499b5d250d9cd4bac5f9fbf13303
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewersmargaret
bugs790438
milestone18.0a1
Bug 790438 - Assign names to anonymous functions in Download manager module aboutDownloads.js. r=margaret
mobile/android/chrome/content/aboutDownloads.js
--- a/mobile/android/chrome/content/aboutDownloads.js
+++ b/mobile/android/chrome/content/aboutDownloads.js
@@ -30,17 +30,17 @@ XPCOMUtils.defineLazyGetter(window, "gCh
     .getInterface(Ci.nsIWebNavigation)
     .QueryInterface(Ci.nsIDocShellTreeItem)
     .rootTreeItem
     .QueryInterface(Ci.nsIInterfaceRequestor)
     .getInterface(Ci.nsIDOMWindow)
     .QueryInterface(Ci.nsIDOMChromeWindow));
 
 let Downloads = {
-  init: function () {
+  init: function dl_init() {
     this._list = document.getElementById("downloads-list");
     this._list.addEventListener("click", function (event) {
       let target = event.target;
       while (target && target.nodeName != "li") {
         target = target.parentNode;
       }
 
       Downloads.openDownload(target);
@@ -108,17 +108,17 @@ let Downloads = {
                                                                              "li[state='" + this._dlmgr.DOWNLOAD_QUEUED + "']," +
                                                                              "li[state='" + this._dlmgr.DOWNLOAD_PAUSED + "']"),
       function (aTarget) {
         Downloads.cancelDownload(aTarget);
       }
     );
   },
 
-  uninit: function () {
+  uninit: function dl_uninit() {
     let contextmenus = gChromeWin.NativeWindow.contextmenus;
     contextmenus.remove(this.openMenuItem);
     contextmenus.remove(this.removeMenuItem);
     contextmenus.remove(this.pauseMenuItem);
     contextmenus.remove(this.resumeMenuItem);
     contextmenus.remove(this.retryMenuItem);
     contextmenus.remove(this.cancelMenuItem);
 
@@ -126,17 +126,17 @@ let Downloads = {
     Services.obs.removeObserver(this, "dl-failed");
     Services.obs.removeObserver(this, "dl-scanning");
     Services.obs.removeObserver(this, "dl-done");
     Services.obs.removeObserver(this, "dl-blocked");
     Services.obs.removeObserver(this, "dl-dirty");
     Services.obs.removeObserver(this, "dl-cancel");
   },
 
-  observe: function (aSubject, aTopic, aData) {
+  observe: function dl_observe(aSubject, aTopic, aData) {
     let download = aSubject.QueryInterface(Ci.nsIDownload);
     switch (aTopic) {
       case "dl-blocked":
       case "dl-dirty":
       case "dl-cancel":
       case "dl-done":
       case "dl-failed":
         // For all "completed" states, move them after active downloads
@@ -149,65 +149,65 @@ let Downloads = {
         if (item)
           this._updateDownloadRow(item);
         else
           this._insertDownloadRow(download);
         break;
     }
   },
 
-  _moveDownloadAfterActive: function (aItem) {
+  _moveDownloadAfterActive: function dl_moveDownloadAfterActive(aItem) {
     // Move downloads that just reached a "completed" state below any active
     try {
       // Iterate down until we find a non-active download
       let next = aItem.nextSibling;
       while (next && this._inProgress(next.getAttribute("state")))
         next = next.nextSibling;
       // Move the item
       this._list.insertBefore(aItem, next);
     } catch (ex) {
       console.log("ERROR: _moveDownloadAfterActive() : " + ex);
     }
   },
   
-  _inProgress: function (aState) {
+  _inProgress: function dl_inProgress(aState) {
     return [
       this._dlmgr.DOWNLOAD_NOTSTARTED,
       this._dlmgr.DOWNLOAD_QUEUED,
       this._dlmgr.DOWNLOAD_DOWNLOADING,
       this._dlmgr.DOWNLOAD_PAUSED,
       this._dlmgr.DOWNLOAD_SCANNING,
     ].indexOf(parseInt(aState)) != -1;
   },
 
-  _insertDownloadRow: function (aDownload) {
+  _insertDownloadRow: function dl_insertDownloadRow(aDownload) {
     let updatedState = this._getState(aDownload.state);
     let item = this._createItem(downloadTemplate, {
       id: aDownload.id,
       target: aDownload.displayName,
       icon: "moz-icon://" + aDownload.displayName + "?size=64",
       date: DownloadUtils.getReadableDates(new Date())[0],
       domain: DownloadUtils.getURIHost(aDownload.source.spec)[0],
       size: this._getDownloadSize(aDownload.size),
       displayState: this._getStateString(updatedState),
       state: updatedState
     });
     this._list.insertAdjacentHTML("afterbegin", item);
   },
 
-  _getDownloadSize: function (aSize) {
+  _getDownloadSize: function dl_getDownloadSize(aSize) {
     let displaySize = DownloadUtils.convertByteUnits(aSize);
     if (displaySize[0] > 0) // [0] is size, [1] is units
       return displaySize.join("");
     else
       return gStrings.GetStringFromName("downloadState.unknownSize");
   },
   
   // Not all states are displayed as-is on mobile, some are translated to a generic state
-  _getState: function (aState) {
+  _getState: function dl_getState(aState) {
     let str;
     switch (aState) {
       // Downloading and Scanning states show up as "Downloading"
       case this._dlmgr.DOWNLOAD_DOWNLOADING:
       case this._dlmgr.DOWNLOAD_SCANNING:
         str = this._dlmgr.DOWNLOAD_DOWNLOADING;
         break;
         
@@ -225,17 +225,17 @@ let Downloads = {
          
       default:
         str = aState;
     }
     return str;
   },
   
   // Note: This doesn't cover all states as some of the states are translated in _getState()
-  _getStateString: function (aState) {
+  _getStateString: function dl_getStateString(aState) {
     let str;
     switch (aState) {
       case this._dlmgr.DOWNLOAD_DOWNLOADING:
         str = "downloadState.downloading";
         break;
       case this._dlmgr.DOWNLOAD_CANCELED:
         str = "downloadState.canceled";
         break;
@@ -253,17 +253,17 @@ let Downloads = {
         break;
         
       default:
         return "";
     }
     return gStrings.GetStringFromName(str);
   },
 
-  _updateItem: function (aItem, aValues) {
+  _updateItem: function dl_updateItem(aItem, aValues) {
     for (let i in aValues) {
       aItem.querySelector("." + i).textContent = aValues[i];
     }
   },
 
   _initStatement: function dv__initStatement() {
     if (this._stmt)
       this._stmt.finalize();
@@ -333,17 +333,17 @@ let Downloads = {
     } else {
       // Use a shorter delay for earlier downloads to display them faster
       let delay = Math.min(this._list.itemCount * 10, 300);
       let self = this;
       this._timeoutID = setTimeout(function () { self._stepDownloads(5); }, delay);
     }
   },
 
-  getDownloads: function () {
+  getDownloads: function dl_getDownloads() {
     this._dlmgr = Cc["@mozilla.org/download-manager;1"].getService(Ci.nsIDownloadManager);
 
     this._initStatement();
 
     clearTimeout(this._timeoutID);
 
     this._stmt.reset();
     this._stmt.bindInt32Parameter(0, Ci.nsIDownloadManager.DOWNLOAD_NOTSTARTED);
@@ -354,48 +354,48 @@ let Downloads = {
 
     // Take a quick break before we actually start building the list
     let self = this;
     this._timeoutID = setTimeout(function () {
       self._stepDownloads(1);
     }, 0);
   },
 
-  _getElementForDownload: function (aKey) {
+  _getElementForDownload: function dl_getElementForDownload(aKey) {
     return this._list.querySelector("li[downloadID='" + aKey + "']");
   },
 
-  _getDownloadForElement: function (aElement) {
+  _getDownloadForElement: function dl_getDownloadForElement(aElement) {
     let id = parseInt(aElement.getAttribute("downloadID"));
     return this._dlmgr.getDownload(id);
   },
 
-  _removeItem: function dv__removeItem(aItem) {
+  _removeItem: function dl_removeItem(aItem) {
     // Make sure we have an item to remove
     if (!aItem)
       return;
   
     let index = this._list.selectedIndex;
     this._list.removeChild(aItem);
     this._list.selectedIndex = Math.min(index, this._list.itemCount - 1);
   },
   
-  openDownload: function (aItem) {
+  openDownload: function dl_openDownload(aItem) {
     let f = null;
     try {
       let download = this._getDownloadForElement(aItem);
       f = download.targetFile;
     } catch(ex) { }
 
     try {
       if (f) f.launch();
     } catch (ex) { }
   },
 
-  removeDownload: function (aItem) {
+  removeDownload: function dl_removeDownload(aItem) {
     let f = null;
     try {
       let download = this._getDownloadForElement(aItem);
       f = download.targetFile;
     } catch(ex) {
       // even if there is no file, pretend that there is so that we can remove
       // it from the list
       f = { leafName: "" };
@@ -405,63 +405,63 @@ let Downloads = {
 
     this._list.removeChild(aItem);
 
     try {
       if (f) f.remove(false);
     } catch(ex) { }
   },
 
-  pauseDownload: function (aItem) {
+  pauseDownload: function dl_pauseDownload(aItem) {
     try {
       let download = this._getDownloadForElement(aItem);
       this._dlmgr.pauseDownload(aItem.getAttribute("downloadID"));
       this._updateDownloadRow(aItem);
     } catch (ex) {
       console.log("Error: pauseDownload() " + ex);  
     }
 
   },
 
-  resumeDownload: function (aItem) {
+  resumeDownload: function dl_resumeDownload(aItem) {
     try {
       let download = this._getDownloadForElement(aItem);
       this._dlmgr.resumeDownload(aItem.getAttribute("downloadID"));
       this._updateDownloadRow(aItem);
     } catch (ex) {
       console.log("Error: resumeDownload() " + ex);  
     }
   },
 
-  retryDownload: function (aItem) {
+  retryDownload: function dl_retryDownload(aItem) {
     try {
       let download = this._getDownloadForElement(aItem);
       this._removeItem(aItem);
       this._dlmgr.retryDownload(aItem.getAttribute("downloadID"));
     } catch (ex) {
       console.log("Error: retryDownload() " + ex);  
     }
   },
 
-  cancelDownload: function (aItem) {
+  cancelDownload: function dl_cancelDownload(aItem) {
     try {
       this._dlmgr.cancelDownload(aItem.getAttribute("downloadID"));
       let download = this._getDownloadForElement(aItem);
       let f = download.targetFile;
 
       if (f.exists())
         f.remove(false);
       
       this._updateDownloadRow(aItem);
     } catch (ex) {
       console.log("Error: cancelDownload() " + ex);  
     }
   },
   
-  _updateDownloadRow: function (aItem){
+  _updateDownloadRow: function dl_updateDownloadRow(aItem){
     try {
       let download = this._getDownloadForElement(aItem);
       let updatedState = this._getState(download.state);
       aItem.setAttribute("state", updatedState);
       this._updateItem(aItem, {
         size: this._getDownloadSize(download.size),
         displayState: this._getStateString(updatedState),
         date: DownloadUtils.getReadableDates(new Date())[0]