B2G/gaia/apps/email/js/ext/mailapi/worker-bootstrap.js
/**
   * Add a new message to the database, generating slice notifications.
   */
Add a new message to the database, generating slice notifications.
Add a new message to the database generating slice notifications .
function ifs_addMessageHeader(header, callback) {
    if (this._pendingLoads.length) {
      this._deferredCalls.push(this.addMessageHeader.bind(
                                 this, header, callback));
      return;
    }
    this._LOG.addMessageHeader(header.date, header.id, header.srvid);
    if (this._curSyncSlice && !this._curSyncSlice.ignoreHeaders)
      this._curSyncSlice.onHeaderAdded(header, true, true);
    if (this._slices.length > (this._curSyncSlice ? 1 : 0)) {
      var date = header.date, uid = header.id;
      for (var iSlice = 0; iSlice < this._slices.length; iSlice++) {
        var slice = this._slices[iSlice];
        if (slice === this._curSyncSlice)
          continue;
        if (slice.startTS !== null) {
          if (BEFORE(date, slice.startTS)) {
            if (slice.headers.length >= slice.desiredHeaders)
              continue;
          }
          else if (SINCE(date, slice.endTS)) {
            if(!(this._headerBlockInfos.length &&
                 slice.endTS === this._headerBlockInfos[0].endTS &&
                 slice.endUID === this._headerBlockInfos[0].endUID))
              continue;
          }
          else if ((date === slice.startTS &&
                    uid < slice.startUID) ||
                   (date === slice.endTS &&
                    uid > slice.endUID)) {
            continue;
          }
        }
        else {
          slice.desiredHeaders++;
        }
        if (this._onAddingHeader !== null) {
          this._onAddingHeader(header);
        }
        slice.onHeaderAdded(header, false, true);
      }
    }
    this._insertIntoBlockUsingDateAndUID(
      'header', header.date, header.id, header.srvid,
      $sync.HEADER_EST_SIZE_IN_BYTES, header, callback);
  }
function ifs_addMessageHeader ( header , callback ) { if ( this . _pendingLoads . length ) { this . _deferredCalls . push ( this . addMessageHeader . bind ( this , header , callback ) ) ; return ; } this . _LOG . addMessageHeader ( header . date , header . id , header . srvid ) ; if ( this . _curSyncSlice && ! this . _curSyncSlice . ignoreHeaders ) this . _curSyncSlice . onHeaderAdded ( header , true , true ) ; if ( this . _slices . length > ( this . _curSyncSlice ? 1 : 0 ) ) { var date = header . date , uid = header . id ; for ( var iSlice = 0 ; iSlice < this . _slices . length ; iSlice ++ ) { var slice = this . _slices [ iSlice ] ; if ( slice === this . _curSyncSlice ) continue ; if ( slice . startTS !== null ) { if ( BEFORE ( date , slice . startTS ) ) { if ( slice . headers . length >= slice . desiredHeaders ) continue ; } else if ( SINCE ( date , slice . endTS ) ) { if ( ! ( this . _headerBlockInfos . length && slice . endTS === this . _headerBlockInfos [ 0 ] . endTS && slice . endUID === this . _headerBlockInfos [ 0 ] . endUID ) ) continue ; } else if ( ( date === slice . startTS && uid < slice . startUID ) || ( date === slice . endTS && uid > slice . endUID ) ) { continue ; } } else { slice . desiredHeaders ++ ; } if ( this . _onAddingHeader !== null ) { this . _onAddingHeader ( header ) ; } slice . onHeaderAdded ( header , false , true ) ; } } this . _insertIntoBlockUsingDateAndUID ( 'header' , header . date , header . id , header . srvid , $sync . HEADER_EST_SIZE_IN_BYTES , header , callback ) ; }
Add a new message to the database, generating slice notifications.
Add a new message to the database generating slice notifications .
// - Generate notifications for (other) interested slices // (if the slice is empty, it cares about any header!) // We never automatically grow a slice into the past if we are full, // but we do allow it if not full. // We do grow a slice into the present if it's already up-to-date... // !(covers most recently known message) // Make sure to increase the number of desired headers so the // truncating heuristic won't rule the header out.