Bug 849739 2/5: DOM. r=mounir,mrbkap
authorVicamo Yang <vyang@mozilla.com>
Tue, 09 Apr 2013 10:21:54 +0800
changeset 134871 2957ce54d228455d0c065b0e2ceb18d77f32e98b
parent 134870 ad3f6f75ac8bdd481e07a377e19ee54d989a7430
child 134872 67d1f7ca23812bbdc99925c0407a2650d280d082
push id3752
push userlsblakk@mozilla.com
push dateMon, 13 May 2013 17:21:10 +0000
treeherdermozilla-aurora@1580544aef0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmounir, mrbkap
bugs849739
milestone23.0a1
Bug 849739 2/5: DOM. r=mounir,mrbkap
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMClassInfoClasses.h
dom/mobilemessage/interfaces/moz.build
dom/mobilemessage/src/Makefile.in
dom/mobilemessage/src/MmsMessage.cpp
dom/mobilemessage/src/MobileMessageCallback.cpp
dom/mobilemessage/src/MobileMessageManager.cpp
dom/mobilemessage/src/MobileMessageService.cpp
dom/mobilemessage/src/MobileMessageThread.cpp
dom/mobilemessage/src/MobileMessageThread.h
dom/mobilemessage/src/SmsManager.cpp
dom/mobilemessage/src/SmsMessage.cpp
dom/mobilemessage/src/SmsRequest.cpp
dom/mobilemessage/src/android/MobileMessageDatabaseService.cpp
dom/mobilemessage/src/fallback/MobileMessageDatabaseService.cpp
dom/tests/mochitest/general/test_interfaces.html
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -330,16 +330,17 @@ using mozilla::dom::workers::ResolveWork
 #include "nsIDOMWakeLock.h"
 #include "nsIDOMSmsManager.h"
 #include "nsIDOMMobileMessageManager.h"
 #include "nsIDOMMozSmsMessage.h"
 #include "nsIDOMMozMmsMessage.h"
 #include "nsIDOMSmsRequest.h"
 #include "nsIDOMSmsFilter.h"
 #include "nsIDOMSmsSegmentInfo.h"
+#include "nsIDOMMozMobileMessageThread.h"
 #include "nsIDOMConnection.h"
 #include "mozilla/dom/network/Utils.h"
 
 #ifdef MOZ_B2G_RIL
 #include "Telephony.h"
 #include "TelephonyCall.h"
 #include "nsIDOMMozVoicemail.h"
 #include "nsIDOMIccManager.h"
@@ -915,16 +916,19 @@ static nsDOMClassInfoData sClassInfoData
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
   NS_DEFINE_CLASSINFO_DATA(MozSmsFilter, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
   NS_DEFINE_CLASSINFO_DATA(MozSmsSegmentInfo, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
+  NS_DEFINE_CLASSINFO_DATA(MozMobileMessageThread, nsDOMGenericSH,
+                           DOM_DEFAULT_SCRIPTABLE_FLAGS)
+
   NS_DEFINE_CLASSINFO_DATA(MozConnection, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
 #ifdef MOZ_B2G_RIL
   NS_DEFINE_CLASSINFO_DATA(MozMobileConnection, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
   NS_DEFINE_CLASSINFO_DATA(MozCellBroadcast, nsDOMGenericSH,
@@ -2362,16 +2366,20 @@ nsDOMClassInfo::Init()
   DOM_CLASSINFO_MAP_BEGIN(MozSmsFilter, nsIDOMMozSmsFilter)
      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsFilter)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(MozSmsSegmentInfo, nsIDOMMozSmsSegmentInfo)
      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsSegmentInfo)
   DOM_CLASSINFO_MAP_END
 
+  DOM_CLASSINFO_MAP_BEGIN(MozMobileMessageThread, nsIDOMMozMobileMessageThread)
+     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozMobileMessageThread)
+  DOM_CLASSINFO_MAP_END
+
   DOM_CLASSINFO_MAP_BEGIN(MozConnection, nsIDOMMozConnection)
      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozConnection)
      DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
   DOM_CLASSINFO_MAP_END
 
 #ifdef MOZ_B2G_RIL
   DOM_CLASSINFO_MAP_BEGIN(MozMobileConnection, nsIDOMMozMobileConnection)
      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozMobileConnection)
