Bug 1197008 - Stop assuming 0 is an invalid threadId. r=btseng r=hsinyi
authorReuben Morais <reuben.morais@gmail.com>
Wed, 02 Sep 2015 09:37:17 -0300
changeset 293116 763a6d65f36c2d04c83dcdab815b9d3ab73c3823
parent 293115 4779c01d4b7132f2cb9e644cb4fccb8766626908
child 293117 ca185abaecc50c9e81fa3c75203b627c81569f75
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbtseng, hsinyi
bugs1197008
milestone43.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 1197008 - Stop assuming 0 is an invalid threadId. r=btseng r=hsinyi
dom/mobilemessage/MobileMessageManager.cpp
dom/mobilemessage/android/MobileMessageDatabaseService.cpp
dom/mobilemessage/gonk/MobileMessageDB.jsm
dom/mobilemessage/gonk/MobileMessageDatabaseService.js
dom/mobilemessage/interfaces/nsIMobileMessageDatabaseService.idl
dom/mobilemessage/ipc/SmsIPCService.cpp
dom/mobilemessage/ipc/SmsParent.cpp
dom/mobilemessage/ipc/SmsTypes.ipdlh
dom/mobilemessage/tests/marionette/mmdb_head.js
dom/webidl/MozMobileMessageManager.webidl
--- a/dom/mobilemessage/MobileMessageManager.cpp
+++ b/dom/mobilemessage/MobileMessageManager.cpp
@@ -458,30 +458,31 @@ MobileMessageManager::GetMessages(const 
   }
 
   bool hasRead = !aFilter.mRead.IsNull();
   bool read = false;
   if (hasRead) {
     read = aFilter.mRead.Value();
   }
 
+  bool hasThreadId = !aFilter.mThreadId.IsNull();
   uint64_t threadId = 0;
-  if (!aFilter.mThreadId.IsNull()) {
+  if (hasThreadId) {
     threadId = aFilter.mThreadId.Value();
   }
 
   nsRefPtr<MobileMessageCursorCallback> cursorCallback =
     new MobileMessageCursorCallback();
   nsCOMPtr<nsICursorContinueCallback> continueCallback;
   nsresult rv = dbService->CreateMessageCursor(hasStartDate, startDate,
                                                hasEndDate, endDate,
                                                ptrNumbers, numbersCount,
                                                delivery,
                                                hasRead, read,
-                                               threadId,
+                                               hasThreadId, threadId,
                                                aReverse, cursorCallback,
                                                getter_AddRefs(continueCallback));
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return nullptr;
   }
 
   nsCOMPtr<nsPIDOMWindow> window = GetOwner();
--- a/dom/mobilemessage/android/MobileMessageDatabaseService.cpp
+++ b/dom/mobilemessage/android/MobileMessageDatabaseService.cpp
@@ -51,16 +51,17 @@ MobileMessageDatabaseService::CreateMess
                                                   uint64_t aStartDate,
                                                   bool aHasEndDate,
                                                   uint64_t aEndDate,
                                                   const char16_t** aNumbers,
                                                   uint32_t aNumbersCount,
                                                   const nsAString& aDelivery,
                                                   bool aHasRead,
                                                   bool aRead,
+                                                  bool aHasThreadId,
                                                   uint64_t aThreadId,
                                                   bool aReverse,
                                                   nsIMobileMessageCursorCallback* aCallback,
                                                   nsICursorContinueCallback** aResult)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
