B2G/gecko/services/aitc/modules/storage.js
/**
   * Remove the object at the head of the queue, and data is saved to disk.
   */
Remove the object at the head of the queue, and data is saved to disk.
Remove the object at the head of the queue and data is saved to disk .
function dequeue(cb) {
    this._log.info("Removing head of queue");
    if (!cb) {
      throw new Error("dequeue called without callback");
    }
    if (!this._queue.length) {
      throw new Error("Queue is empty");
    }
    let self = this;
    let obj = this._queue.shift();
    try {
      this._putFile(this._queue, function _dequeuePutFile(err) {
        if (!err) {
          cb(null, true);
          return;
        }
        self._queue.unshift(obj);
        cb(err, false);
      });
    } catch (e) {
      self._queue.unshift(obj);
      cb(e, false);
    }
  }
function dequeue ( cb ) { this . _log . info ( "Removing head of queue" ) ; if ( ! cb ) { throw new Error ( "dequeue called without callback" ) ; } if ( ! this . _queue . length ) { throw new Error ( "Queue is empty" ) ; } let self = this ; let obj = this . _queue . shift ( ) ; try { this . _putFile ( this . _queue , function _dequeuePutFile ( err ) { if ( ! err ) { cb ( null , true ) ; return ; } self . _queue . unshift ( obj ) ; cb ( err , false ) ; } ) ; } catch ( e ) { self . _queue . unshift ( obj ) ; cb ( e , false ) ; } }
Remove the object at the head of the queue, and data is saved to disk.
Remove the object at the head of the queue and data is saved to disk .
// Successful write. // Unsuccessful write, put back in queue.