author | Ava Katushka <ava8katushka@gmail.com> |
Thu, 27 May 2021 10:53:35 +0000 | |
changeset 580958 | ffd2f7c0f1a4cdb106725852038ffa4ec33025b2 |
parent 580957 | fa3a8fdd9db4a1087a87e27e82b2dddeb5132aca |
child 580959 | 032deb66224a0211cb83767fd08adb32e0bc6d7e |
push id | 143854 |
push user | gijskruitbosch@gmail.com |
push date | Thu, 27 May 2021 10:56:04 +0000 |
treeherder | autoland@032deb66224a [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | Gijs, mak |
bugs | 1706355 |
milestone | 90.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
|
--- a/browser/components/downloads/DownloadsCommon.jsm +++ b/browser/components/downloads/DownloadsCommon.jsm @@ -75,150 +75,22 @@ const kDownloadsStringsRequiringFormatti const kDownloadsStringsRequiringPluralForm = { otherDownloads3: true, }; const kMaxHistoryResultsForLimitedView = 42; const kPrefBranch = Services.prefs.getBranch("browser.download."); -const kFileExtensions = [ - "aac", - "adt", - "adts", - "accdb", - "accde", - "accdr", - "accdt", - "aif", - "aifc", - "aiff", - "apng", - "aspx", - "avi", - "avif", - "bat", - "bin", - "bmp", - "cab", - "cda", - "csv", - "dif", - "dll", - "doc", - "docm", - "docx", - "dot", - "dotx", - "eml", - "eps", - "exe", - "flac", - "flv", - "gif", - "htm", - "html", - "ico", - "ini", - "iso", - "jar", - "jfif", - "jpg", - "jpeg", - "json", - "m4a", - "mdb", - "mid", - "midi", - "mov", - "mp3", - "mp4", - "mpeg", - "mpg", - "msi", - "mui", - "oga", - "ogg", - "ogv", - "opus", - "pdf", - "pjpeg", - "pjp", - "png", - "pot", - "potm", - "potx", - "ppam", - "pps", - "ppsm", - "ppsx", - "ppt", - "pptm", - "pptx", - "psd", - "pst", - "pub", - "rar", - "rdf", - "rtf", - "shtml", - "sldm", - "sldx", - "svg", - "swf", - "sys", - "tif", - "tiff", - "tmp", - "txt", - "vob", - "vsd", - "vsdm", - "vsdx", - "vss", - "vssm", - "vst", - "vstm", - "vstx", - "wav", - "wbk", - "webm", - "webp", - "wks", - "wma", - "wmd", - "wmv", - "wmz", - "wms", - "wpd", - "wp5", - "xht", - "xhtml", - "xla", - "xlam", - "xll", - "xlm", - "xls", - "xlsm", - "xlsx", - "xlt", - "xltm", - "xltx", - "xml", - "zip", -]; - const kGenericContentTypes = [ "application/octet-stream", "binary/octet-stream", "application/unknown", ]; -const TELEMETRY_EVENT_CATEGORY = "downloads"; - var PrefObserver = { QueryInterface: ChromeUtils.generateQI([ "nsIObserver", "nsISupportsWeakReference", ]), getPref(name) { try { switch (typeof this.prefs[name]) { @@ -948,36 +820,16 @@ DownloadsDataCtor.prototype = { ? PrivateDownloadsIndicatorData : DownloadsIndicatorData; indicatorData.attention = DownloadsCommon.ATTENTION_NONE; }, // Integration with the asynchronous Downloads back-end onDownloadAdded(download) { - let extension = download.target.path.split(".").pop(); - - if (!kFileExtensions.includes(extension)) { - extension = "other"; - } - - try { - Services.telemetry.recordEvent( - TELEMETRY_EVENT_CATEGORY, - "added", - "fileExtension", - extension, - {} - ); - } catch (ex) { - Cu.reportError( - "DownloadsCommon: error recording telemetry event. " + ex.message - ); - } - // Download objects do not store the end time of downloads, as the Downloads // API does not need to persist this information for all platforms. Once a // download terminates on a Desktop browser, it becomes a history download, // for which the end time is stored differently, as a Places annotation. download.endTime = Date.now(); this.oldDownloadStates.set( download,
--- a/toolkit/components/downloads/DownloadList.jsm +++ b/toolkit/components/downloads/DownloadList.jsm @@ -9,16 +9,146 @@ "use strict"; var EXPORTED_SYMBOLS = [ "DownloadList", "DownloadCombinedList", "DownloadSummary", ]; +const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); + +const kFileExtensions = [ + "aac", + "adt", + "adts", + "accdb", + "accde", + "accdr", + "accdt", + "aif", + "aifc", + "aiff", + "apng", + "aspx", + "avi", + "avif", + "bat", + "bin", + "bmp", + "cab", + "cda", + "csv", + "dif", + "dll", + "doc", + "docm", + "docx", + "dot", + "dotx", + "eml", + "eps", + "exe", + "flac", + "flv", + "gif", + "htm", + "html", + "ico", + "ini", + "iso", + "jar", + "jfif", + "jpg", + "jpeg", + "json", + "m4a", + "mdb", + "mid", + "midi", + "mov", + "mp3", + "mp4", + "mpeg", + "mpg", + "msi", + "mui", + "oga", + "ogg", + "ogv", + "opus", + "pdf", + "pjpeg", + "pjp", + "png", + "pot", + "potm", + "potx", + "ppam", + "pps", + "ppsm", + "ppsx", + "ppt", + "pptm", + "pptx", + "psd", + "pst", + "pub", + "rar", + "rdf", + "rtf", + "shtml", + "sldm", + "sldx", + "svg", + "swf", + "sys", + "tif", + "tiff", + "tmp", + "txt", + "vob", + "vsd", + "vsdm", + "vsdx", + "vss", + "vssm", + "vst", + "vstm", + "vstx", + "wav", + "wbk", + "webm", + "webp", + "wks", + "wma", + "wmd", + "wmv", + "wmz", + "wms", + "wpd", + "wp5", + "xht", + "xhtml", + "xla", + "xlam", + "xll", + "xlm", + "xls", + "xlsm", + "xlsx", + "xlt", + "xltm", + "xltx", + "xml", + "zip", +]; + +const TELEMETRY_EVENT_CATEGORY = "downloads"; + /** * Represents a collection of Download objects that can be viewed and managed by * the user interface, and persisted across sessions. */ var DownloadList = function() { this._downloads = []; this._views = new Set(); }; @@ -289,16 +419,36 @@ DownloadCombinedList.prototype = { * @param aDownload * The Download object to add. * * @return {Promise} * @resolves When the download has been added. * @rejects JavaScript exception. */ add(aDownload) { + let extension = aDownload.target.path.split(".").pop(); + + if (!kFileExtensions.includes(extension)) { + extension = "other"; + } + + try { + Services.telemetry.recordEvent( + TELEMETRY_EVENT_CATEGORY, + "added", + "fileExtension", + extension, + {} + ); + } catch (ex) { + Cu.reportError( + "DownloadsCommon: error recording telemetry event. " + ex.message + ); + } + if (aDownload.source.isPrivate) { return this._privateList.add(aDownload); } return this._publicList.add(aDownload); }, /** * Removes a download from the list. If the download was already removed,
--- a/toolkit/components/telemetry/Events.yaml +++ b/toolkit/components/telemetry/Events.yaml @@ -422,20 +422,20 @@ blocklist: - "firefox" record_in_processes: ["main"] bug_numbers: [1662857] release_channel_collection: opt-out downloads: added: description: > - Sent when downloading a new file. Possible values are in contained in DownloadsCommon::kFileExtensions. + Sent when downloading a new file. Possible values are in contained in DownloadList::kFileExtensions. All other downloads not in the listare marked as other. objects: ["fileExtension"] - bug_numbers: [1627676] + bug_numbers: [1627676, 1706355] notification_emails: ["rtestard@mozilla.com", "emalysz@mozilla.com"] products: - "firefox" record_in_processes: ["main"] release_channel_collection: opt-out expiry_version: never form_autocomplete: