B2G/gaia/apps/email/js/ext/mailapi/worker-bootstrap.js
/**
 * Book-keeping and limited agency for the slices.
 *
 * === Batching ===
 *
 * We do a few different types of batching based on the current sync state,
 * with these choices being motivated by UX desires and some efficiency desires
 * (in pursuit of improved UX).  We want the user to feel like they get their
 * messages quickly, but we also don't want messages jumping all over the
 * screen.
 *
 * - Fresh sync (all messages are new to us): Messages are being added from
 *   most recent to oldest.  Currently, we just let this pass through, but
 *   we might want to do some form of limited time-based batching.  (ex:
 *   wait 50ms or for notification of completion before sending a batch).
 *
 * - Refresh (sync): No action required because we either already have the
 *   messages or get them in efficient-ish batches.  This is followed by
 *   what should be minimal changes (and where refresh was explicitly chosen
 *   to be used rather than date sync for this reason.)
 *
 * - Date sync (some messages are new, some messages are known):  We currently
 *   get the known headers added one by one from youngest to oldest, followed
 *   by the new messages also youngest to oldest.  The notional UX (enforced
 *   by unit tests) for this is that we want all the changes coherently and with
 *   limits made effective.  To this end, we do not generate any splices until
 *   sync is complete and then generate a single slice.
 */
Book-keeping and limited agency for the slices.
=== Batching

We do a few different types of batching based on the current sync state,
with these choices being motivated by UX desires and some efficiency desires
(in pursuit of improved UX).  We want the user to feel like they get their
messages quickly, but we also don't want messages jumping all over the
screen.

- Fresh sync (all messages are new to us): Messages are being added from
most recent to oldest.  Currently, we just let this pass through, but
we might want to do some form of limited time-based batching.  (ex:
wait 50ms or for notification of completion before sending a batch).

- Refresh (sync): No action required because we either already have the
messages or get them in efficient-ish batches.  This is followed by
what should be minimal changes (and where refresh was explicitly chosen
to be used rather than date sync for this reason.)

- Date sync (some messages are new, some messages are known):  We currently
get the known headers added one by one from youngest to oldest, followed
by the new messages also youngest to oldest.  The notional UX (enforced
by unit tests) for this is that we want all the changes coherently and with
limits made effective.  To this end, we do not generate any splices until
sync is complete and then generate a single slice.
Book - keeping and limited agency for the slices . === Batching We do a few different types of batching based on the current sync state with these choices being motivated by UX desires and some efficiency desires ( in pursuit of improved UX ) . We want the user to feel like they get their messages quickly but we also don ' t want messages jumping all over the screen . - Fresh sync ( all messages are new to us ) : Messages are being added from most recent to oldest . Currently we just let this pass through but we might want to do some form of limited time - based batching . ( ex : wait 50ms or for notification of completion before sending a batch ) . - Refresh ( sync ) : No action required because we either already have the messages or get them in efficient - ish batches . This is followed by what should be minimal changes ( and where refresh was explicitly chosen to be used rather than date sync for this reason . ) - Date sync ( some messages are new some messages are known ) : We currently get the known headers added one by one from youngest to oldest followed by the new messages also youngest to oldest . The notional UX ( enforced by unit tests ) for this is that we want all the changes coherently and with limits made effective . To this end we do not generate any splices until sync is complete and then generate a single slice .
function MailSlice(bridgeHandle, storage, _parentLog) {
  this._bridgeHandle = bridgeHandle;
  bridgeHandle.__listener = this;
  this._storage = storage;
  this._LOG = LOGFAB.MailSlice(this, _parentLog, bridgeHandle._handle);
  this.startTS = null;
  this.startUID = null;
  this.endTS = null;
  this.endUID = null;
  this.waitingOnData = false;
  this._accumulating = false;
  this.ignoreHeaders = false;
  this.headers = [];
  this.desiredHeaders = $sync.INITIAL_FILL_SIZE;
}
function MailSlice ( bridgeHandle , storage , _parentLog ) { this . _bridgeHandle = bridgeHandle ; bridgeHandle . __listener = this ; this . _storage = storage ; this . _LOG = LOGFAB . MailSlice ( this , _parentLog , bridgeHandle . _handle ) ; this . startTS = null ; this . startUID = null ; this . endTS = null ; this . endUID = null ; this . waitingOnData = false ; this . _accumulating = false ; this . ignoreHeaders = false ; this . headers = [ ] ; this . desiredHeaders = $sync . INITIAL_FILL_SIZE ; }
Book-keeping and limited agency for the slices.
Book - keeping and limited agency for the slices .
// The time range of the headers we are looking at right now. // If the end values line up with the most recent message known about for this // folder, then we will grow to encompass more recent messages. /**
   * A string value for hypothetical debugging purposes, but which is coerced
   * to a Boolean value for some of our slice notifications as both the
   * userRequested/moreExpected values, although they aren't super important.
   */ /**
   * When true, we are not generating splices and are just accumulating state
   * in this.headers.
   */ /**
   * If true, don't add any headers.  This is used by ActiveSync during its
   * synchronization step to wait until all headers have been retrieved and
   * then the slice is populated from the database.  After this initial sync,
   * ignoreHeaders is set to false so that updates and (hopefully small
   * numbers of) additions/removals can be observed.
   */ /**
   * @listof[HeaderInfo]
   */