B2G/gecko/browser/base/content/browser.js
/**
   * Update status based on the number of active and paused downloads
   */
Update status based on the number of active and paused downloads
Update status based on the number of active and paused downloads
function DMP_updateStatus() {
    if (!this.inited())
      return;
    let numActive = gDownloadMgr.activeDownloadCount;
    if (numActive == 0) {
      this._panel.hidden = true;
      this._lastTime = Infinity;
      return;
    }
    let numPaused = 0;
    let maxTime = -Infinity;
    let dls = gDownloadMgr.activeDownloads;
    while (dls.hasMoreElements()) {
      let dl = dls.getNext();
      if (dl.state == gDownloadMgr.DOWNLOAD_DOWNLOADING) {
        if (dl.speed > 0 && dl.size > 0)
          maxTime = Math.max(maxTime, (dl.size - dl.amountTransferred) / dl.speed);
        else
          maxTime = -1;
      }
      else if (dl.state == gDownloadMgr.DOWNLOAD_PAUSED)
        numPaused++;
    }
    let timeLeft;
    [timeLeft, this._lastTime] =
      this.DownloadUtils.getTimeLeft(maxTime, this._lastTime);
    let numDls = numActive - numPaused;
    let status = this._activeStr;
    if (numDls == 0) {
      numDls = numPaused;
      status = this._pausedStr;
    }
    status = PluralForm.get(numDls, status);
    status = status.replace("#1", numDls);
    status = status.replace("#2", timeLeft);
    this._panel.label = status;
    this._panel.hidden = false;
  }
function DMP_updateStatus ( ) { if ( ! this . inited ( ) ) return ; let numActive = gDownloadMgr . activeDownloadCount ; if ( numActive == 0 ) { this . _panel . hidden = true ; this . _lastTime = Infinity ; return ; } let numPaused = 0 ; let maxTime = - Infinity ; let dls = gDownloadMgr . activeDownloads ; while ( dls . hasMoreElements ( ) ) { let dl = dls . getNext ( ) ; if ( dl . state == gDownloadMgr . DOWNLOAD_DOWNLOADING ) { if ( dl . speed > 0 && dl . size > 0 ) maxTime = Math . max ( maxTime , ( dl . size - dl . amountTransferred ) / dl . speed ) ; else maxTime = - 1 ; } else if ( dl . state == gDownloadMgr . DOWNLOAD_PAUSED ) numPaused ++ ; } let timeLeft ; [ timeLeft , this . _lastTime ] = this . DownloadUtils . getTimeLeft ( maxTime , this . _lastTime ) ; let numDls = numActive - numPaused ; let status = this . _activeStr ; if ( numDls == 0 ) { numDls = numPaused ; status = this . _pausedStr ; } status = PluralForm . get ( numDls , status ) ; status = status . replace ( "#1" , numDls ) ; status = status . replace ( "#2" , timeLeft ) ; this . _panel . label = status ; this . _panel . hidden = false ; }
Update status based on the number of active and paused downloads
Update status based on the number of active and paused downloads
// Hide the panel and reset the "last time" if there's no downloads // Find the download with the longest remaining time // Figure out if this download takes longer // Get the remaining time string and last sec for time estimation // Figure out how many downloads are currently downloading // If all downloads are paused, show the paused message instead // Get the correct plural form and insert the number of downloads and time // left message if necessary // Update the panel and show it