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

--HG--
extra : source : 1ddfd4b28b7af650705fb45a02e70bf68b36ecd9
This commit is contained in:
Paolo Amadini 2017-07-24 12:16:01 +01:00
Родитель ae74fe5d2a
Коммит c58336f839
7 изменённых файлов: 25 добавлений и 170 удалений

Просмотреть файл

@ -1,40 +1,10 @@
/* -*- 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";
@ -50,12 +20,7 @@ this.EXPORTED_SYMBOLS = [
"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");
@ -138,8 +103,6 @@ function deserializeUnknownProperties(aObject, aSerializable, aFilterFn) {
*/
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
@ -1225,8 +1188,6 @@ Download.fromSerializable = function(aSerializable) {
return download;
};
// DownloadSource
/**
* Represents the source of a download, for example a document or an URI.
*/
@ -1350,8 +1311,6 @@ this.DownloadSource.fromSerializable = function(aSerializable) {
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.
@ -1477,8 +1436,6 @@ this.DownloadTarget.fromSerializable = function(aSerializable) {
return target;
};
// DownloadError
/**
* Provides detailed information about a download failure.
*
@ -1669,8 +1626,6 @@ this.DownloadError.fromSerializable = function(aSerializable) {
return e;
};
// DownloadSaver
/**
* Template for an object that actually transfers the data for the download.
*/
@ -1819,8 +1774,6 @@ this.DownloadSaver.fromSerializable = function(aSerializable) {
return saver;
};
// DownloadCopySaver
/**
* Saver object that simply copies the entire source file to the target.
*/
@ -2296,8 +2249,6 @@ this.DownloadCopySaver.fromSerializable = function(aSerializable) {
return saver;
};
// DownloadLegacySaver
/**
* Saver object that integrates with the legacy nsITransfer interface.
*
@ -2664,8 +2615,6 @@ 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

Просмотреть файл

@ -1,5 +1,3 @@
/* -*- 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/. */
@ -15,13 +13,7 @@ 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");
@ -134,9 +126,6 @@ const kVerdictMap = {
Downloads.Error.BLOCK_VERDICT_MALWARE,
};
////////////////////////////////////////////////////////////////////////////////
//// DownloadIntegration
/**
* Provides functions to integrate with the host application, handling for
* example the global prompts on shutdown.
@ -799,9 +788,6 @@ this.DownloadIntegration = {
},
};
////////////////////////////////////////////////////////////////////////////////
//// DownloadObserver
this.DownloadObserver = {
/**
* Flag to determine if the observers have been added previously.
@ -914,9 +900,7 @@ this.DownloadObserver = {
}
},
////////////////////////////////////////////////////////////////////////////
//// nsIObserver
// nsIObserver
observe: function DO_observe(aSubject, aTopic, aData) {
let downloadsCount;
let p = DownloadUIHelper.getPrompter();
@ -997,15 +981,9 @@ this.DownloadObserver = {
}
},
////////////////////////////////////////////////////////////////////////////
//// 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.
@ -1028,19 +1006,15 @@ this.DownloadHistoryObserver.prototype = {
*/
_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();
},
@ -1053,9 +1027,6 @@ this.DownloadHistoryObserver.prototype = {
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
@ -1131,9 +1102,7 @@ this.DownloadAutoSaveView.prototype = {
this._writer.arm();
},
//////////////////////////////////////////////////////////////////////////////
//// DownloadList view
// DownloadList callback
onDownloadAdded: function (aDownload)
{
if (gCombinedDownloadIntegration.shouldPersistDownload(aDownload)) {
@ -1144,6 +1113,7 @@ this.DownloadAutoSaveView.prototype = {
}
},
// DownloadList callback
onDownloadChanged: function (aDownload)
{
if (!gCombinedDownloadIntegration.shouldPersistDownload(aDownload)) {
@ -1161,6 +1131,7 @@ this.DownloadAutoSaveView.prototype = {
}
},
// DownloadList callback
onDownloadRemoved: function (aDownload)
{
if (this._downloadsMap.has(aDownload)) {

Просмотреть файл

@ -1,5 +1,3 @@
/* -*- 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/. */
@ -16,12 +14,7 @@
"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");
@ -30,8 +23,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "Downloads",
XPCOMUtils.defineLazyModuleGetter(this, "PromiseUtils",
"resource://gre/modules/PromiseUtils.jsm");
// DownloadLegacyTransfer
/**
* nsITransfer implementation that provides a bridge to a Download object.
*
@ -67,14 +58,12 @@ function DownloadLegacyTransfer() {
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)) {
@ -153,6 +142,7 @@ DownloadLegacyTransfer.prototype = {
}
},
// nsIWebProgressListener
onProgressChange: function DLT_onProgressChange(aWebProgress, aRequest,
aCurSelfProgress,
aMaxSelfProgress,
@ -165,6 +155,7 @@ DownloadLegacyTransfer.prototype = {
onLocationChange() { },
// nsIWebProgressListener
onStatusChange: function DLT_onStatusChange(aWebProgress, aRequest, aStatus,
aMessage) {
// The status change may optionally be received in addition to the state
@ -183,7 +174,6 @@ DownloadLegacyTransfer.prototype = {
onSecurityChange() { },
// nsIWebProgressListener2
onProgressChange64: function DLT_onProgressChange64(aWebProgress, aRequest,
aCurSelfProgress,
aMaxSelfProgress,
@ -195,6 +185,7 @@ DownloadLegacyTransfer.prototype = {
}).catch(Cu.reportError);
},
// nsIWebProgressListener2
onRefreshAttempted: function DLT_onRefreshAttempted(aWebProgress, aRefreshURI,
aMillis, aSameURI) {
// Indicate that refreshes and redirects are allowed by default. However,
@ -203,7 +194,6 @@ DownloadLegacyTransfer.prototype = {
},
// nsITransfer
init: function DLT_init(aSource, aTarget, aDisplayName, aMIMEInfo, aStartTime,
aTempFile, aCancelable, aIsPrivate) {
this._cancelable = aCancelable;
@ -262,8 +252,6 @@ DownloadLegacyTransfer.prototype = {
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.
@ -294,6 +282,4 @@ DownloadLegacyTransfer.prototype = {
_signatureInfo: null,
};
// Module
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([DownloadLegacyTransfer]);

Просмотреть файл

@ -1,21 +1,9 @@
/* -*- 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";
@ -26,18 +14,10 @@ this.EXPORTED_SYMBOLS = [
"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.
@ -254,8 +234,6 @@ this.DownloadList.prototype = {
},
};
// DownloadCombinedList
/**
* Provides a unified, unordered list combining public and private downloads.
*
@ -335,17 +313,18 @@ this.DownloadCombinedList.prototype = {
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) {
@ -355,8 +334,6 @@ this.DownloadCombinedList.prototype = {
},
};
// DownloadSummary
/**
* Provides an aggregated view on the contents of a DownloadList.
*/
@ -524,8 +501,7 @@ this.DownloadSummary.prototype = {
}
},
// DownloadList view
// DownloadList callback
onDownloadAdded(aDownload) {
this._downloads.push(aDownload);
if (this._list) {
@ -533,10 +509,12 @@ this.DownloadSummary.prototype = {
}
},
// DownloadList callback
onDownloadChanged(aDownload) {
this._onListChanged();
},
// DownloadList callback
onDownloadRemoved(aDownload) {
let index = this._downloads.indexOf(aDownload);
if (index != -1) {

Просмотреть файл

@ -1,5 +1,3 @@
/* -*- 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/. */
@ -34,12 +32,7 @@ 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");
@ -56,8 +49,6 @@ 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.

Просмотреть файл

@ -1,5 +1,3 @@
/* -*- 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/. */
@ -14,12 +12,7 @@ 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");
@ -41,8 +34,6 @@ const kStringsRequiringFormatting = {
leavePrivateBrowsingWindowsCancelDownloadsAlertMsgMultiple2: true
};
// DownloadUIHelper
/**
* Provides functions to handle status and messages in the user interface.
*/
@ -92,8 +83,6 @@ XPCOMUtils.defineLazyGetter(DownloadUIHelper, "strings", function() {
return strings;
});
// DownloadPrompter
/**
* Allows displaying prompts related to downloads.
*

Просмотреть файл

@ -1,5 +1,3 @@
/* -*- 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/. */
@ -14,12 +12,7 @@ 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");
@ -38,8 +31,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "DownloadUIHelper",
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.