--- a/dom/base/nsDOMClassInfoClasses.h
+++ b/dom/base/nsDOMClassInfoClasses.h
@@ -188,16 +188,17 @@ DOMCI_CLASS(MozWakeLock)
 
 DOMCI_CLASS(MozSmsManager)
 DOMCI_CLASS(MozMobileMessageManager)
 DOMCI_CLASS(MozSmsMessage)
 DOMCI_CLASS(MozMmsMessage)
 DOMCI_CLASS(MozSmsRequest)
 DOMCI_CLASS(MozSmsFilter)
 DOMCI_CLASS(MozSmsSegmentInfo)
+DOMCI_CLASS(MozMobileMessageThread)
 
 DOMCI_CLASS(MozConnection)
 #ifdef MOZ_B2G_RIL
 DOMCI_CLASS(MozMobileConnection)
 DOMCI_CLASS(MozCellBroadcast)
 #endif
 
 // @font-face in CSS
--- a/dom/mobilemessage/interfaces/moz.build
+++ b/dom/mobilemessage/interfaces/moz.build
@@ -3,16 +3,17 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 XPIDL_SOURCES += [
     'nsIDOMMobileMessageManager.idl',
     'nsIDOMMozMmsEvent.idl',
     'nsIDOMMozMmsMessage.idl',
+    'nsIDOMMozMobileMessageThread.idl',
     'nsIDOMMozSmsEvent.idl',
     'nsIDOMMozSmsMessage.idl',
     'nsIDOMNavigatorMobileMessage.idl',
     'nsIDOMNavigatorSms.idl',
     'nsIDOMSmsFilter.idl',
     'nsIDOMSmsManager.idl',
     'nsIDOMSmsRequest.idl',
     'nsIDOMSmsSegmentInfo.idl',
--- a/dom/mobilemessage/src/Makefile.in
+++ b/dom/mobilemessage/src/Makefile.in
@@ -49,16 +49,17 @@ EXPORTS_mozilla/dom/mobilemessage = \
   SmsServicesFactory.h \
   Constants.h \
   Types.h \
   MobileMessageCallback.h \
   $(NULL)
 
 CPPSRCS = \
   MobileMessageCursorCallback.cpp \
+  MobileMessageThread.cpp \
   SmsManager.cpp \
   MobileMessageManager.cpp \
   SmsService.cpp \
   MobileMessageService.cpp \
   SmsIPCService.cpp \
   SmsServicesFactory.cpp \
   SmsParent.cpp \
   SmsMessage.cpp \
--- a/dom/mobilemessage/src/MmsMessage.cpp
+++ b/dom/mobilemessage/src/MmsMessage.cpp
@@ -325,17 +325,20 @@ MmsMessage::GetReceivers(JSContext* aCx,
 
   aReceivers->setObject(*reveiversObj);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 MmsMessage::GetTimestamp(JSContext* cx, JS::Value* aDate)
 {
-  *aDate = OBJECT_TO_JSVAL(JS_NewDateObjectMsec(cx, mTimestamp));
+  JSObject *obj = JS_NewDateObjectMsec(cx, mTimestamp);
+  NS_ENSURE_TRUE(obj, NS_ERROR_FAILURE);
+
+  *aDate = OBJECT_TO_JSVAL(obj);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 MmsMessage::GetRead(bool* aRead)
 {
   *aRead = mRead;
   return NS_OK;
--- a/dom/mobilemessage/src/MobileMessageCallback.cpp
+++ b/dom/mobilemessage/src/MobileMessageCallback.cpp
@@ -134,23 +134,11 @@ MobileMessageCallback::NotifyMessageMark
 }
 
 NS_IMETHODIMP
 MobileMessageCallback::NotifyMarkMessageReadFailed(int32_t aError)
 {
   return NotifyError(aError);
 }
 
-NS_IMETHODIMP
-MobileMessageCallback::NotifyThreadList(const JS::Value& aThreadList, JSContext* aCx)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
-MobileMessageCallback::NotifyThreadListFailed(int32_t aError)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
 } // namesapce mobilemessage
 } // namespace dom
 } // namespace mozilla
