B2G/gecko/browser/modules/NewTabUtils.jsm
/**
   * Populates the cache with fresh links from the current provider.
   * @param aCallback The callback to call when finished (optional).
   * @param aForce When true, populates the cache even when it's already filled.
   */
Populates the cache with fresh links from the current provider.
@param aCallback The callback to call when finished (optional).
@param aForce When true, populates the cache even when it's already filled.
Populates the cache with fresh links from the current provider . @param aCallback The callback to call when finished ( optional ) . @param aForce When true populates the cache even when it ' s already filled .
function Links_populateCache(aCallback, aForce) {
    let callbacks = this._populateCallbacks;
    callbacks.push(aCallback);
    if (callbacks.length > 1)
      return;
    function executeCallbacks() {
      while (callbacks.length) {
        let callback = callbacks.shift();
        if (callback) {
          try {
            callback();
          } catch (e) {
          }
        }
      }
    }
    if (this._links && !aForce) {
      executeCallbacks();
    } else {
      this._provider.getLinks(function (aLinks) {
        this._links = aLinks;
        executeCallbacks();
      }.bind(this));
      this._addObserver();
    }
  }
function Links_populateCache ( aCallback , aForce ) { let callbacks = this . _populateCallbacks ; callbacks . push ( aCallback ) ; if ( callbacks . length > 1 ) return ; function executeCallbacks ( ) { while ( callbacks . length ) { let callback = callbacks . shift ( ) ; if ( callback ) { try { callback ( ) ; } catch ( e ) { } } } } if ( this . _links && ! aForce ) { executeCallbacks ( ) ; } else { this . _provider . getLinks ( function ( aLinks ) { this . _links = aLinks ; executeCallbacks ( ) ; } . bind ( this ) ) ; this . _addObserver ( ) ; } }
Populates the cache with fresh links from the current provider.
Populates the cache with fresh links from the current provider .
// Enqueue the current callback. // There was a callback waiting already, thus the cache has not yet been // populated. // We want to proceed even if a callback fails.