--- a/dom/mobilemessage/gonk/MobileMessageDB.jsm
+++ b/dom/mobilemessage/gonk/MobileMessageDB.jsm
@@ -4040,25 +4040,26 @@ MobileMessageDB.prototype = {
    *        <code>true</code> to reverse the order.
    * @param {nsIMobileMessageCursorCallback} aCallback
    *        The callback object used by GetMessagesCursor
    * @return {GetMessagesCursor}
    *         The cursor to iterate on messages.
    */
   createMessageCursor: function(aHasStartDate, aStartDate, aHasEndDate,
                                 aEndDate, aNumbers, aNumbersCount, aDelivery,
-                                aHasRead, aRead, aThreadId, aReverse, aCallback) {
+                                aHasRead, aRead, aHasThreadId, aThreadId,
+                                aReverse, aCallback) {
     if (DEBUG) {
       debug("Creating a message cursor. Filters:" +
             " startDate: " + (aHasStartDate ? aStartDate : "(null)") +
             " endDate: " + (aHasEndDate ? aEndDate : "(null)") +
             " delivery: " + aDelivery +
             " numbers: " + (aNumbersCount ? aNumbers : "(null)") +
             " read: " + (aHasRead ? aRead : "(null)") +
-            " threadId: " + aThreadId +
+            " threadId: " + (aHasThreadId ? aThreadId : "(null)") +
             " reverse: " + aReverse);
     }
 
     let filter = {};
     if (aHasStartDate) {
       filter.startDate = aStartDate;
     }
     if (aHasEndDate) {
@@ -4068,17 +4069,17 @@ MobileMessageDB.prototype = {
       filter.numbers = aNumbers.slice();
     }
     if (aDelivery !== null) {
       filter.delivery = aDelivery;
     }
     if (aHasRead) {
       filter.read = aRead;
     }
-    if (aThreadId) {
+    if (aHasThreadId) {
       filter.threadId = aThreadId;
     }
 
     let cursor = new GetMessagesCursor(this, aCallback);
 
     let self = this;
     self.newTxn(READ_ONLY, function(error, txn, stores) {
       let collector = cursor.collector.idCollector;
--- a/dom/mobilemessage/gonk/MobileMessageDatabaseService.js
+++ b/dom/mobilemessage/gonk/MobileMessageDatabaseService.js
@@ -105,21 +105,22 @@ MobileMessageDatabaseService.prototype =
   },
 
   deleteMessage: function(aMessageIds, aLength, aRequest) {
     this.mmdb.deleteMessage(aMessageIds, aLength, aRequest);
   },
 
   createMessageCursor: function(aHasStartDate, aStartDate, aHasEndDate,
                                 aEndDate, aNumbers, aNumbersCount, aDelivery,
-                                aHasRead, aRead, aThreadId, aReverse, aCallback) {
+                                aHasRead, aRead, aHasThreadId, aThreadId,
+                                aReverse, aCallback) {
     return this.mmdb.createMessageCursor(aHasStartDate, aStartDate, aHasEndDate,
                                          aEndDate, aNumbers, aNumbersCount,
-                                         aDelivery, aHasRead, aRead, aThreadId,
-                                         aReverse, aCallback);
+                                         aDelivery, aHasRead, aRead, aHasThreadId,
+                                         aThreadId, aReverse, aCallback);
   },
 
   markMessageRead: function(aMessageId, aValue, aSendReadReport, aRequest) {
     this.mmdb.markMessageRead(aMessageId, aValue, aSendReadReport, aRequest);
   },
 
   createThreadCursor: function(aCallback) {
     return this.mmdb.createThreadCursor(aCallback);
--- a/dom/mobilemessage/interfaces/nsIMobileMessageDatabaseService.idl
+++ b/dom/mobilemessage/interfaces/nsIMobileMessageDatabaseService.idl
@@ -10,17 +10,17 @@
 { 0xa5, 0xcd, 0xdb, 0xfb, 0x01, 0xdf, 0xda, 0x99 } }
 #define MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID "@mozilla.org/mobilemessage/mobilemessagedatabaseservice;1"
 %}
 
 interface nsICursorContinueCallback;
 interface nsIMobileMessageCallback;
 interface nsIMobileMessageCursorCallback;
 
-[scriptable, uuid(ead626bc-f5b4-47e1-921c-0b956c9298e0)]
+[scriptable, uuid(18672be2-c185-4f9c-8af6-2e6ea004de73)]
 interface nsIMobileMessageDatabaseService : nsISupports
 {
   [binaryname(GetMessageMoz)]
   void getMessage(in long messageId,
                   in nsIMobileMessageCallback request);
 
   void deleteMessage([array, size_is(count)] in long messageIds,
                      in uint32_t count,
@@ -30,16 +30,17 @@ interface nsIMobileMessageDatabaseServic
                                                 in unsigned long long startDate,
                                                 in boolean hasEndDate,
                                                 in unsigned long long endDate,
                                                 [array, size_is(numbersCount)] in wstring numbers,
                                                 in uint32_t numbersCount,
                                                 [Null(Null), Undefined(Null)] in DOMString delivery,
                                                 in boolean hasRead,
                                                 in boolean read,
+                                                in boolean hasThreadId,
                                                 in unsigned long long threadId,
                                                 in boolean reverse,
                                                 in nsIMobileMessageCursorCallback callback);
 
   void markMessageRead(in long messageId,
                        in boolean value,
                        in boolean sendReadReport,
                        in nsIMobileMessageCallback request);
--- a/dom/mobilemessage/ipc/SmsIPCService.cpp
+++ b/dom/mobilemessage/ipc/SmsIPCService.cpp
@@ -255,16 +255,17 @@ SmsIPCService::CreateMessageCursor(bool 
                                    uint64_t aStartDate,
                                    bool aHasEndDate,
                                    uint64_t aEndDate,
                                    const char16_t** aNumbers,
                                    uint32_t aNumbersCount,
                                    const nsAString& aDelivery,
                                    bool aHasRead,
                                    bool aRead,
+                                   bool aHasThreadId,
                                    uint64_t aThreadId,
                                    bool aReverse,
                                    nsIMobileMessageCursorCallback* aCursorCallback,
                                    nsICursorContinueCallback** aResult)
 {
   SmsFilterData data;
 
   data.hasStartDate() = aHasStartDate;
@@ -279,16 +280,17 @@ SmsIPCService::CreateMessageCursor(bool 
     for (index = 0; index < aNumbersCount; index++) {
       numbers.AppendElement(aNumbers[index]);
     }
   }
 
   data.delivery() = aDelivery;
   data.hasRead() = aHasRead;
   data.read() = aRead;
+  data.hasThreadId() = aHasThreadId;
   data.threadId() = aThreadId;
 
   return SendCursorRequest(CreateMessageCursorRequest(data, aReverse),
                            aCursorCallback, aResult);
 }
 
 NS_IMETHODIMP
 SmsIPCService::MarkMessageRead(int32_t aMessageId,
--- a/dom/mobilemessage/ipc/SmsParent.cpp
+++ b/dom/mobilemessage/ipc/SmsParent.cpp
@@ -842,16 +842,17 @@ MobileMessageCursorParent::DoRequest(con
     rv = dbService->CreateMessageCursor(filter.hasStartDate(),
                                         filter.startDate(),
                                         filter.hasEndDate(),
                                         filter.endDate(),
                                         ptrNumbers, numbersCount,
                                         filter.delivery(),
                                         filter.hasRead(),
                                         filter.read(),
+                                        filter.hasThreadId(),
                                         filter.threadId(),
                                         aRequest.reverse(),
                                         this,
                                         getter_AddRefs(mContinueCallback));
   }
 
   if (NS_FAILED(rv)) {
     return NS_SUCCEEDED(NotifyCursorError(nsIMobileMessageCallback::INTERNAL_ERROR));
--- a/dom/mobilemessage/ipc/SmsTypes.ipdlh
+++ b/dom/mobilemessage/ipc/SmsTypes.ipdlh
@@ -80,16 +80,17 @@ struct SmsFilterData
   bool          hasStartDate;
   uint64_t      startDate;
   bool          hasEndDate;
   uint64_t      endDate;
   nsString[]    numbers;
   nsString      delivery;
   bool          hasRead;
   bool          read;
+  bool          hasThreadId;
   uint64_t      threadId;
 };
 
 struct ThreadData
 {
   uint64_t    id;
   nsString[]  participants;
   uint64_t    timestamp;
--- a/dom/mobilemessage/tests/marionette/mmdb_head.js
+++ b/dom/mobilemessage/tests/marionette/mmdb_head.js
@@ -336,16 +336,17 @@ function createMessageCursor(aMmdb, aSta
                           aStartDate || 0,
                           aEndDate !== null,
                           aEndDate || 0,
                           aNumbers || null,
                           aNumbers && aNumbers.length || 0,
                           aDelivery || null,
                           aRead !== null,
                           aRead || false,
+                          aThreadId !== null,
                           aThreadId || 0,
                           aReverse || false);
 }
 
 /**
  * A convenient function for calling |mmdb.createThreadCursor(...)|.
  *
  * Fulfill params: [<Ci.nsIMobileMessageCallback.FOO>, [<DOM thread>]].
--- a/dom/webidl/MozMobileMessageManager.webidl
+++ b/dom/webidl/MozMobileMessageManager.webidl
@@ -67,17 +67,17 @@ dictionary MobileMessageFilter
   sequence<DOMString>? numbers = null;
 
   MobileMessageFilterDelivery? delivery = null;
 
   // Filtering by whether a message has been read or not.
   boolean? read = null;
 
   // Filtering by a message's threadId attribute.
-  [EnforceRange] unsigned long long? threadId = 0;
+  [EnforceRange] unsigned long long? threadId = null;
 };
 
 /**
  * TON defined in |Table 10.5.118: Called party BCD number| of 3GPP TS 24.008.
  * It's used in SM-RL originator / destination address element as defined in
  * |8.2.5.2 Destination address element| of 3GPP TS 24.011.
  */
 enum TypeOfNumber { "unknown", "international", "national", "network-specific",