Backout d29847ff05c4 (bug 811538) for B2G marionette-webapi failures in test_getmessage.js
authorEd Morley <emorley@mozilla.com>
Wed, 05 Dec 2012 10:42:51 +0000
changeset 115038 56f34c1cc509
parent 115037 ab23919fe636
child 115039 2812c6500aed
child 115053 247f62a63000
push id23951
push useremorley@mozilla.com
push date2012-12-05 15:27 +0000
treeherdermozilla-central@56f34c1cc509 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs811538
milestone20.0a1
backs outd29847ff05c4
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
Backout d29847ff05c4 (bug 811538) for B2G marionette-webapi failures in test_getmessage.js
dom/sms/src/ril/SmsDatabaseService.js
--- a/dom/sms/src/ril/SmsDatabaseService.js
+++ b/dom/sms/src/ril/SmsDatabaseService.js
@@ -3,24 +3,23 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/PhoneNumberUtils.jsm");
 
 const RIL_SMSDATABASESERVICE_CONTRACTID = "@mozilla.org/sms/rilsmsdatabaseservice;1";
 const RIL_SMSDATABASESERVICE_CID = Components.ID("{a1fa610c-eb6c-4ac2-878f-b005d5e89249}");
 
 const DEBUG = false;
 const DB_NAME = "sms";
-const DB_VERSION = 6;
+const DB_VERSION = 5;
 const STORE_NAME = "sms";
 const MOST_RECENT_STORE_NAME = "most-recent";
 
 const DELIVERY_SENT = "sent";
 const DELIVERY_RECEIVED = "received";
 
 const DELIVERY_STATUS_NOT_APPLICABLE = "not-applicable";
 const DELIVERY_STATUS_SUCCESS = "success";
@@ -185,20 +184,16 @@ SmsDatabaseService.prototype = {
           case 3:
             if (DEBUG) debug("Upgrade to version 4. Add quick threads view.")
             self.upgradeSchema3(db, event.target.transaction);
             break;
           case 4:
             if (DEBUG) debug("Upgrade to version 5. Populate quick threads view.")
             self.upgradeSchema4(event.target.transaction);
             break;
-          case 5:
-            if (DEBUG) debug("Upgrade to version 6. Use PhonenumberJS.")
-            self.upgradeSchema5(event.target.transaction);
-            break;
           default:
             event.target.transaction.abort();
             callback("Old database version: " + event.oldVersion, null);
             break;
         }
         currentVersion++;
       }
     }
@@ -357,86 +352,16 @@ SmsDatabaseService.prototype = {
           body: message.body,
           unreadCount: message.read ? 0 : 1
         }
       }
       cursor.continue();
     }
   },
 
-  upgradeSchema5: function upgradeSchema5(transaction) {
-    let smsStore = transaction.objectStore(STORE_NAME);
-    let mostRecentStore = transaction.objectStore(MOST_RECENT_STORE_NAME);
-
-    smsStore.openCursor().onsuccess = function(event) {
-      let cursor = event.target.result;
-      if (!cursor) {
-        return;
-      }
-
-      let needsUpdate = false;
-      let message = cursor.value;
-      if (message.receiver) {
-        if (message.receiver !== "undefined") {
-          if (DEBUG) debug("upgrade message.receiver from: " + message.receiver + "\n");
-          let parsedNumber = PhoneNumberUtils.parse(message.receiver.toString());
-          if (parsedNumber && parsedNumber.internationalNumber) {
-            message.receiver = parsedNumber.internationalNumber;
-            needsUpdate = true;
-          }
-
-          if (DEBUG) debug("upgrade message.receiver to: " + message.receiver + "\n");
-        } else {
-          message.receiver = null;
-          needsUpdate = true;
-        }
-      }
-
-      if (message.sender) {
-        if (message.sender !== "undefined") {
-          if (DEBUG) debug("upgrade message.sender from: " + message.sender + "\n");
-          let parsedNumber = PhoneNumberUtils.parse(message.sender.toString());
-          if (parsedNumber && parsedNumber.internationalNumber) {
-            message.sender = parsedNumber.internationalNumber;
-            needsUpdate = true;
-            if (DEBUG) debug("upgrade message.sender to: " + message.sender + "\n");
-          }
-        } else {
-          message.sender = null;
-          needsUpdate = true;
-        }
-      }
-
-      if (needsUpdate) {
-        cursor.update(message);
-      }
-      cursor.continue();
-    }
-
-    mostRecentStore.openCursor().onsuccess = function(event) {
-      let cursor = event.target.result;
-      if (!cursor) {
-        return;
-      }
-
-      let entry = cursor.value;
-      if (entry.senderOrReceiver) {
-        if (DEBUG) debug("upgrade mostRecentStore from: " + entry.senderOrReceiver + "\n");
-        let parsedNumber = PhoneNumberUtils.parse(entry.senderOrReceiver);
-        if (parsedNumber && parsedNumber.internationalNumber) {
-          entry.senderOrReceiver = parsedNumber.internationalNumber;
-          cursor.update(entry);
-          if (DEBUG) debug("upgrade mostRecentStore to: " + entry.senderOrReceiver + "\n");
-        }
-      }
-
-      cursor.continue();
-    }
-  },
-
   /**
    * Helper function to make the intersection of the partial result arrays
    * obtained within createMessageList.
    *
    * @param keys
    *        Object containing the partial result arrays.
    * @param fiter
    *        Object containing the filter search criteria used to retrieved the
@@ -563,82 +488,52 @@ SmsDatabaseService.prototype = {
     return message.id;
   },
 
 
   /**
    * nsISmsDatabaseService API
    */
 
