src/ydn/db/conn/indexed_db.js
function(db, opt_err) {

    if (df.hasFired()) {
      goog.log.warning(me.logger, 'database already set.');
    } else if (goog.isDef(opt_err)) {
      goog.log.warning(me.logger, opt_err ? opt_err.message : 'Error received.');
      me.idx_db_ = null;
      df.errback(opt_err);
    } else {
      goog.asserts.assertObject(db, 'db');
      me.idx_db_ = db;
      me.idx_db_.onabort = function(e) {
        goog.log.finest(me.logger, me + ': abort');
        var request = /** @type {IDBRequest} */ (e.target);
        me.onError(request.error);
      };
      me.idx_db_.onerror = function(e) {
        if (ydn.db.con.IndexedDb.DEBUG) {
          goog.global.console.log(e);
        }
        goog.log.finest(me.logger, me + ': error');
        var request = /** @type {IDBRequest} */ (e.target);
        me.onError(request.error);
      };

      /**
       * @this {null}
       * @param {IDBVersionChangeEvent} event event.
       */
      me.idx_db_.onversionchange = function(event) {
        // Handle version changes while a web app is open in another tab
        // https://developer.mozilla.org/en-US/docs/IndexedDB/Using_IndexedDB#
        // Version_changes_while_a_web_app_is_open_in_another_tab
        //
        if (ydn.db.con.IndexedDb.DEBUG) {
          goog.global.console.log([this, event]);
        }
        goog.log.finest(me.logger, me + ' closing connection for onversionchange to: ' +
            event.version);
        if (me.idx_db_) {
          me.idx_db_.onabort = null;
          me.idx_db_.onblocked = null;
          me.idx_db_.onerror = null;
          me.idx_db_.onversionchange = null;
          me.onVersionChange(event);
          if (!event.defaultPrevented) {
            me.idx_db_.close();
            me.idx_db_ = null;
            var e = new Error();
            e.name = event.type;
            me.onFail(e);
          }
        }
      };
      df.callback(parseFloat(old_version));
    }

  }
function(db, opt_err) {

    if (df.hasFired()) {
      goog.log.warning(me.logger, 'database already set.');
    } else if (goog.isDef(opt_err)) {
      goog.log.warning(me.logger, opt_err ? opt_err.message : 'Error received.');
      me.idx_db_ = null;
      df.errback(opt_err);
    } else {
      goog.asserts.assertObject(db, 'db');
      me.idx_db_ = db;
      me.idx_db_.onabort = function(e) {
        goog.log.finest(me.logger, me + ': abort');
        var request = /** @type {IDBRequest} */ (e.target);
        me.onError(request.error);
      };
      me.idx_db_.onerror = function(e) {
        if (ydn.db.con.IndexedDb.DEBUG) {
          goog.global.console.log(e);
        }
        goog.log.finest(me.logger, me + ': error');
        var request = /** @type {IDBRequest} */ (e.target);
        me.onError(request.error);
      };

      /**
       * @this {null}
       * @param {IDBVersionChangeEvent} event event.
       */
      me.idx_db_.onversionchange = function(event) {
        // Handle version changes while a web app is open in another tab
        // https://developer.mozilla.org/en-US/docs/IndexedDB/Using_IndexedDB#
        // Version_changes_while_a_web_app_is_open_in_another_tab
        //
        if (ydn.db.con.IndexedDb.DEBUG) {
          goog.global.console.log([this, event]);
        }
        goog.log.finest(me.logger, me + ' closing connection for onversionchange to: ' +
            event.version);
        if (me.idx_db_) {
          me.idx_db_.onabort = null;
          me.idx_db_.onblocked = null;
          me.idx_db_.onerror = null;
          me.idx_db_.onversionchange = null;
          me.onVersionChange(event);
          if (!event.defaultPrevented) {
            me.idx_db_.close();
            me.idx_db_ = null;
            var e = new Error();
            e.name = event.type;
            me.onFail(e);
          }
        }
      };
      df.callback(parseFloat(old_version));
    }

  }
function ( db , opt_err ) { if ( df . hasFired ( ) ) { goog . log . warning ( me . logger , 'database already set.' ) ; } else if ( goog . isDef ( opt_err ) ) { goog . log . warning ( me . logger , opt_err ? opt_err . message : 'Error received.' ) ; me . idx_db_ = null ; df . errback ( opt_err ) ; } else { goog . asserts . assertObject ( db , 'db' ) ; me . idx_db_ = db ; me . idx_db_ . onabort = function ( e ) { goog . log . finest ( me . logger , me + ': abort' ) ; var request = /** @type {IDBRequest} */ ( e . target ) ; me . onError ( request . error ) ; } ; me . idx_db_ . onerror = function ( e ) { if ( ydn . db . con . IndexedDb . DEBUG ) { goog . global . console . log ( e ) ; } goog . log . finest ( me . logger , me + ': error' ) ; var request = /** @type {IDBRequest} */ ( e . target ) ; me . onError ( request . error ) ; } ; /**
       * @this {null}
       * @param {IDBVersionChangeEvent} event event.
       */ me . idx_db_ . onversionchange = function ( event ) { // Handle version changes while a web app is open in another tab // https://developer.mozilla.org/en-US/docs/IndexedDB/Using_IndexedDB# // Version_changes_while_a_web_app_is_open_in_another_tab // if ( ydn . db . con . IndexedDb . DEBUG ) { goog . global . console . log ( [ this , event ] ) ; } goog . log . finest ( me . logger , me + ' closing connection for onversionchange to: ' + event . version ) ; if ( me . idx_db_ ) { me . idx_db_ . onabort = null ; me . idx_db_ . onblocked = null ; me . idx_db_ . onerror = null ; me . idx_db_ . onversionchange = null ; me . onVersionChange ( event ) ; if ( ! event . defaultPrevented ) { me . idx_db_ . close ( ) ; me . idx_db_ = null ; var e = new Error ( ) ; e . name = event . type ; me . onFail ( e ) ; } } } ; df . callback ( parseFloat ( old_version ) ) ; } }
This is final result of connection. It is either fail or connected
and only once.
@param {IDBDatabase} db database instance.
@param {Error=} opt_err error.
This is final result of connection . It is either fail or connected and only once .