--- a/dom/mobilemessage/src/MobileMessageManager.cpp
+++ b/dom/mobilemessage/src/MobileMessageManager.cpp
@@ -313,26 +313,33 @@ MobileMessageManager::MarkMessageRead(in
   nsresult rv = mobileMessageDBService->MarkMessageRead(aId, aValue, msgCallback);
   NS_ENSURE_SUCCESS(rv, rv);
 
   request.forget(aRequest);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-MobileMessageManager::GetThreadList(nsIDOMMozSmsRequest** aRequest)
+MobileMessageManager::GetThreads(nsIDOMDOMCursor** aCursor)
 {
-  nsCOMPtr<nsIDOMMozSmsRequest> req = SmsRequest::Create(this);
-  nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService =
+  nsCOMPtr<nsIMobileMessageDatabaseService> dbService =
     do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
-  NS_ENSURE_TRUE(mobileMessageDBService, NS_ERROR_FAILURE);
-  nsCOMPtr<nsIMobileMessageCallback> forwarder =
-    new SmsRequestForwarder(static_cast<SmsRequest*>(req.get()));
-  mobileMessageDBService->GetThreadList(forwarder);
-  req.forget(aRequest);
+  NS_ENSURE_TRUE(dbService, NS_ERROR_FAILURE);
+
+  nsRefPtr<MobileMessageCursorCallback> cursorCallback =
+    new MobileMessageCursorCallback();
+
+  nsCOMPtr<nsICursorContinueCallback> continueCallback;
+  nsresult rv = dbService->CreateThreadCursor(cursorCallback,
+                                              getter_AddRefs(continueCallback));
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  cursorCallback->mDOMCursor = new DOMCursor(GetOwner(), continueCallback);
+  NS_ADDREF(*aCursor = cursorCallback->mDOMCursor);
+
   return NS_OK;
 }
 
 nsresult
 MobileMessageManager::DispatchTrustedSmsEventToSelf(const nsAString& aEventName,
                                                     nsIDOMMozSmsMessage* aMessage)
 {
   nsCOMPtr<nsIDOMEvent> event;
--- a/dom/mobilemessage/src/MobileMessageService.cpp
+++ b/dom/mobilemessage/src/MobileMessageService.cpp
@@ -1,14 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "SmsMessage.h"
 #include "MmsMessage.h"
+#include "MobileMessageThread.h"
 #include "MobileMessageService.h"
 #include "SmsSegmentInfo.h"
 #include "jsapi.h"
 
 namespace mozilla {
 namespace dom {
 namespace mobilemessage {
 
@@ -93,11 +94,29 @@ MobileMessageService::CreateSmsSegmentIn
                                            nsIDOMMozSmsSegmentInfo** aSegmentInfo)
 {
   nsCOMPtr<nsIDOMMozSmsSegmentInfo> info =
       new SmsSegmentInfo(aSegments, aCharsPerSegment, aCharsAvailableInLastSegment);
   info.forget(aSegmentInfo);
   return NS_OK;
 }
 
+NS_IMETHODIMP
+MobileMessageService::CreateThread(uint64_t aId,
+                                   const JS::Value& aParticipants,
+                                   const JS::Value& aTimestamp,
+                                   const nsAString& aBody,
+                                   uint64_t aUnreadCount,
+                                   JSContext* aCx,
+                                   nsIDOMMozMobileMessageThread** aThread)
+{
+  return MobileMessageThread::Create(aId,
+                                     aParticipants,
+                                     aTimestamp,
+                                     aBody,
+                                     aUnreadCount,
+                                     aCx,
+                                     aThread);
+}
+
 } // namespace mobilemessage
 } // namespace dom
 } // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/dom/mobilemessage/src/MobileMessageThread.cpp
@@ -0,0 +1,161 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "MobileMessageThread.h"
+#include "nsIDOMClassInfo.h"
+#include "jsapi.h"           // For OBJECT_TO_JSVAL and JS_NewDateObjectMsec
+#include "jsfriendapi.h"     // For js_DateGetMsecSinceEpoch
+#include "nsJSUtils.h"       // For nsDependentJSString
+#include "nsContentUtils.h"  // For nsTArrayHelpers.h
+#include "nsTArrayHelpers.h" // For nsTArrayToJSArray
+
+using namespace mozilla::dom::mobilemessage;
+
+DOMCI_DATA(MozMobileMessageThread, mozilla::dom::MobileMessageThread)
+
+namespace mozilla {
+namespace dom {
+
+NS_INTERFACE_MAP_BEGIN(MobileMessageThread)
+  NS_INTERFACE_MAP_ENTRY(nsIDOMMozMobileMessageThread)
+  NS_INTERFACE_MAP_ENTRY(nsISupports)
+  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozMobileMessageThread)
+NS_INTERFACE_MAP_END
+
+NS_IMPL_ADDREF(MobileMessageThread)
+NS_IMPL_RELEASE(MobileMessageThread)
+
+/* static */ nsresult
+MobileMessageThread::Create(const uint64_t aId,
+                            const JS::Value& aParticipants,
+                            const JS::Value& aTimestamp,
+                            const nsAString& aBody,
+                            const uint64_t aUnreadCount,
+                            JSContext* aCx,
+                            nsIDOMMozMobileMessageThread** aThread)
+{
+  *aThread = nullptr;
+
+  // ThreadData exposes these as references, so we can simply assign
+  // to them.
+  ThreadData data;
+  data.id() = aId;
+  data.body().Assign(aBody);
+  data.unreadCount() = aUnreadCount;
+
+  // Participants.
+  {
+    if (!aParticipants.isObject()) {
+      return NS_ERROR_INVALID_ARG;
+    }
+
+    JSObject* obj = &aParticipants.toObject();
+    if (!JS_IsArrayObject(aCx, obj)) {
+      return NS_ERROR_INVALID_ARG;
+    }
+
+    uint32_t length;
+    JS_ALWAYS_TRUE(JS_GetArrayLength(aCx, obj, &length));
+    NS_ENSURE_TRUE(length, NS_ERROR_INVALID_ARG);
+
+    for (uint32_t i = 0; i < length; ++i) {
+      JS::Value val;
+
+      if (!JS_GetElement(aCx, obj, i, &val) || !val.isString()) {
+        return NS_ERROR_INVALID_ARG;
+      }
+
+      nsDependentJSString str;
+      str.init(aCx, val.toString());
+      data.participants().AppendElement(str);
+    }
+  }
+
+  // We support both a Date object and a millisecond timestamp as a number.
+  if (aTimestamp.isObject()) {
+    JSObject& obj = aTimestamp.toObject();
+    if (!JS_ObjectIsDate(aCx, &obj)) {
+      return NS_ERROR_INVALID_ARG;
+    }
+    data.timestamp() = js_DateGetMsecSinceEpoch(&obj);
+  } else {
+    if (!aTimestamp.isNumber()) {
+      return NS_ERROR_INVALID_ARG;
+    }
+    double number = aTimestamp.toNumber();
+    if (static_cast<uint64_t>(number) != number) {
+      return NS_ERROR_INVALID_ARG;
+    }
+    data.timestamp() = static_cast<uint64_t>(number);
+  }
+
+  nsCOMPtr<nsIDOMMozMobileMessageThread> thread = new MobileMessageThread(data);
+  thread.forget(aThread);
+  return NS_OK;
+}
+
+MobileMessageThread::MobileMessageThread(const uint64_t aId,
+                                         const nsTArray<nsString>& aParticipants,
+                                         const uint64_t aTimestamp,
+                                         const nsString& aBody,
+                                         const uint64_t aUnreadCount)
+  : mData(aId, aParticipants, aTimestamp, aBody, aUnreadCount)
+{
+  MOZ_ASSERT(aParticipants.Length());
+}
+
+MobileMessageThread::MobileMessageThread(const ThreadData& aData)
+  : mData(aData)
+{
+  MOZ_ASSERT(aData.participants().Length());
+}
+
+NS_IMETHODIMP
+MobileMessageThread::GetId(uint64_t* aId)
+{
+  *aId = mData.id();
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+MobileMessageThread::GetBody(nsAString& aBody)
+{
+  aBody = mData.body();
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+MobileMessageThread::GetUnreadCount(uint64_t* aUnreadCount)
+{
+  *aUnreadCount = mData.unreadCount();
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+MobileMessageThread::GetParticipants(JSContext* aCx,
+                                     JS::Value* aParticipants)
+{
+  JSObject* obj;
+
+  nsresult rv = nsTArrayToJSArray(aCx, mData.participants(), &obj);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  aParticipants->setObject(*obj);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+MobileMessageThread::GetTimestamp(JSContext* aCx,
+                                  JS::Value* aDate)
+{
+  JSObject *obj = JS_NewDateObjectMsec(aCx, mData.timestamp());
+  NS_ENSURE_TRUE(obj, NS_ERROR_FAILURE);
+
+  *aDate = OBJECT_TO_JSVAL(obj);
+  return NS_OK;
+}
+
+} // namespace dom
+} // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/dom/mobilemessage/src/MobileMessageThread.h
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_dom_mobilemessage_MobileMessageThread_h
+#define mozilla_dom_mobilemessage_MobileMessageThread_h
+
+#include "mozilla/Attributes.h"
+#include "mozilla/dom/mobilemessage/SmsTypes.h"
+#include "nsIDOMMozMobileMessageThread.h"
+#include "nsString.h"
+#include "jspubtd.h"
+
+namespace mozilla {
+namespace dom {
+
+class MobileMessageThread MOZ_FINAL : public nsIDOMMozMobileMessageThread
+{
+private:
+  typedef mobilemessage::ThreadData ThreadData;
+
+public:
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSIDOMMOZMOBILEMESSAGETHREAD
+
+  MobileMessageThread(const uint64_t aId,
+                      const nsTArray<nsString>& aParticipants,
+                      const uint64_t aTimestamp,
+                      const nsString& aBody,
+                      const uint64_t aUnreadCount);
+
+  MobileMessageThread(const ThreadData& aData);
+
+  static nsresult Create(const uint64_t aId,
+                         const JS::Value& aParticipants,
+                         const JS::Value& aTimestamp,
+                         const nsAString& aBody,
+                         const uint64_t aUnreadCount,
+                         JSContext* aCx,
+                         nsIDOMMozMobileMessageThread** aThread);
+
+  const ThreadData& GetData() const { return mData; }
+
+private:
+  // Don't try to use the default constructor.
+  MobileMessageThread() MOZ_DELETE;
+
+  ThreadData mData;
+};
+
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_mobilemessage_MobileMessageThread_h
--- a/dom/mobilemessage/src/SmsManager.cpp
+++ b/dom/mobilemessage/src/SmsManager.cpp
@@ -309,26 +309,33 @@ SmsManager::MarkMessageRead(int32_t aId,
   nsCOMPtr<nsIMobileMessageCallback> forwarder =
     new SmsRequestForwarder(static_cast<SmsRequest*>(req.get()));
   mobileMessageDBService->MarkMessageRead(aId, aValue, forwarder);
   req.forget(aRequest);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-SmsManager::GetThreadList(nsIDOMMozSmsRequest** aRequest)
+SmsManager::GetThreads(nsIDOMDOMCursor** aCursor)
 {
-  nsCOMPtr<nsIDOMMozSmsRequest> req = SmsRequest::Create(this);
-  nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService =
+  nsCOMPtr<nsIMobileMessageDatabaseService> dbService =
     do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
-  NS_ENSURE_TRUE(mobileMessageDBService, NS_ERROR_FAILURE);
-  nsCOMPtr<nsIMobileMessageCallback> forwarder =
-    new SmsRequestForwarder(static_cast<SmsRequest*>(req.get()));
-  mobileMessageDBService->GetThreadList(forwarder);
-  req.forget(aRequest);
+  NS_ENSURE_TRUE(dbService, NS_ERROR_FAILURE);
+
+  nsRefPtr<MobileMessageCursorCallback> cursorCallback =
+    new MobileMessageCursorCallback();
+
+  nsCOMPtr<nsICursorContinueCallback> continueCallback;
+  nsresult rv = dbService->CreateThreadCursor(cursorCallback,
+                                              getter_AddRefs(continueCallback));
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  cursorCallback->mDOMCursor = new DOMCursor(GetOwner(), continueCallback);
+  NS_ADDREF(*aCursor = cursorCallback->mDOMCursor);
+
   return NS_OK;
 }
 
 nsresult
 SmsManager::DispatchTrustedSmsEventToSelf(const nsAString& aEventName, nsIDOMMozSmsMessage* aMessage)
 {
   nsCOMPtr<nsIDOMEvent> event;
   NS_NewDOMMozSmsEvent(getter_AddRefs(event), this, nullptr, nullptr);
--- a/dom/mobilemessage/src/SmsMessage.cpp
+++ b/dom/mobilemessage/src/SmsMessage.cpp
@@ -256,17 +256,20 @@ SmsMessage::GetMessageClass(nsAString& a
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 SmsMessage::GetTimestamp(JSContext* cx, JS::Value* aDate)
 {
-  *aDate = OBJECT_TO_JSVAL(JS_NewDateObjectMsec(cx, mData.timestamp()));
+  JSObject *obj = JS_NewDateObjectMsec(cx, mData.timestamp());
+  NS_ENSURE_TRUE(obj, NS_ERROR_FAILURE);
+
+  *aDate = OBJECT_TO_JSVAL(obj);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 SmsMessage::GetRead(bool* aRead)
 {
   *aRead = mData.read();
   return NS_OK;
--- a/dom/mobilemessage/src/SmsRequest.cpp
+++ b/dom/mobilemessage/src/SmsRequest.cpp
@@ -382,144 +382,10 @@ NS_IMETHODIMP
 SmsRequest::NotifyMarkMessageReadFailed(int32_t aError)
 {
   if (mParent) {
     return SendMessageReply(MessageReply(ReplyMarkeMessageReadFail(aError)));
   }
   return NotifyError(aError);
 }
 
-NS_IMETHODIMP
-SmsRequest::NotifyThreadList(const JS::Value& aThreadList, JSContext* aCx)
-{
-  MOZ_ASSERT(aThreadList.isObject());
-
-  if (mParent) {
-    JSObject* array = const_cast<JSObject*>(&aThreadList.toObject());
-
-    uint32_t length;
-    bool ok = JS_GetArrayLength(aCx, array, &length);
-    NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
-
-    ReplyThreadList reply;
-    InfallibleTArray<ThreadListItem>& ipcItems = reply.items();
-
-    if (length) {
-      ipcItems.SetCapacity(length);
-
-      for (uint32_t i = 0; i < length; i++) {
-        JS::Value arrayEntry;
-        ok = JS_GetElement(aCx, array, i, &arrayEntry);
-        NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
-
-        MOZ_ASSERT(arrayEntry.isObject());
-
-        mozilla::idl::SmsThreadListItem item;
-        nsresult rv = item.Init(aCx, &arrayEntry);
-        NS_ENSURE_SUCCESS(rv, rv);
-
-        ThreadListItem* ipcItem = ipcItems.AppendElement();
-        ipcItem->id() = item.id;
-        ipcItem->senderOrReceiver() = item.senderOrReceiver;
-        ipcItem->timestamp() = item.timestamp;
-        ipcItem->body() = item.body;
-        ipcItem->unreadCount() = item.unreadCount;
-      }
-    }
-
-    return SendMessageReply(reply);
-  }
-
-  return NotifySuccess(aThreadList);
-}
-
-NS_IMETHODIMP
-SmsRequest::NotifyThreadListFailed(int32_t aError)
-{
-  if (mParent) {
-    return SendMessageReply(MessageReply(ReplyThreadListFail(aError)));
-  }
-  return NotifyError(aError);
-}
-
-void
-SmsRequest::NotifyThreadList(const InfallibleTArray<ThreadListItem>& aItems)
-{
-  MOZ_ASSERT(!mParent);
-  MOZ_ASSERT(GetOwner());
-
-  nsresult rv;
-  nsIScriptContext* sc = GetContextForEventHandlers(&rv);
-  NS_ENSURE_SUCCESS_VOID(rv);
-  NS_ENSURE_TRUE_VOID(sc);
-
-  AutoPushJSContext cx(sc->GetNativeContext());
-  MOZ_ASSERT(cx);
-
-  nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(GetOwner());
-
-  JSObject* ownerObj = sgo->GetGlobalJSObject();
-  NS_ENSURE_TRUE_VOID(ownerObj);
-
-  nsCxPusher pusher;
-  pusher.Push(cx);
-
-  JSAutoRequest ar(cx);
-  JSAutoCompartment ac(cx, ownerObj);
-
-  JSObject* array = JS_NewArrayObject(cx, aItems.Length(), nullptr);
-  NS_ENSURE_TRUE_VOID(array);
-
-  bool ok;
-
-  for (uint32_t i = 0; i < aItems.Length(); i++) {
-    const ThreadListItem& source = aItems[i];
-
-    JS::Value id = JS_NumberValue(double(source.id()));
-
-    nsString temp = source.senderOrReceiver();
-
-    JS::Value senderOrReceiver;
-    ok = xpc::StringToJsval(cx, temp, &senderOrReceiver);
-    NS_ENSURE_TRUE_VOID(ok);
-
-    JSObject* timestampObj = JS_NewDateObjectMsec(cx, source.timestamp());
-    NS_ENSURE_TRUE_VOID(timestampObj);
-
-    JS::Value timestamp = OBJECT_TO_JSVAL(timestampObj);
-
-    temp = source.body();
-
-    JS::Value body;
-    ok = xpc::StringToJsval(cx, temp, &body);
-    NS_ENSURE_TRUE_VOID(ok);
-
-    JS::Value unreadCount = JS_NumberValue(double(source.unreadCount()));
-
-    JSObject* elementObj = JS_NewObject(cx, nullptr, nullptr, nullptr);
-    NS_ENSURE_TRUE_VOID(elementObj);
-
-    ok = JS_SetProperty(cx, elementObj, "id", &id);
-    NS_ENSURE_TRUE_VOID(ok);
-
-    ok = JS_SetProperty(cx, elementObj, "senderOrReceiver", &senderOrReceiver);
-    NS_ENSURE_TRUE_VOID(ok);
-
-    ok = JS_SetProperty(cx, elementObj, "timestamp", &timestamp);
-    NS_ENSURE_TRUE_VOID(ok);
-
-    ok = JS_SetProperty(cx, elementObj, "body", &body);
-    NS_ENSURE_TRUE_VOID(ok);
-
-    ok = JS_SetProperty(cx, elementObj, "unreadCount", &unreadCount);
-    NS_ENSURE_TRUE_VOID(ok);
-
-    JS::Value element = OBJECT_TO_JSVAL(elementObj);
-
-    ok = JS_SetElement(cx, array, i, &element);
-    NS_ENSURE_TRUE_VOID(ok);
-  }
-
-  NotifyThreadList(OBJECT_TO_JSVAL(array), cx);
-}
-
 } // namespace dom
 } // namespace mozilla
--- a/dom/mobilemessage/src/android/MobileMessageDatabaseService.cpp
+++ b/dom/mobilemessage/src/android/MobileMessageDatabaseService.cpp
@@ -51,17 +51,18 @@ MobileMessageDatabaseService::MarkMessag
                                               bool aValue,
                                               nsIMobileMessageCallback* aRequest)
 {
   // TODO: This would need to be implemented as part of Bug 748391
   return NS_OK;
 }
 
 NS_IMETHODIMP
-MobileMessageDatabaseService::GetThreadList(nsIMobileMessageCallback* aRequest)
+MobileMessageDatabaseService::CreateThreadCursor(nsIMobileMessageCursorCallback* aCallback,
+                                                 nsICursorContinueCallback** aResult)
 {
   NS_NOTYETIMPLEMENTED("Implement me!");
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 } // namespace mobilemessage
 } // namespace dom
 } // namespace mozilla
--- a/dom/mobilemessage/src/fallback/MobileMessageDatabaseService.cpp
+++ b/dom/mobilemessage/src/fallback/MobileMessageDatabaseService.cpp
@@ -42,17 +42,18 @@ MobileMessageDatabaseService::MarkMessag
                                               bool aValue,
                                               nsIMobileMessageCallback* aRequest)
 {
   NS_ERROR("We should not be here!");
   return NS_OK;
 }
 
 NS_IMETHODIMP
-MobileMessageDatabaseService::GetThreadList(nsIMobileMessageCallback* aRequest)
+MobileMessageDatabaseService::CreateThreadCursor(nsIMobileMessageCursorCallback* aCallback,
+                                                 nsICursorContinueCallback** aResult)
 {
   NS_ERROR("We should not be here!");
   return NS_OK;
 }
 
 } // namespace mobilemessage
 } // namespace dom
 } // namespace mozilla
--- a/dom/tests/mochitest/general/test_interfaces.html
+++ b/dom/tests/mochitest/general/test_interfaces.html
@@ -544,17 +544,18 @@ var interfaceNamesInGlobalScope =
     "GamepadEvent",
     "GamepadButtonEvent",
     "GamepadAxisMoveEvent",
     "SpeechRecognitionEvent",
     "SpeechRecognitionError",
     "SpeechSynthesisEvent",
     "PushManager",
     "StyleSheetAddedEvent",
-    "StyleSheetRemovedEvent"
+    "StyleSheetRemovedEvent",
+    "MozMobileMessageThread",
   ]
 
 for (var i in SpecialPowers.Components.interfaces) {
   var s = i.toString();
   var name = null;
   if (s.indexOf("nsIDOM") == 0) {
     name = s.substring("nsIDOM".length);
   } else if (s.indexOf("nsI") == 0) {