B2G/gecko/services/aitc/modules/manager.js
/**
   * Checks if the current token we hold is valid. If not, we obtain a new one
   * and execute the provided func. If a token could not be obtained, func will
   * not be called and an error will be logged.
   */
Checks if the current token we hold is valid. If not, we obtain a new one
and execute the provided func. If a token could not be obtained, func will
not be called and an error will be logged.
Checks if the current token we hold is valid . If not we obtain a new one and execute the provided func . If a token could not be obtained func will not be called and an error will be logged .
function _validateToken(func) {
    let timeSinceLastToken = Date.now() - this._lastTokenTime;
    if (!this._invalidTokenFlag && timeSinceLastToken < this._tokenDuration) {
      this._log.info("Current token is valid");
      func();
      return;
    }
    this._log.info("Current token is invalid");
    let win;
    if (this._state == this.ACTIVE) {
      win = this._dashboardWindow;
    }
    let self = this;
    this._refreshToken(function(err, done) {
      if (!done) {
        self._log.warn("_checkServer could not refresh token, aborting");
        return;
      }
      func(err);
    }, win);
  }
function _validateToken ( func ) { let timeSinceLastToken = Date . now ( ) - this . _lastTokenTime ; if ( ! this . _invalidTokenFlag && timeSinceLastToken < this . _tokenDuration ) { this . _log . info ( "Current token is valid" ) ; func ( ) ; return ; } this . _log . info ( "Current token is invalid" ) ; let win ; if ( this . _state == this . ACTIVE ) { win = this . _dashboardWindow ; } let self = this ; this . _refreshToken ( function ( err , done ) { if ( ! done ) { self . _log . warn ( "_checkServer could not refresh token, aborting" ) ; return ; } func ( err ) ; } , win ) ; }
Checks if the current token we hold is valid.
Checks if the current token we hold is valid .