Bug 958782 - 2.b/3: WebIDL implementation. f=Ms2ger,bzbarsky,bz,r=khuey
☠☠ backed out by ed17e0fa0487 ☠ ☠
authorVicamo Yang <vyang@mozilla.com>
Mon, 23 Jun 2014 20:55:58 +0800
changeset 190188 731f37afb6498ae303de3276476aaaa07230b640
parent 190187 15a281081b971ecd72584f70dc58f56c89018b36
child 190189 f06d2ba57fb31d33f7e51ee4f13147aa0fb28b6c
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewerskhuey
bugs958782
milestone33.0a1
Bug 958782 - 2.b/3: WebIDL implementation. f=Ms2ger,bzbarsky,bz,r=khuey
dom/base/Navigator.cpp
dom/base/Navigator.h
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMClassInfoClasses.h
dom/mobileconnection/src/MobileConnection.cpp
dom/mobilemessage/src/MmsMessage.h
dom/mobilemessage/src/MobileMessageManager.cpp
dom/mobilemessage/src/MobileMessageManager.h
dom/mobilemessage/src/ipc/SmsIPCService.cpp
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -1553,26 +1553,26 @@ Navigator::RequestWakeLock(const nsAStri
   if (!pmService) {
     aRv.Throw(NS_ERROR_UNEXPECTED);
     return nullptr;
   }
 
   return pmService->NewWakeLock(aTopic, mWindow, aRv);
 }
 
