Interface nsIBitsType

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.

Hierarchy

Properties

initialized: boolean

Indicates whether init() has been called.

Methods

  • Increases the reference count for this interface. The associated instance will not be deleted unless the reference count is returned to zero.

    Returns

    The resulting reference count.

    Returns number

  • Parameters

    • aIID: object
    • Optional aInstancePtr: object

    Returns any

  • A run time mechanism for interface discovery.

    Returns

    NS_OK if the interface is supported by the associated instance, NS_NOINTERFACE if it is not.

    aInstancePtr must not be null.

    Parameters

    • aIID: object

      [in] A requested interface IID

    • aInstancePtr: object

      [out] A pointer to an interface pointer to receive the result.

    Returns void

  • Decreases the reference count for this interface. Generally, if the reference count returns to zero, the associated instance is deleted.

    Returns

    The resulting reference count.

    Returns number

  • Initializes the BITS interface. Unlike other functions here, this happens synchronously. init() should only be called only once.

    Parameters

    • jobName: string

      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.

    • savePathPrefix: string

      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.

    • monitorTimeoutMs: number

      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.

    Returns void

  • Similar to startDownload, but connects to a BITS transfer that has already been started.

    Parameters

    • id: string

      The GUID of the download to monitor.

    • monitorIntervalMs: number

      The number of milliseconds between download status notifications.

    • observer: nsIRequestObserver

      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.

    • context: nsISupports

      User defined object forwarded to the observer's onProgress method. This parameter, unlike others for this interface, can be passed a null pointer.

    • callback: nsIBitsNewRequestCallback

      The callback used to relay the response from BITS.

    Returns void

  • Downloads the specified URL to the specified location within the savePathPrefix passed to init().

    Parameters

    • downloadURL: string

      The URL to be downloaded.

    • saveRelativePath: string

      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").

    • proxy: nsProxyUsage

      Specifies what proxy to use when downloading. Valid values are listed below.

    • noProgressTimeoutSecs: number

      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.

    • monitorIntervalMs: number

      The number of milliseconds between download status notifications.

    • observer: nsIRequestObserver

      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.

    • context: nsISupports

      User defined object forwarded to the observer's onProgress method. This parameter, unlike others for this interface, can be passed a null pointer.

    • callback: nsIBitsNewRequestCallback

      The callback used to relay the response from BITS.

    Returns void

Generated using TypeDoc