Now that the download manager back-end changes have landed and have stabilized, I figured that it’d be a good idea to get the word out. Basically, all of the RDF code has been pulled out, and we’ve switched over to using mozStorage as our back-end. The data is now stored in downloads.sqlite in your profile directory, and we do import the data from the existing file, downloads.rdf.
Doing this brought about changes to several interfaces (see Bug 380250). We no longer have the following methods and attributes for nsIDownloadManager because they were RDF related:
void startBatchUpdate()
void endBatchUpdate()
readonly attribute nsIRDFDataSource datasource
To replace the datasource
attribute, readonly attribute mozIStorageConnection DBConnection
was added. This gives you access to the mozIStorageConnection that the download manager uses.
Several methods were modified from using a persistent descriptor to using a download id. The persistent descriptor was overly complex, so we decided to can it in favor of a simple unsigned 32-bit integer that is automatically assigned by the database.
nsIDownload getDownload(in unsigned long aID)
void cancelDownload(in unsigned long aID)
void removeDownload(in unsigned long aID)
void pauseDownload(in unsigned long aID)
void resumeDownload(in unsigned long aID)
void open(in nsIDOMWindow aParent, in unsigned long aID)
Lastly, activeDownloads no longer returns an nsISupportsArray
. Now it returns an nsISimpleEnumerator.
There were also a few changes to nsIDownload in this bug as well. The display name was changed from a wstring
to an AString
. We also added two new attributes to the interface:
readonly attribute unsigned long id
readonly attribute short state
One other interface was changed with this bug as well. nsIDownloadProgressListener had one more method added to it that is called whenever a download's state is changed:
void onDownloadStateChange(in short aState, in nsIDownload aDownload)
One other bug modified the API of the download manager, and in a way that people have been asking for for some time. Bug 289540 now allows someone to register more than one nsIDownloadProgressListener. Some extensions out there had to do some strange things to work around this, so I think they will be extremely happy to see this fixed. This caused the listener
attribute to be removed, and two methods to be added:
void addListener(in nsIDownloadProgressListener aListener)
void removeListener(in nsIDownloadProgressListener aListener)
All of the idl files got comments revamped to better explain what is going on with methods and attributes. If something still seems unclear, talk to me and I'll get it fixed ASAP.
These API changes should be much more useful. If you have any questions or concerns about any of these changes (or think we are still lacking something with the API), please get in touch with me!