-  saveReceivedMessage: function saveReceivedMessage(aSender, aBody, aMessageClass, aDate) {
+  saveReceivedMessage: function saveReceivedMessage(sender, body, messageClass, date) {
     let receiver = this.mRIL.rilContext.icc ? this.mRIL.rilContext.icc.msisdn : null;
 
     // Workaround an xpconnect issue with undefined string objects.
     // See bug 808220
     if (receiver === undefined || receiver === "undefined") {
       receiver = null;
     }
 
-    if (receiver) {
-      let parsedNumber = PhoneNumberUtils.parse(receiver);
-      receiver = (parsedNumber && parsedNumber.internationalNumber)
-                 ? parsedNumber.internationalNumber
-                 : receiver;
-    }
-
-    let sender = aSender;
-    if (sender) {
-      let parsedNumber = PhoneNumberUtils.parse(sender);
-      sender = (parsedNumber && parsedNumber.internationalNumber)
-               ? parsedNumber.internationalNumber
-               : sender;
-    }
-
     let message = {delivery:       DELIVERY_RECEIVED,
                    deliveryStatus: DELIVERY_STATUS_SUCCESS,
                    sender:         sender,
                    receiver:       receiver,
-                   body:           aBody,
-                   messageClass:   aMessageClass,
-                   timestamp:      aDate,
+                   body:           body,
+                   messageClass:   messageClass,
+                   timestamp:      date,
                    read:           FILTER_READ_UNREAD};
     return this.saveMessage(message);
   },
 
-  saveSentMessage: function saveSentMessage(aReceiver, aBody, aDate) {
+  saveSentMessage: function saveSentMessage(receiver, body, date) {
     let sender = this.mRIL.rilContext.icc ? this.mRIL.rilContext.icc.msisdn : null;
 
     // Workaround an xpconnect issue with undefined string objects.
     // See bug 808220
     if (sender === undefined || sender === "undefined") {
       sender = null;
     }
 
-    let receiver = aReceiver
-    if (receiver) {
-      let parsedNumber = PhoneNumberUtils.parse(receiver.toString());
-      receiver = (parsedNumber && parsedNumber.internationalNumber)
-                 ? parsedNumber.internationalNumber
-                 : receiver;
-    }
-
-    if (sender) {
-      let parsedNumber = PhoneNumberUtils.parse(sender.toString());
-      sender = (parsedNumber && parsedNumber.internationalNumber)
-               ? parsedNumber.internationalNumber
-               : sender;
-    }
-
     let message = {delivery:       DELIVERY_SENT,
                    deliveryStatus: DELIVERY_STATUS_PENDING,
                    sender:         sender,
                    receiver:       receiver,
-                   body:           aBody,
+                   body:           body,
                    messageClass:   MESSAGE_CLASS_NORMAL,
-                   timestamp:      aDate,
+                   timestamp:      date,
                    read:           FILTER_READ_READ};
     return this.saveMessage(message);
   },
 
   setMessageDeliveryStatus: function setMessageDeliveryStatus(messageId, deliveryStatus) {
     if ((deliveryStatus != DELIVERY_STATUS_SUCCESS)
         && (deliveryStatus != DELIVERY_STATUS_ERROR)) {
       if (DEBUG) {
@@ -725,20 +620,17 @@ SmsDatabaseService.prototype = {
                                                    data.body,
                                                    data.messageClass,
                                                    data.timestamp,
                                                    data.read);
         aRequest.notifyMessageGot(message);
       };
 
       txn.onerror = function onerror(event) {
-        if (DEBUG) {
-          if (event.target)
-            debug("Caught error on transaction", event.target.errorCode);
-        }
+        if (DEBUG) debug("Caught error on transaction", event.target.errorCode);
         //TODO look at event.target.errorCode, pick appropriate error constant
         aRequest.notifyGetMessageFailed(Ci.nsISmsRequest.INTERNAL_ERROR);
       };
     });
   },
 
   deleteMessage: function deleteMessage(messageId, aRequest) {
     let deleted = false;