Readonly
initializedIndicates whether init() has been called.
Optional
aInstancePtr: objectA run time mechanism for interface discovery.
NS_OK if the interface is supported by the associated instance, NS_NOINTERFACE if it is not.
aInstancePtr must not be null.
[in] A requested interface IID
[out] A pointer to an interface pointer to receive the result.
Initializes the BITS interface. Unlike other functions here, this happens synchronously. init() should only be called only once.
The name of the BITS job. This is used both to set the name during job creation and to verify that a job is ours.
The directory that downloads will be saved to. Providing a safe directory here ensures that the download path cannot be manipulated to save files to a malicious location. Downloads are guaranteed to be saved to this directory or a subdirectory.
The amount of time to wait between download monitor notifications. This should be larger than the largest monitorIntervalMs that will be passed to startDownload(), monitorDownload(), or changeMonitorInterval(). This value may not be 0.
Similar to startDownload, but connects to a BITS transfer that has already been started.
The GUID of the download to monitor.
The number of milliseconds between download status notifications.
An observer to be notified of various events. OnStartRequest is called once the BITS job has been created. OnStopRequest is called when the file transfer has completed or when an error occurs. If this object implements nsIProgressEventSink, then its OnProgress method will be called as data is transferred. IMPORTANT NOTE: When OnStopRequest is called, the download has completed, but nsIBitsRequest::complete() still needs to be called to save the file to the filesystem.
User defined object forwarded to the observer's onProgress method. This parameter, unlike others for this interface, can be passed a null pointer.
The callback used to relay the response from BITS.
Downloads the specified URL to the specified location within the savePathPrefix passed to init().
The URL to be downloaded.
The location to download to. The path given should be a path relative to the savePathPrefix passed to init(). If this attempts to escape the directory specified by savePathPrefix, this call will fail (ex: Don't pass "../filename").
Specifies what proxy to use when downloading. Valid values are listed below.
The number of seconds for the "no progress" timeout. After there has been no download progress for this long, BITS will not retry the job following a transient error, producing instead a permanent error.
The number of milliseconds between download status notifications.
An observer to be notified of various events. OnStartRequest is called once the BITS job has been created. OnStopRequest is called when the file transfer has completed or when an error occurs. If this object implements nsIProgressEventSink, then its OnProgress method will be called as data is transferred. IMPORTANT NOTE: When OnStopRequest is called, the download has completed, but nsIBitsRequest::complete() still needs to be called to save the file to the filesystem.
User defined object forwarded to the observer's onProgress method. This parameter, unlike others for this interface, can be passed a null pointer.
The callback used to relay the response from BITS.
Generated using TypeDoc
An interface for interacting with Windows Background Intelligent Transfer Service. This should only be used on Windows.
It would be preferable for the functions in this interface to return Promises, but this interface is implemented in Rust, which does not yet have support for Promises. There is a JS wrapper around this class that should be preferred over using this interface directly, located in Bits.sys.mjs.
Methods of this class that take a nsIBitsNewRequestCallback do not return or throw errors. All errors will be reported through the callback. The only things that should cause methods to directly throw errors are null arguments.