-nsIDOMMozMobileMessageManager*
+MobileMessageManager*
 Navigator::GetMozMobileMessage()
 {
   if (!mMobileMessageManager) {
     // Check that our window has not gone away
     NS_ENSURE_TRUE(mWindow, nullptr);
     NS_ENSURE_TRUE(mWindow->GetDocShell(), nullptr);
 
-    mMobileMessageManager = new MobileMessageManager();
-    mMobileMessageManager->Init(mWindow);
+    mMobileMessageManager = new MobileMessageManager(mWindow);
+    mMobileMessageManager->Init();
   }
 
   return mMobileMessageManager;
 }
 
 Telephony*
 Navigator::GetMozTelephony(ErrorResult& aRv)
 {
--- a/dom/base/Navigator.h
+++ b/dom/base/Navigator.h
@@ -17,17 +17,16 @@
 #include "nsHashKeys.h"
 #include "nsInterfaceHashtable.h"
 #include "nsString.h"
 #include "nsTArray.h"
 
 class nsPluginArray;
 class nsMimeTypeArray;
 class nsPIDOMWindow;
-class nsIDOMMozMobileMessageManager;
 class nsIDOMNavigatorSystemMessages;
 class nsDOMCameraManager;
 class nsDOMDeviceStorage;
 class nsIDOMBlob;
 class nsIPrincipal;
 
 namespace mozilla {
 namespace dom {
@@ -202,17 +201,17 @@ public:
   nsDOMDeviceStorage* GetDeviceStorage(const nsAString& aType,
                                        ErrorResult& aRv);
   void GetDeviceStorages(const nsAString& aType,
                          nsTArray<nsRefPtr<nsDOMDeviceStorage> >& aStores,
                          ErrorResult& aRv);
   DesktopNotificationCenter* GetMozNotification(ErrorResult& aRv);
   bool MozIsLocallyAvailable(const nsAString& aURI, bool aWhenOffline,
                              ErrorResult& aRv);
-  nsIDOMMozMobileMessageManager* GetMozMobileMessage();
+  MobileMessageManager* GetMozMobileMessage();
   Telephony* GetMozTelephony(ErrorResult& aRv);
   network::Connection* GetConnection(ErrorResult& aRv);
   nsDOMCameraManager* GetMozCameras(ErrorResult& aRv);
   void MozSetMessageHandler(const nsAString& aType,
                             systemMessageCallback* aCallback,
                             ErrorResult& aRv);
   bool MozHasPendingMessage(const nsAString& aType, ErrorResult& aRv);
 #ifdef MOZ_B2G
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -127,17 +127,16 @@
 #include "nsIEventListenerService.h"
 #include "nsIMessageManager.h"
 
 #include "mozilla/dom/TouchEvent.h"
 
 #include "nsWrapperCacheInlines.h"
 #include "mozilla/dom/HTMLCollectionBinding.h"
 
-#include "nsIDOMMobileMessageManager.h"
 #include "nsIDOMMozSmsMessage.h"
 #include "nsIDOMMozMmsMessage.h"
 #include "nsIDOMSmsFilter.h"
 #include "nsIDOMSmsSegmentInfo.h"
 #include "nsIDOMMozMobileMessageThread.h"
 
 #ifdef MOZ_B2G_FM
 #include "FMRadio.h"
@@ -372,19 +371,16 @@ static nsDOMClassInfoData sClassInfoData
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(File, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
   NS_DEFINE_CLASSINFO_DATA(ModalContentWindow, nsWindowSH,
                            DEFAULT_SCRIPTABLE_FLAGS |
                            WINDOW_SCRIPTABLE_FLAGS)
 
-  NS_DEFINE_CLASSINFO_DATA(MozMobileMessageManager, nsDOMGenericSH,
-                           DOM_DEFAULT_SCRIPTABLE_FLAGS)
-
   NS_DEFINE_CLASSINFO_DATA(MozSmsMessage, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
   NS_DEFINE_CLASSINFO_DATA(MozMmsMessage, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
   NS_DEFINE_CLASSINFO_DATA(MozSmsFilter, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
@@ -978,20 +974,16 @@ nsDOMClassInfo::Init()
   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ModalContentWindow, nsIDOMWindow)
     DOM_CLASSINFO_WINDOW_MAP_ENTRIES
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMModalContentWindow)
 #ifdef MOZ_WEBSPEECH
     DOM_CLASSINFO_MAP_ENTRY(nsISpeechSynthesisGetter)
 #endif
   DOM_CLASSINFO_MAP_END
 
-  DOM_CLASSINFO_MAP_BEGIN(MozMobileMessageManager, nsIDOMMozMobileMessageManager)
-     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozMobileMessageManager)
-  DOM_CLASSINFO_MAP_END
-
   DOM_CLASSINFO_MAP_BEGIN(MozSmsMessage, nsIDOMMozSmsMessage)
      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozSmsMessage)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(MozMmsMessage, nsIDOMMozMmsMessage)
      DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozMmsMessage)
   DOM_CLASSINFO_MAP_END
 
--- a/dom/base/nsDOMClassInfoClasses.h
+++ b/dom/base/nsDOMClassInfoClasses.h
@@ -54,17 +54,16 @@ DOMCI_CLASS(XPathResult)
 DOMCI_CLASS(Storage)
 
 DOMCI_CLASS(Blob)
 DOMCI_CLASS(File)
 
 // DOM modal content window class, almost identical to Window
 DOMCI_CLASS(ModalContentWindow)
 
-DOMCI_CLASS(MozMobileMessageManager)
 DOMCI_CLASS(MozSmsMessage)
 DOMCI_CLASS(MozMmsMessage)
 DOMCI_CLASS(MozSmsFilter)
 DOMCI_CLASS(MozSmsSegmentInfo)
 DOMCI_CLASS(MozMobileMessageThread)
 
 // @font-face in CSS
 DOMCI_CLASS(CSSFontFaceRule)
--- a/dom/mobileconnection/src/MobileConnection.cpp
+++ b/dom/mobileconnection/src/MobileConnection.cpp
@@ -599,17 +599,23 @@ MobileConnection::SetCallForwardingOptio
     return nullptr;
   }
 
   if (!mProvider) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
-  AutoSafeJSContext cx;
+  AutoJSAPI jsapi;
+  if (!NS_WARN_IF(jsapi.InitUsingWin(GetOwner()))) {
+    aRv.Throw(NS_ERROR_FAILURE);
+    return nullptr;
+  }
+
+  JSContext *cx = jsapi.cx();
   JS::Rooted<JS::Value> options(cx);
   if (!ToJSValue(cx, aOptions, &options)) {
     aRv.Throw(NS_ERROR_TYPE_ERR);
     return nullptr;
   }
 
   nsCOMPtr<nsIDOMDOMRequest> request;
   nsresult rv = mProvider->SetCallForwarding(mClientId, GetOwner(), options,
@@ -630,17 +636,23 @@ MobileConnection::GetCallBarringOption(c
     return nullptr;
   }
 
   if (!mProvider) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
-  AutoSafeJSContext cx;
+  AutoJSAPI jsapi;
+  if (!NS_WARN_IF(jsapi.InitUsingWin(GetOwner()))) {
+    aRv.Throw(NS_ERROR_FAILURE);
+    return nullptr;
+  }
+
+  JSContext *cx = jsapi.cx();
   JS::Rooted<JS::Value> options(cx);
   if (!ToJSValue(cx, aOptions, &options)) {
     aRv.Throw(NS_ERROR_TYPE_ERR);
     return nullptr;
   }
 
   nsCOMPtr<nsIDOMDOMRequest> request;
   nsresult rv = mProvider->GetCallBarring(mClientId, GetOwner(), options,
@@ -661,17 +673,23 @@ MobileConnection::SetCallBarringOption(c
     return nullptr;
   }
 
   if (!mProvider) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
-  AutoSafeJSContext cx;
+  AutoJSAPI jsapi;
+  if (!NS_WARN_IF(jsapi.InitUsingWin(GetOwner()))) {
+    aRv.Throw(NS_ERROR_FAILURE);
+    return nullptr;
+  }
+
+  JSContext *cx = jsapi.cx();
   JS::Rooted<JS::Value> options(cx);
   if (!ToJSValue(cx, aOptions, &options)) {
     aRv.Throw(NS_ERROR_TYPE_ERR);
     return nullptr;
   }
 
   nsCOMPtr<nsIDOMDOMRequest> request;
   nsresult rv = mProvider->SetCallBarring(mClientId, GetOwner(), options,
@@ -692,17 +710,23 @@ MobileConnection::ChangeCallBarringPassw
     return nullptr;
   }
 
   if (!mProvider) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
-  AutoSafeJSContext cx;
+  AutoJSAPI jsapi;
+  if (!NS_WARN_IF(jsapi.InitUsingWin(GetOwner()))) {
+    aRv.Throw(NS_ERROR_FAILURE);
+    return nullptr;
+  }
+
+  JSContext *cx = jsapi.cx();
   JS::Rooted<JS::Value> options(cx);
   if (!ToJSValue(cx, aOptions, &options)) {
     aRv.Throw(NS_ERROR_TYPE_ERR);
     return nullptr;
   }
 
   nsCOMPtr<nsIDOMDOMRequest> request;
   nsresult rv = mProvider->ChangeCallBarringPassword(mClientId,
--- a/dom/mobilemessage/src/MmsMessage.h
+++ b/dom/mobilemessage/src/MmsMessage.h
@@ -5,16 +5,17 @@
 
 #ifndef mozilla_dom_mobilemessage_MmsMessage_h
 #define mozilla_dom_mobilemessage_MmsMessage_h
 
 #include "nsIDOMMozMmsMessage.h"
 #include "nsString.h"
 #include "mozilla/dom/mobilemessage/Types.h"
 #include "mozilla/dom/MozMmsMessageBinding.h"
+#include "mozilla/dom/MozMobileMessageManagerBinding.h"
 #include "mozilla/Attributes.h"
 
 namespace mozilla {
 namespace dom {
 
 namespace mobilemessage {
 class MmsMessageData;
 } // namespace mobilemessage
--- a/dom/mobilemessage/src/MobileMessageManager.cpp
+++ b/dom/mobilemessage/src/MobileMessageManager.cpp
@@ -7,20 +7,21 @@
 #include "MobileMessageManager.h"
 #include "nsIDOMClassInfo.h"
 #include "nsISmsService.h"
 #include "nsIMmsService.h"
 #include "nsIObserverService.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
 #include "mozilla/dom/mobilemessage/Constants.h" // For MessageType
-#include "mozilla/dom/MobileMessageManagerBinding.h"
 #include "mozilla/dom/MozMmsEvent.h"
 #include "mozilla/dom/MozMmsMessageBinding.h"
+#include "mozilla/dom/MozMobileMessageManagerBinding.h"
 #include "mozilla/dom/MozSmsEvent.h"
+#include "mozilla/dom/ToJSValue.h"
 #include "nsIDOMMozSmsMessage.h"
 #include "nsIDOMMozMmsMessage.h"
 #include "nsJSUtils.h"
 #include "nsContentUtils.h"
 #include "nsCxPusher.h"
 #include "nsIMobileMessageDatabaseService.h"
 #include "nsIXPConnect.h"
 #include "nsIPermissionManager.h"
@@ -38,45 +39,34 @@
 #define FAILED_EVENT_NAME           NS_LITERAL_STRING("failed")
 #define DELIVERY_SUCCESS_EVENT_NAME NS_LITERAL_STRING("deliverysuccess")
 #define DELIVERY_ERROR_EVENT_NAME   NS_LITERAL_STRING("deliveryerror")
 #define READ_SUCCESS_EVENT_NAME     NS_LITERAL_STRING("readsuccess")
 #define READ_ERROR_EVENT_NAME       NS_LITERAL_STRING("readerror")
 
 using namespace mozilla::dom::mobilemessage;
 
-DOMCI_DATA(MozMobileMessageManager, mozilla::dom::MobileMessageManager)
-
 namespace mozilla {
 namespace dom {
 
 NS_INTERFACE_MAP_BEGIN(MobileMessageManager)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMMozMobileMessageManager)
   NS_INTERFACE_MAP_ENTRY(nsIObserver)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozMobileMessageManager)
 NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
 
 NS_IMPL_ADDREF_INHERITED(MobileMessageManager, DOMEventTargetHelper)
 NS_IMPL_RELEASE_INHERITED(MobileMessageManager, DOMEventTargetHelper)
 
-NS_IMPL_EVENT_HANDLER(MobileMessageManager, received)
-NS_IMPL_EVENT_HANDLER(MobileMessageManager, retrieving)
-NS_IMPL_EVENT_HANDLER(MobileMessageManager, sending)
-NS_IMPL_EVENT_HANDLER(MobileMessageManager, sent)
-NS_IMPL_EVENT_HANDLER(MobileMessageManager, failed)
-NS_IMPL_EVENT_HANDLER(MobileMessageManager, deliverysuccess)
-NS_IMPL_EVENT_HANDLER(MobileMessageManager, deliveryerror)
-NS_IMPL_EVENT_HANDLER(MobileMessageManager, readsuccess)
-NS_IMPL_EVENT_HANDLER(MobileMessageManager, readerror)
+MobileMessageManager::MobileMessageManager(nsPIDOMWindow *aWindow)
+  : DOMEventTargetHelper(aWindow)
+{
+}
 
 void
-MobileMessageManager::Init(nsPIDOMWindow *aWindow)
+MobileMessageManager::Init()
 {
-  BindToOwner(aWindow);
-
   nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
   // GetObserverService() can return null is some situations like shutdown.
   if (!obs) {
     return;
   }
 
   obs->AddObserver(this, kSmsReceivedObserverTopic, false);
   obs->AddObserver(this, kSmsRetrievingObserverTopic, false);
@@ -104,382 +94,402 @@ MobileMessageManager::Shutdown()
   obs->RemoveObserver(this, kSmsSentObserverTopic);
   obs->RemoveObserver(this, kSmsFailedObserverTopic);
   obs->RemoveObserver(this, kSmsDeliverySuccessObserverTopic);
   obs->RemoveObserver(this, kSmsDeliveryErrorObserverTopic);
   obs->RemoveObserver(this, kSmsReadSuccessObserverTopic);
   obs->RemoveObserver(this, kSmsReadErrorObserverTopic);
 }
 
-NS_IMETHODIMP
+JSObject*
+MobileMessageManager::WrapObject(JSContext* aCx)
+{
+  return MozMobileMessageManagerBinding::Wrap(aCx, this);
+}
+
+already_AddRefed<DOMRequest>
 MobileMessageManager::GetSegmentInfoForText(const nsAString& aText,
-                                            nsIDOMDOMRequest** aRequest)
+                                            ErrorResult& aRv)
 {
   nsCOMPtr<nsISmsService> smsService = do_GetService(SMS_SERVICE_CONTRACTID);
-  NS_ENSURE_TRUE(smsService, NS_ERROR_FAILURE);
+  if (!smsService) {
+    aRv.Throw(NS_ERROR_FAILURE);
+    return nullptr;
+  }
 
   nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
   nsCOMPtr<nsIMobileMessageCallback> msgCallback =
     new MobileMessageCallback(request);
   nsresult rv = smsService->GetSegmentInfoForText(aText, msgCallback);
-  NS_ENSURE_SUCCESS(rv, rv);
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return nullptr;
+  }
 
-  request.forget(aRequest);
-  return NS_OK;
+  return request.forget();
 }
 
-nsresult
-MobileMessageManager::Send(JSContext* aCx,
-                           JS::Handle<JSObject*> aGlobal,
-                           nsISmsService* aSmsService,
+already_AddRefed<DOMRequest>
+MobileMessageManager::Send(nsISmsService* aSmsService,
                            uint32_t aServiceId,
-                           JS::Handle<JSString*> aNumber,
+                           const nsAString& aNumber,
                            const nsAString& aText,
-                           JS::MutableHandle<JS::Value> aRequest)
+                           ErrorResult& aRv)
 {
-  nsDependentJSString number;
-  number.init(aCx, aNumber);
-
   nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
   nsCOMPtr<nsIMobileMessageCallback> msgCallback =
     new MobileMessageCallback(request);
 
   // By default, we don't send silent messages via MobileMessageManager.
-  nsresult rv = aSmsService->Send(aServiceId, number, aText,
+  nsresult rv = aSmsService->Send(aServiceId, aNumber, aText,
                                   false, msgCallback);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  js::AssertSameCompartment(aCx, aGlobal);
-  rv = nsContentUtils::WrapNative(aCx,
-                                  static_cast<nsIDOMDOMRequest*>(request.get()),
-                                  aRequest);
   if (NS_FAILED(rv)) {
-    NS_ERROR("Failed to create the js value!");
-    return rv;
+    aRv.Throw(rv);
+    return nullptr;
   }
 
-  return NS_OK;
+  return request.forget();
 }
 
-NS_IMETHODIMP
-MobileMessageManager::Send(JS::Handle<JS::Value> aNumber,
+already_AddRefed<DOMRequest>
+MobileMessageManager::Send(const nsAString& aNumber,
                            const nsAString& aText,
-                           JS::Handle<JS::Value> aSendParams,
-                           JSContext* aCx,
-                           uint8_t aArgc,
-                           JS::MutableHandle<JS::Value> aReturn)
+                           const SmsSendParameters& aSendParams,
+                           ErrorResult& aRv)
 {
-  if (!aNumber.isString() && !JS_IsArrayObject(aCx, aNumber)) {
-    return NS_ERROR_INVALID_ARG;
+  nsCOMPtr<nsISmsService> smsService = do_GetService(SMS_SERVICE_CONTRACTID);
+  if (!smsService) {
+    aRv.Throw(NS_ERROR_FAILURE);
+    return nullptr;
   }
 
-  nsresult rv;
-  nsIScriptContext* sc = GetContextForEventHandlers(&rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-  NS_ENSURE_STATE(sc);
-
-  JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
-
-  mozilla::Maybe<JSAutoCompartment> ac;
-  if (!global) {
-    global = sc->GetWindowProxy();
-    ac.construct(aCx, global);
-  }
-
-  nsCOMPtr<nsISmsService> smsService = do_GetService(SMS_SERVICE_CONTRACTID);
-  NS_ENSURE_TRUE(smsService, NS_ERROR_FAILURE);
-
   // Use the default one unless |aSendParams.serviceId| is available.
   uint32_t serviceId;
-  RootedDictionary<SmsSendParameters> sendParams(aCx);
-
-  if (aArgc >= 1) {
-    JS::Rooted<JS::Value> param(aCx, aSendParams);
-    if (!sendParams.Init(aCx, param)) {
-      return NS_ERROR_TYPE_ERR;
+  if (aSendParams.mServiceId.WasPassed()) {
+    serviceId = aSendParams.mServiceId.Value();
+  } else {
+    nsresult rv = smsService->GetSmsDefaultServiceId(&serviceId);
+    if (NS_FAILED(rv)) {
+      aRv.Throw(rv);
+      return nullptr;
     }
   }
 
-  if (sendParams.mServiceId.WasPassed()) {
-    serviceId = sendParams.mServiceId.Value();
-  } else {
-    rv = smsService->GetSmsDefaultServiceId(&serviceId);
-    NS_ENSURE_SUCCESS(rv, rv);
-  }
-
-  if (aNumber.isString()) {
-    JS::Rooted<JSString*> str(aCx, aNumber.toString());
-    return Send(aCx, global, smsService, serviceId, str, aText, aReturn);
-  }
-
-  // Must be an array then.
-  JS::Rooted<JSObject*> numbers(aCx, &aNumber.toObject());
-
-  uint32_t size;
-  if (!JS_GetArrayLength(aCx, numbers, &size)) {
-    return NS_ERROR_FAILURE;
-  }
-
-  JS::AutoValueVector requests(aCx);
-  if (!requests.resize(size)) {
-    return NS_ERROR_FAILURE;
-  }
-
-  JS::Rooted<JS::Value> number(aCx);
-  JS::Rooted<JSString*> str(aCx);
-  for (uint32_t i = 0; i < size; ++i) {
-    if (!JS_GetElement(aCx, numbers, i, &number)) {
-      return NS_ERROR_INVALID_ARG;
-    }
-
-    str = JS::ToString(aCx, number);
-    if (!str) {
-      return NS_ERROR_FAILURE;
-    }
-
-    nsresult rv = Send(aCx, global, smsService, serviceId, str, aText, requests[i]);
-    NS_ENSURE_SUCCESS(rv, rv);
-  }
-
-  JS::Rooted<JSObject*> obj(aCx);
-  obj = JS_NewArrayObject(aCx, requests);
-  if (!obj) {
-    return NS_ERROR_FAILURE;
-  }
-
-  aReturn.setObject(*obj);
-  return NS_OK;
+  return Send(smsService, serviceId, aNumber, aText, aRv);
 }
 
-NS_IMETHODIMP
-MobileMessageManager::SendMMS(JS::Handle<JS::Value> aParams,
-                              JS::Handle<JS::Value> aSendParams,
-                              JSContext* aCx,
-                              uint8_t aArgc,
-                              nsIDOMDOMRequest** aRequest)
+void
+MobileMessageManager::Send(const Sequence<nsString>& aNumbers,
+                           const nsAString& aText,
+                           const SmsSendParameters& aSendParams,
+                           nsTArray<nsRefPtr<DOMRequest>>& aReturn,
+                           ErrorResult& aRv)
 {
-  nsCOMPtr<nsIMmsService> mmsService = do_GetService(MMS_SERVICE_CONTRACTID);
-  NS_ENSURE_TRUE(mmsService, NS_ERROR_FAILURE);
+  nsCOMPtr<nsISmsService> smsService = do_GetService(SMS_SERVICE_CONTRACTID);
+  if (!smsService) {
+    aRv.Throw(NS_ERROR_FAILURE);
+    return;
+  }
 
   // Use the default one unless |aSendParams.serviceId| is available.
   uint32_t serviceId;
-  RootedDictionary<MmsSendParameters> sendParams(aCx);
-  nsresult rv;
-
-  if (aArgc >= 1) {
-    JS::Rooted<JS::Value> param(aCx, aSendParams);
-    if (!sendParams.Init(aCx, param)) {
-      return NS_ERROR_TYPE_ERR;
+  if (aSendParams.mServiceId.WasPassed()) {
+    serviceId = aSendParams.mServiceId.Value();
+  } else {
+    nsresult rv = smsService->GetSmsDefaultServiceId(&serviceId);
+    if (NS_FAILED(rv)) {
+      aRv.Throw(rv);
+      return;
     }
   }
 
-  if (sendParams.mServiceId.WasPassed()) {
-    serviceId = sendParams.mServiceId.Value();
+  const uint32_t size = aNumbers.Length();
+  for (uint32_t i = 0; i < size; ++i) {
+    nsRefPtr<DOMRequest> request = Send(smsService, serviceId, aNumbers[i], aText, aRv);
+    if (aRv.Failed()) {
+      return;
+    }
+    aReturn.AppendElement(request);
+  }
+}
+
+already_AddRefed<DOMRequest>
+MobileMessageManager::SendMMS(const MmsParameters& aParams,
+                              const MmsSendParameters& aSendParams,
+                              ErrorResult& aRv)
+{
+  nsCOMPtr<nsIMmsService> mmsService = do_GetService(MMS_SERVICE_CONTRACTID);
+  if (!mmsService) {
+    aRv.Throw(NS_ERROR_FAILURE);
+    return nullptr;
+  }
+
+  // Use the default one unless |aSendParams.serviceId| is available.
+  uint32_t serviceId;
+  nsresult rv;
+  if (aSendParams.mServiceId.WasPassed()) {
+    serviceId = aSendParams.mServiceId.Value();
   } else {
     rv = mmsService->GetMmsDefaultServiceId(&serviceId);
-    NS_ENSURE_SUCCESS(rv, rv);
+    if (NS_FAILED(rv)) {
+      aRv.Throw(rv);
+      return nullptr;
+    }
+  }
+
+  AutoJSAPI jsapi;
+  if (!NS_WARN_IF(jsapi.InitUsingWin(GetOwner()))) {
+    aRv.Throw(NS_ERROR_FAILURE);
+    return nullptr;
+  }
+
+  JSContext *cx = jsapi.cx();
+  JS::Rooted<JS::Value> val(cx);
+  if (!ToJSValue(cx, aParams, &val)) {
+    aRv.Throw(NS_ERROR_TYPE_ERR);
+    return nullptr;
   }
 
   nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
   nsCOMPtr<nsIMobileMessageCallback> msgCallback = new MobileMessageCallback(request);
-  rv = mmsService->Send(serviceId, aParams, msgCallback);
-  NS_ENSURE_SUCCESS(rv, rv);
+  rv = mmsService->Send(serviceId, val, msgCallback);
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return nullptr;
+  }
 
-  request.forget(aRequest);
-  return NS_OK;
+  return request.forget();
 }
 
-NS_IMETHODIMP
-MobileMessageManager::GetMessageMoz(int32_t aId,
-                                    nsIDOMDOMRequest** aRequest)
+already_AddRefed<DOMRequest>
+MobileMessageManager::GetMessage(int32_t aId,
+                                 ErrorResult& aRv)
 {
   nsCOMPtr<nsIMobileMessageDatabaseService> dbService =
     do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
-  NS_ENSURE_TRUE(dbService, NS_ERROR_FAILURE);
+  if (!dbService) {
+    aRv.Throw(NS_ERROR_FAILURE);
+    return nullptr;
+  }
 
   nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
   nsCOMPtr<nsIMobileMessageCallback> msgCallback = new MobileMessageCallback(request);
   nsresult rv = dbService->GetMessageMoz(aId, msgCallback);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  request.forget(aRequest);
-  return NS_OK;
-}
-
-nsresult
-MobileMessageManager::GetMessageId(JSContext* aCx,
-                                   const JS::Value& aMessage, int32_t* aId)
-{
-  nsCOMPtr<nsIDOMMozSmsMessage> smsMessage =
-    do_QueryInterface(nsContentUtils::XPConnect()->GetNativeOfWrapper(aCx, &aMessage.toObject()));
-  if (smsMessage) {
-    return smsMessage->GetId(aId);
-  }
-
-  nsCOMPtr<nsIDOMMozMmsMessage> mmsMessage =
-    do_QueryInterface(nsContentUtils::XPConnect()->GetNativeOfWrapper(aCx, &aMessage.toObject()));
-  if (mmsMessage) {
-    return mmsMessage->GetId(aId);
-  }
-
-  return NS_ERROR_INVALID_ARG;
-}
-
-NS_IMETHODIMP
-MobileMessageManager::Delete(JS::Handle<JS::Value> aParam,
-                             JSContext* aCx,
-                             nsIDOMDOMRequest** aRequest)
-{
-  // We expect Int32, SmsMessage, MmsMessage, Int32[], SmsMessage[], MmsMessage[]
-  if (!aParam.isObject() && !aParam.isInt32()) {
-    return NS_ERROR_INVALID_ARG;
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return nullptr;
   }
 
-  nsresult rv = NS_OK;
-  int32_t id, *idArray;
-  uint32_t size;
-
-  if (aParam.isInt32()) {
-    // Single Integer Message ID
-    id = aParam.toInt32();
-
-    size = 1;
-    idArray = &id;
-  } else if (!JS_IsArrayObject(aCx, aParam)) {
-    // Single SmsMessage/MmsMessage object
-    rv = GetMessageId(aCx, aParam, &id);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    size = 1;
-    idArray = &id;
-  } else {
-    // Int32[], SmsMessage[], or MmsMessage[]
-    JS::Rooted<JSObject*> ids(aCx, &aParam.toObject());
+  return request.forget();
+}
 
-    MOZ_ALWAYS_TRUE(JS_GetArrayLength(aCx, ids, &size));
-    nsAutoArrayPtr<int32_t> idAutoArray(new int32_t[size]);
-
-    JS::Rooted<JS::Value> idJsValue(aCx);
-    for (uint32_t i = 0; i < size; i++) {
-      if (!JS_GetElement(aCx, ids, i, &idJsValue)) {
-        return NS_ERROR_INVALID_ARG;
-      }
-
-      if (idJsValue.isInt32()) {
-        idAutoArray[i] = idJsValue.toInt32();
-      } else if (idJsValue.isObject()) {
-        rv = GetMessageId(aCx, idJsValue, &id);
-        NS_ENSURE_SUCCESS(rv, rv);
-
-        idAutoArray[i] = id;
-      }
-    }
-
-    idArray = idAutoArray.forget();
-  }
-
+already_AddRefed<DOMRequest>
+MobileMessageManager::Delete(int32_t* aIdArray,
+                             uint32_t aSize,
+                             ErrorResult& aRv)
+{
   nsCOMPtr<nsIMobileMessageDatabaseService> dbService =
     do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
-  NS_ENSURE_TRUE(dbService, NS_ERROR_FAILURE);
+  if (!dbService) {
+    aRv.Throw(NS_ERROR_FAILURE);
+    return nullptr;
+  }
 
   nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
   nsCOMPtr<nsIMobileMessageCallback> msgCallback =
     new MobileMessageCallback(request);
 
-  rv = dbService->DeleteMessage(idArray, size, msgCallback);
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsresult rv = dbService->DeleteMessage(aIdArray, aSize, msgCallback);
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return nullptr;
+  }
+
+  return request.forget();
+}
 
-  request.forget(aRequest);
-  return NS_OK;
+already_AddRefed<DOMRequest>
+MobileMessageManager::Delete(int32_t aId,
+                             ErrorResult& aRv)
+{
+  return Delete(&aId, 1, aRv);
+}
+
+already_AddRefed<DOMRequest>
+MobileMessageManager::Delete(nsIDOMMozSmsMessage* aMessage,
+                             ErrorResult& aRv)
+{
+  int32_t id;
+
+  DebugOnly<nsresult> rv = aMessage->GetId(&id);
+  MOZ_ASSERT(NS_SUCCEEDED(rv));
+
+  return Delete(id, aRv);
 }
 
-NS_IMETHODIMP
+already_AddRefed<DOMRequest>
+MobileMessageManager::Delete(nsIDOMMozMmsMessage* aMessage,
+                             ErrorResult& aRv)
+{
+  int32_t id;
+
+  DebugOnly<nsresult> rv = aMessage->GetId(&id);
+  MOZ_ASSERT(NS_SUCCEEDED(rv));
+
+  return Delete(id, aRv);
+}
+
+already_AddRefed<DOMRequest>
+MobileMessageManager::Delete(const Sequence<OwningLongOrMozSmsMessageOrMozMmsMessage>& aParams,
+                             ErrorResult& aRv)
+{
+  const uint32_t size = aParams.Length();
+  FallibleTArray<int32_t> idArray;
+  if (!idArray.SetLength(size)) {
+    aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
+    return nullptr;
+  }
+
+  DebugOnly<nsresult> rv;
+  for (uint32_t i = 0; i < size; i++) {
+    const OwningLongOrMozSmsMessageOrMozMmsMessage& element = aParams[i];
+    int32_t &id = idArray[i];
+
+    if (element.IsLong()) {
+      id = element.GetAsLong();
+    } else if (element.IsMozMmsMessage()) {
+      rv = element.GetAsMozMmsMessage()->GetId(&id);
+      MOZ_ASSERT(NS_SUCCEEDED(rv));
+    } else /*if (element.IsMozSmsMessage())*/ {
+      rv = element.GetAsMozSmsMessage()->GetId(&id);
+      MOZ_ASSERT(NS_SUCCEEDED(rv));
+    }
+  }
+
+  return Delete(idArray.Elements(), size, aRv);
+}
+
+already_AddRefed<DOMCursor>
 MobileMessageManager::GetMessages(nsIDOMMozSmsFilter* aFilter,
                                   bool aReverse,
-                                  nsIDOMDOMCursor** aCursor)
+                                  ErrorResult& aRv)
 {
   nsCOMPtr<nsIMobileMessageDatabaseService> dbService =
     do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
-  NS_ENSURE_TRUE(dbService, NS_ERROR_FAILURE);
+  if (!dbService) {
+    aRv.Throw(NS_ERROR_FAILURE);
+    return nullptr;
+  }
 
   nsCOMPtr<nsIDOMMozSmsFilter> filter = aFilter;
   if (!filter) {
     filter = new SmsFilter();
   }
 
   nsRefPtr<MobileMessageCursorCallback> cursorCallback =
     new MobileMessageCursorCallback();
 
   nsCOMPtr<nsICursorContinueCallback> continueCallback;
   nsresult rv = dbService->CreateMessageCursor(filter, aReverse, cursorCallback,
                                                getter_AddRefs(continueCallback));
-  NS_ENSURE_SUCCESS(rv, rv);
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return nullptr;
+  }
 
   cursorCallback->mDOMCursor = new DOMCursor(GetOwner(), continueCallback);
-  NS_ADDREF(*aCursor = cursorCallback->mDOMCursor);
 
-  return NS_OK;
+  nsRefPtr<DOMCursor> cursor = cursorCallback->mDOMCursor;
+  return cursor.forget();
 }
 
-NS_IMETHODIMP
+already_AddRefed<DOMRequest>
 MobileMessageManager::MarkMessageRead(int32_t aId,
                                       bool aValue,
                                       bool aSendReadReport,
-                                      nsIDOMDOMRequest** aRequest)
+                                      ErrorResult& aRv)
 {
   nsCOMPtr<nsIMobileMessageDatabaseService> dbService =
     do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
-  NS_ENSURE_TRUE(dbService, NS_ERROR_FAILURE);
+  if (!dbService) {
+    aRv.Throw(NS_ERROR_FAILURE);
+    return nullptr;
+  }
 
   nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
   nsCOMPtr<nsIMobileMessageCallback> msgCallback = new MobileMessageCallback(request);
   nsresult rv = dbService->MarkMessageRead(aId, aValue, aSendReadReport,
                                            msgCallback);
-  NS_ENSURE_SUCCESS(rv, rv);
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return nullptr;
+  }
 
-  request.forget(aRequest);
-  return NS_OK;
+  return request.forget();
 }
 
-NS_IMETHODIMP
-MobileMessageManager::GetThreads(nsIDOMDOMCursor** aCursor)
+already_AddRefed<DOMCursor>
+MobileMessageManager::GetThreads(ErrorResult& aRv)
 {
   nsCOMPtr<nsIMobileMessageDatabaseService> dbService =
     do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
-  NS_ENSURE_TRUE(dbService, NS_ERROR_FAILURE);
+  if (!dbService) {
+    aRv.Throw(NS_ERROR_FAILURE);
+    return nullptr;
+  }
 
   nsRefPtr<MobileMessageCursorCallback> cursorCallback =
     new MobileMessageCursorCallback();
 
   nsCOMPtr<nsICursorContinueCallback> continueCallback;
   nsresult rv = dbService->CreateThreadCursor(cursorCallback,
                                               getter_AddRefs(continueCallback));
-  NS_ENSURE_SUCCESS(rv, rv);
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return nullptr;
+  }
 
   cursorCallback->mDOMCursor = new DOMCursor(GetOwner(), continueCallback);
-  NS_ADDREF(*aCursor = cursorCallback->mDOMCursor);
 
-  return NS_OK;
+  nsRefPtr<DOMCursor> cursor = cursorCallback->mDOMCursor;
+  return cursor.forget();
 }
 
-NS_IMETHODIMP
+already_AddRefed<DOMRequest>
 MobileMessageManager::RetrieveMMS(int32_t aId,
-                                  nsIDOMDOMRequest** aRequest)
+                                  ErrorResult& aRv)
 {
   nsCOMPtr<nsIMmsService> mmsService = do_GetService(MMS_SERVICE_CONTRACTID);
-  NS_ENSURE_TRUE(mmsService, NS_ERROR_FAILURE);
+  if (!mmsService) {
+    aRv.Throw(NS_ERROR_FAILURE);
+    return nullptr;
+  }
 
   nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
   nsCOMPtr<nsIMobileMessageCallback> msgCallback = new MobileMessageCallback(request);
 
   nsresult rv = mmsService->Retrieve(aId, msgCallback);
-  NS_ENSURE_SUCCESS(rv, rv);
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return nullptr;
+  }
+
+  return request.forget();
+}
 
-  request.forget(aRequest);
-  return NS_OK;
+already_AddRefed<DOMRequest>
+MobileMessageManager::RetrieveMMS(nsIDOMMozMmsMessage* aMessage,
+                                  ErrorResult& aRv)
+{
+  int32_t id;
+
+  DebugOnly<nsresult> rv = aMessage->GetId(&id);
+  MOZ_ASSERT(NS_SUCCEEDED(rv));
+
+  return RetrieveMMS(id, aRv);
 }
 
 nsresult
 MobileMessageManager::DispatchTrustedSmsEventToSelf(const char* aTopic,
                                                     const nsAString& aEventName,
                                                     nsISupports* aMsg)
 {
   nsCOMPtr<nsIDOMMozSmsMessage> sms = do_QueryInterface(aMsg);
@@ -552,33 +562,44 @@ MobileMessageManager::Observe(nsISupport
 
   if (!strcmp(aTopic, kSmsReadErrorObserverTopic)) {
     return DispatchTrustedSmsEventToSelf(aTopic, READ_ERROR_EVENT_NAME, aSubject);
   }
 
   return NS_OK;
 }
 
-NS_IMETHODIMP
-MobileMessageManager::GetSmscAddress(uint32_t aServiceId,
-                                     uint8_t aArgc,
-                                     nsIDOMDOMRequest** aRequest)
+already_AddRefed<DOMRequest>
+MobileMessageManager::GetSmscAddress(const Optional<uint32_t>& aServiceId,
+                                     ErrorResult& aRv)
 {
   nsCOMPtr<nsISmsService> smsService = do_GetService(SMS_SERVICE_CONTRACTID);
-  NS_ENSURE_TRUE(smsService, NS_ERROR_FAILURE);
+  if (!smsService) {
+    aRv.Throw(NS_ERROR_FAILURE);
+    return nullptr;
+  }
 
+  // Use the default one unless |aSendParams.serviceId| is available.
+  uint32_t serviceId;
   nsresult rv;
-  if (aArgc == 0) {
-    rv = smsService->GetSmsDefaultServiceId(&aServiceId);
-    NS_ENSURE_SUCCESS(rv, rv);
+  if (aServiceId.WasPassed()) {
+    serviceId = aServiceId.Value();
+  } else {
+    rv = smsService->GetSmsDefaultServiceId(&serviceId);
+    if (NS_FAILED(rv)) {
+      aRv.Throw(rv);
+      return nullptr;
+    }
   }
 
   nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
   nsCOMPtr<nsIMobileMessageCallback> msgCallback = new MobileMessageCallback(request);
-  rv = smsService->GetSmscAddress(aServiceId, msgCallback);
-  NS_ENSURE_SUCCESS(rv, rv);
+  rv = smsService->GetSmscAddress(serviceId, msgCallback);
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return nullptr;
+  }
 
-  request.forget(aRequest);
-  return NS_OK;
+  return request.forget();
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/mobilemessage/src/MobileMessageManager.h
+++ b/dom/mobilemessage/src/MobileMessageManager.h
@@ -1,53 +1,150 @@
 /* -*- 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_MobileMessageManager_h
 #define mozilla_dom_mobilemessage_MobileMessageManager_h
 
+#include "mozilla/Attributes.h"
+#include "mozilla/dom/UnionTypes.h"
 #include "mozilla/DOMEventTargetHelper.h"
-#include "nsIDOMMobileMessageManager.h"
 #include "nsIObserver.h"
 
 class nsISmsService;
 class nsIDOMMozSmsMessage;
 class nsIDOMMozMmsMessage;
+class nsIDOMMozSmsFilter;
 
 namespace mozilla {
 namespace dom {
 
-class MobileMessageManager : public DOMEventTargetHelper
-                           , public nsIDOMMozMobileMessageManager
-                           , public nsIObserver
+class DOMRequest;
+class DOMCursor;
+class MmsParameters;
+class MmsSendParameters;
+class SmsSendParameters;
+
+class MobileMessageManager MOZ_FINAL : public DOMEventTargetHelper
+                                     , public nsIObserver
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIOBSERVER
-  NS_DECL_NSIDOMMOZMOBILEMESSAGEMANAGER
 
   NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
 
-  void Init(nsPIDOMWindow *aWindow);
+  MobileMessageManager(nsPIDOMWindow* aWindow);
+
+  void Init();
   void Shutdown();
 
+  nsPIDOMWindow*
+  GetParentObject() const { return GetOwner(); }
+
+  // WrapperCache
+  virtual JSObject*
+  WrapObject(JSContext* aCx) MOZ_OVERRIDE;
+
+  // WebIDL Interface
+  already_AddRefed<DOMRequest>
+  GetSegmentInfoForText(const nsAString& aText,
+                        ErrorResult& aRv);
+
+  already_AddRefed<DOMRequest>
+  Send(const nsAString& aNumber,
+       const nsAString& aText,
+       const SmsSendParameters& aSendParams,
+       ErrorResult& aRv);
+
+  void
+  Send(const Sequence<nsString>& aNumbers,
+       const nsAString& aText,
+       const SmsSendParameters& aSendParams,
+       nsTArray<nsRefPtr<DOMRequest>>& aReturn,
+       ErrorResult& aRv);
+
+  already_AddRefed<DOMRequest>
+  SendMMS(const MmsParameters& aParameters,
+          const MmsSendParameters& aSendParams,
+          ErrorResult& aRv);
+
+  already_AddRefed<DOMRequest>
+  GetMessage(int32_t aId,
+             ErrorResult& aRv);
+
+  already_AddRefed<DOMRequest>
+  Delete(int32_t aId,
+         ErrorResult& aRv);
+
+  already_AddRefed<DOMRequest>
+  Delete(nsIDOMMozSmsMessage* aMessage,
+         ErrorResult& aRv);
+
+  already_AddRefed<DOMRequest>
+  Delete(nsIDOMMozMmsMessage* aMessage,
+         ErrorResult& aRv);
+
+  already_AddRefed<DOMRequest>
+  Delete(const Sequence<OwningLongOrMozSmsMessageOrMozMmsMessage>& aParams,
+         ErrorResult& aRv);
+
+  already_AddRefed<DOMCursor>
+  GetMessages(nsIDOMMozSmsFilter* aFilter,
+              bool aReverse,
+              ErrorResult& aRv);
+
+  already_AddRefed<DOMRequest>
+  MarkMessageRead(int32_t aId,
+                  bool aRead,
+                  bool aSendReadReport,
+                  ErrorResult& aRv);
+
+  already_AddRefed<DOMCursor>
+  GetThreads(ErrorResult& aRv);
+
+  already_AddRefed<DOMRequest>
+  RetrieveMMS(int32_t aId,
+              ErrorResult& aRv);
+
+  already_AddRefed<DOMRequest>
+  RetrieveMMS(nsIDOMMozMmsMessage* aMessage,
+              ErrorResult& aRv);
+
+  already_AddRefed<DOMRequest>
+  GetSmscAddress(const Optional<uint32_t>& aServiceId,
+                 ErrorResult& aRv);
+
+  IMPL_EVENT_HANDLER(received)
+  IMPL_EVENT_HANDLER(retrieving)
+  IMPL_EVENT_HANDLER(sending)
+  IMPL_EVENT_HANDLER(sent)
+  IMPL_EVENT_HANDLER(failed)
+  IMPL_EVENT_HANDLER(deliverysuccess)
+  IMPL_EVENT_HANDLER(deliveryerror)
+  IMPL_EVENT_HANDLER(readsuccess)
+  IMPL_EVENT_HANDLER(readerror)
+
 private:
   /**
    * Internal Send() method used to send one message.
    */
-  nsresult
-  Send(JSContext* aCx,
-       JS::Handle<JSObject*> aGlobal,
-       nsISmsService* aSmsService,
+  already_AddRefed<DOMRequest>
+  Send(nsISmsService* aSmsService,
        uint32_t aServiceId,
-       JS::Handle<JSString*> aNumber,
+       const nsAString& aNumber,
        const nsAString& aText,
-       JS::MutableHandle<JS::Value> aRequest);
+       ErrorResult& aRv);
+
+  already_AddRefed<DOMRequest>
+  Delete(int32_t* aIdArray,
+         uint32_t aSize,
+         ErrorResult& aRv);
 
   nsresult
   DispatchTrustedSmsEventToSelf(const char* aTopic,
                                 const nsAString& aEventName,
                                 nsISupports* aMsg);
 
   /**
    * Helper to get message ID from SMS/MMS Message object
--- a/dom/mobilemessage/src/ipc/SmsIPCService.cpp
+++ b/dom/mobilemessage/src/ipc/SmsIPCService.cpp
@@ -7,18 +7,17 @@
 #include "SmsIPCService.h"
 #include "nsXULAppAPI.h"
 #include "mozilla/dom/mobilemessage/SmsChild.h"
 #include "SmsMessage.h"
 #include "SmsFilter.h"
 #include "SmsSegmentInfo.h"
 #include "nsJSUtils.h"
 #include "nsCxPusher.h"
-#include "mozilla/dom/MobileMessageManagerBinding.h"
-#include "mozilla/dom/MozMmsMessageBinding.h"
+#include "mozilla/dom/MozMobileMessageManagerBinding.h"
 #include "mozilla/dom/BindingUtils.h"
 #include "mozilla/Preferences.h"
 #include "nsString.h"
 
 using namespace mozilla::dom;
 using namespace mozilla::dom::mobilemessage;
 
 namespace {