Bug 723081 - pass the true gloda representation in so the attachments can hang off that v1. r=bienvenu,a=Standard8
authorAndrew Sutherland <asutherland@asutherland.org>
Wed, 15 Feb 2012 13:34:26 -0800
changeset 10195 3f05bb53a6816464a00e6403c32998a6b1149cf5
parent 10194 5579d69dcd4b8976d729c2fd48ce9d6db2ef1a12
child 10196 e117463528ff57577b9a3d4367e3342bbe694f6c
push id362
push userbugzilla@standard8.plus.com
push dateTue, 21 Feb 2012 22:07:37 +0000
treeherdercomm-beta@3f05bb53a681 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbienvenu, Standard8
bugs723081
Bug 723081 - pass the true gloda representation in so the attachments can hang off that v1. r=bienvenu,a=Standard8
mailnews/db/gloda/modules/fundattr.js
mailnews/db/gloda/modules/gloda.js
--- a/mailnews/db/gloda/modules/fundattr.js
+++ b/mailnews/db/gloda/modules/fundattr.js
@@ -608,17 +608,18 @@ var GlodaFundAttr = {
 
       // This is not the same kind of attachments as above. Now, we want to
       // provide convenience attributes to Gloda consumers, so that they can run
       // through the list of attachments of a given message, to possibly build a
       // visualization on top of it. We still reject bogus mime types, which
       // means yencode won't be supported. Oh, I feel really bad.
       let attachmentInfos = [];
       for each (let [, att] in Iterator(aMimeMsg.allUserAttachments)) {
-        attachmentInfos.push(this.glodaAttFromMimeAtt(aGlodaMessage, att));
+        attachmentInfos.push(this.glodaAttFromMimeAtt(aRawReps.trueGlodaRep,
+                                                      att));
       }
       aGlodaMessage.attachmentInfos = attachmentInfos;
     }
 
     // TODO: deal with mailing lists, including implicit-to.  this will require
     //  convincing the indexer to pass us in the previous message if it is
     //  available.  (which we'll simply pass to everyone... it can help body
     //  logic for quoting purposes, etc. too.)
--- a/mailnews/db/gloda/modules/gloda.js
+++ b/mailnews/db/gloda/modules/gloda.js
@@ -1929,20 +1929,28 @@ var Gloda = {
    *  that, we build and persist our attribute representations.
    *
    * The result of the processing ends up with attributes in 3 different forms:
    * - Database attribute rows (to be added and removed).
    * - In-memory representation.
    * - JSON-able representation.
    *
    * @param aItem The noun instance you want processed.
-   * @param aRawReps An opaque dictionary that we pass to the attribute
-   *     providers.  There is a(n implied) contract between the caller of
-   *     grokNounItem for a given noun type and the attribute providers for
-   *     that noun type, and we have nothing to do with it.
+   * @param aRawReps A dictionary that we pass to the attribute providers.
+   *     There is a(n implied) contract between the caller of grokNounItem for a
+   *     given noun type and the attribute providers for that noun type, and we
+   *     have nothing to do with it OTHER THAN inserting a 'trueGlodaRep'
+   *     value into it.  In the event of reindexing an existing object, the
+   *     gloda representation we pass to the indexers is actually a clone that
+   *     allows the asynchronous indexers to mutate the object without
+   *     causing visible changes in the existing representation of the gloda
+   *     object.  We patch the changes back onto the original item atomically
+   *     once indexing completes.  The 'trueGlodaRep' is then useful for
+   *     objects that hang off of the gloda instance that need a reference
+   *     back to their containing object for API convenience purposes.
    * @param aIsConceptuallyNew Is the item "new" in the sense that it would
    *     never have been visible from within user code?  This translates into
    *     whether this should trigger an itemAdded notification or an
    *     itemModified notification.
    * @param aIsRecordNew Is the item "new" in the sense that we should INSERT
    *     a record rather than UPDATE-ing a record.  For example, when dealing
    *     with messages where we may have a ghost, the ghost message is not a
    *     new record, but is conceptually new.
@@ -1960,16 +1968,17 @@ var Gloda = {
     this._log.info(" ** grokNounItem: " + itemNounDef.name);
 
     let addDBAttribs = [];
     let removeDBAttribs = [];
 
     let jsonDict = {};
 
     let aOldItem;
+    aRawReps.trueGlodaRep = aItem;
     if (aIsConceptuallyNew) // there is no old item if we are new.
       aOldItem = {};
     else {
       aOldItem = aItem;
       // we want to create a clone of the existing item so that we can know the
       //  deltas that happened for indexing purposes
       aItem = aItem._clone();
     }