Bug 869841 - B2G MMS: Gaia cannot get request returned after calling .sendMMS(...). r=vicamo a=leo+
authorGene Lian <clian@mozilla.com>
Wed, 08 May 2013 18:40:41 +0800
changeset 142150 7243109bed0a9f52652aa663264d89669e8fa752
parent 142149 ea89e932e5a377dc19d3194ccd2719437a639f8b
child 142151 62a9fd6e8a4a5348de0f1cdcf9b748dffdae7a4f
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvicamo, leo
bugs869841
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 869841 - B2G MMS: Gaia cannot get request returned after calling .sendMMS(...). r=vicamo a=leo+
dom/mms/src/ril/MmsService.js
--- a/dom/mms/src/ril/MmsService.js
+++ b/dom/mms/src/ril/MmsService.js
@@ -1072,40 +1072,42 @@ MmsService.prototype = {
       read:           aDomMessage.read,
       subject:        aDomMessage.subject,
       smil:           aDomMessage.smil,
       attachments:    aDomMessage.attachments
     });
   },
 
   /**
-   * A helper function to broadcast the mms sent system message and notify observers.
+   * A helper function to broadcast system message and notify observers that
+   * an MMS is sent.
    *
    * @params aDomMessage
    *         The nsIDOMMozMmsMessage object.
    */
   broadcastSentMessageEvent: function broadcastSentMessageEvent(aDomMessage) {
     // Broadcasting a 'sms-sent' system message to open apps.
     this.broadcastMmsSystemMessage("sms-sent", aDomMessage);
 
     // Notifying observers an MMS message is sent.
     Services.obs.notifyObservers(aDomMessage, kSmsSentObserverTopic, null);
   },
 
   /**
-   * A helper function to broadcast the mms received system message and notify observers.
+   * A helper function to broadcast system message and notify observers that
+   * an MMS is received.
    *
    * @params aDomMessage
    *         The nsIDOMMozMmsMessage object.
    */
   broadcastReceivedMessageEvent :function broadcastReceivedMessageEvent(aDomMessage) {
     // Broadcasting a 'sms-received' system message to open apps.
     this.broadcastMmsSystemMessage("sms-received", aDomMessage);
 
-    // Notifying observers an MMS message is comming.
+    // Notifying observers an MMS message is received.
     Services.obs.notifyObservers(aDomMessage, kSmsReceivedObserverTopic, null);
   },
 
   /**
    * Callback for retrieveMessage.
    */
   retrieveMessageCallback: function retrieveMessageCallback(wish,
                                                             savableMessage,
@@ -1137,16 +1139,22 @@ MmsService.prototype = {
     }
 
     savableMessage = this.mergeRetrievalConfirmation(retrievedMessage,
                                                      savableMessage);
 
     gMobileMessageDatabaseService.saveReceivedMessage(savableMessage,
         (function (rv, domMessage) {
       let success = Components.isSuccessCode(rv);
+
+      // Cite 6.2.1 "Transaction Flow" in OMA-TS-MMS_ENC-V1_3-20110913-A:
+      // The M-NotifyResp.ind response PDU SHALL provide a message retrieval
+      // status code. The status ‘retrieved’ SHALL be used only if the MMS
+      // Client has successfully retrieved the MM prior to sending the
+      // NotifyResp.ind response PDU.
       let transaction =
         new NotifyResponseTransaction(transactionId,
                                       success ? MMS.MMS_PDU_STATUS_RETRIEVED
                                               : MMS.MMS_PDU_STATUS_DEFERRED,
                                       reportAllowed);
       transaction.run();
 
       if (!success) {
@@ -1214,17 +1222,20 @@ MmsService.prototype = {
                                                       reportAllowed);
       transaction.run();
       return;
     }
     let url = savableMessage.headers["x-mms-content-location"].uri;
 
     // For RETRIEVAL_MODE_AUTOMATIC or RETRIEVAL_MODE_AUTOMATIC_HOME but not
     // roaming, proceed to retrieve MMS.
-    this.retrieveMessage(url, this.retrieveMessageCallback.bind(this, wish, savableMessage));
+    this.retrieveMessage(url,
+                         this.retrieveMessageCallback.bind(this,
+                                                           wish,
+                                                           savableMessage));
   },
 
   /**
    * Handle incoming M-Notification.ind PDU.
    *
    * @param notification
    *        The parsed MMS message object.
    */
@@ -1384,17 +1395,21 @@ MmsService.prototype = {
                            JSON.stringify(aParams.receivers));
           aRequest.notifySendMessageFailed(Ci.nsIMobileMessageCallback.INTERNAL_ERROR);
           Services.obs.notifyObservers(aDomMessage, kSmsFailedObserverTopic, null);
           return;
         }
 
         if (DEBUG) debug("Send MMS successful. aParams.receivers = " +
                          JSON.stringify(aParams.receivers));
-        self.broadcastSentMessageEvent(domMessage);
+
+        // Notifying observers the MMS message is sent.
+        self.broadcastSentMessageEvent(aDomMessage);
+
+        // Return the request after sending the MMS message successfully.
         aRequest.notifyMessageSent(aDomMessage);
       });
     };
 
     let savableMessage = this.createSavableFromParams(aParams);
     gMobileMessageDatabaseService
       .saveSendingMessage(savableMessage,
                           function notifySendingResult(aRv, aDomMessage) {
@@ -1485,19 +1500,28 @@ MmsService.prototype = {
             // At this point we could send a message to content to
             // notify the user that storing an incoming MMS failed, most
             // likely due to a full disk.
             if (DEBUG) debug("Could not store MMS " + domMessage.id +
                   ", error code " + rv);
             aRequest.notifyGetMessageFailed(Ci.nsIMobileMessageCallback.INTERNAL_ERROR);
             return;
           }
+
           // Notifying observers a new MMS message is retrieved.
+          this.broadcastReceivedMessageEvent(domMessage);
+
+          // Return the request after retrieving the MMS message successfully.
           aRequest.notifyMessageGot(domMessage);
-          this.broadcastReceivedMessageEvent(domMessage);
+
+          // Cite 6.3.1 "Transaction Flow" in OMA-TS-MMS_ENC-V1_3-20110913-A:
+          // If an acknowledgement is requested, the MMS Client SHALL respond
+          // with an M-Acknowledge.ind PDU to the MMS Proxy-Relay that supports
+          // the specific MMS Client. The M-Acknowledge.ind PDU confirms
+          // successful message retrieval to the MMS Proxy Relay.
           let transaction = new AcknowledgeTransaction(transactionId, reportAllowed);
           transaction.run();
         }).bind(this));
       }).bind(this));
     }).bind(this));
   },
 
   // nsIWapPushApplication