mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-23 02:05:42 +00:00
Bug 941027 - Store metadata about completed downloads in the download history. r=mak
This commit is contained in:
parent
918ac2395c
commit
b4834145e0
@ -59,6 +59,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "DownloadUtils",
|
||||
"resource://gre/modules/DownloadUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "OS",
|
||||
"resource://gre/modules/osfile.jsm")
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
|
||||
"resource://gre/modules/PlacesUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
|
||||
"resource://gre/modules/PrivateBrowsingUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "RecentWindow",
|
||||
@ -668,6 +670,27 @@ DownloadsDataCtor.prototype = {
|
||||
Cu.reportError(ex);
|
||||
}
|
||||
}
|
||||
|
||||
// This state transition code should actually be located in a Downloads
|
||||
// API module (bug 941009). Moreover, the fact that state is stored as
|
||||
// annotations should be ideally hidden behind methods of
|
||||
// nsIDownloadHistory (bug 830415).
|
||||
if (!this._isPrivate && !aDataItem.inProgress) {
|
||||
try {
|
||||
let downloadMetaData = { state: aDataItem.state,
|
||||
endTime: aDataItem.endTime };
|
||||
if (aDataItem.done) {
|
||||
downloadMetaData.fileSize = aDataItem.maxBytes;
|
||||
}
|
||||
|
||||
PlacesUtils.annotations.setPageAnnotation(
|
||||
NetUtil.newURI(aDataItem.uri), "downloads/metaData",
|
||||
JSON.stringify(downloadMetaData), 0,
|
||||
PlacesUtils.annotations.EXPIRE_WITH_HISTORY);
|
||||
} catch (ex) {
|
||||
Cu.reportError(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!aDataItem.newDownloadNotified) {
|
||||
|
Loading…
Reference in New Issue
Block a user