Bug 1310027 - Remove DOM/mobilemessage and related code. r=Ehsan
authorMichelangelo De Simone <mds@mozilla.com>
Mon, 17 Oct 2016 17:26:51 -0700
changeset 428118 09cfffe505b8d97aba25a80a983dff6eb9773a91
parent 428117 fc577423948f36ef86955ebac4a8e468ddd3a8ab
child 428119 d15798b73b9e3f8226e7d4ac8adfca3a77b069f0
push id33225
push userbmo:dmu@mozilla.com
push dateFri, 21 Oct 2016 15:19:23 +0000
reviewersEhsan
bugs1310027
milestone52.0a1
Bug 1310027 - Remove DOM/mobilemessage and related code. r=Ehsan MozReview-Commit-ID: ENmSuOCdTnA
b2g/app/b2g.js
browser/installer/package-manifest.in
dom/base/Navigator.cpp
dom/base/Navigator.h
dom/bindings/Bindings.conf
dom/ipc/ContentChild.cpp
dom/ipc/ContentChild.h
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
dom/ipc/PContent.ipdl
dom/ipc/moz.build
dom/mobilemessage/Assertions.cpp
dom/mobilemessage/Constants.cpp
dom/mobilemessage/Constants.h
dom/mobilemessage/DOMMobileMessageError.cpp
dom/mobilemessage/DOMMobileMessageError.h
dom/mobilemessage/DeletedMessageInfo.cpp
dom/mobilemessage/DeletedMessageInfo.h
dom/mobilemessage/MmsMessage.cpp
dom/mobilemessage/MmsMessage.h
dom/mobilemessage/MmsMessageInternal.cpp
dom/mobilemessage/MmsMessageInternal.h
dom/mobilemessage/MobileMessageCallback.cpp
dom/mobilemessage/MobileMessageCallback.h
dom/mobilemessage/MobileMessageCursorCallback.cpp
dom/mobilemessage/MobileMessageCursorCallback.h
dom/mobilemessage/MobileMessageManager.cpp
dom/mobilemessage/MobileMessageManager.h
dom/mobilemessage/MobileMessageService.cpp
dom/mobilemessage/MobileMessageService.h
dom/mobilemessage/MobileMessageThread.cpp
dom/mobilemessage/MobileMessageThread.h
dom/mobilemessage/MobileMessageThreadInternal.cpp
dom/mobilemessage/MobileMessageThreadInternal.h
dom/mobilemessage/SmsMessage.cpp
dom/mobilemessage/SmsMessage.h
dom/mobilemessage/SmsMessageInternal.cpp
dom/mobilemessage/SmsMessageInternal.h
dom/mobilemessage/Types.h
dom/mobilemessage/android/MobileMessageDatabaseService.cpp
dom/mobilemessage/android/MobileMessageDatabaseService.h
dom/mobilemessage/android/SmsManager.cpp
dom/mobilemessage/android/SmsManager.h
dom/mobilemessage/android/SmsService.cpp
dom/mobilemessage/android/SmsService.h
dom/mobilemessage/gonk/MmsPduHelper.jsm
dom/mobilemessage/gonk/MmsService.js
dom/mobilemessage/gonk/MmsService.manifest
dom/mobilemessage/gonk/MobileMessageDB.jsm
dom/mobilemessage/gonk/MobileMessageDatabaseService.js
dom/mobilemessage/gonk/MobileMessageDatabaseService.manifest
dom/mobilemessage/gonk/SmsSegmentHelper.jsm
dom/mobilemessage/gonk/SmsService.js
dom/mobilemessage/gonk/SmsService.manifest
dom/mobilemessage/gonk/WspPduHelper.jsm
dom/mobilemessage/gonk/mms_consts.js
dom/mobilemessage/gonk/wap_consts.js
dom/mobilemessage/interfaces/moz.build
dom/mobilemessage/interfaces/nsIDeletedMessageInfo.idl
dom/mobilemessage/interfaces/nsIGonkMobileMessageDatabaseService.idl
dom/mobilemessage/interfaces/nsIGonkSmsService.idl
dom/mobilemessage/interfaces/nsIMmsMessage.idl
dom/mobilemessage/interfaces/nsIMmsService.idl
dom/mobilemessage/interfaces/nsIMobileMessageCallback.idl
dom/mobilemessage/interfaces/nsIMobileMessageCursorCallback.idl
dom/mobilemessage/interfaces/nsIMobileMessageDatabaseService.idl
dom/mobilemessage/interfaces/nsIMobileMessageService.idl
dom/mobilemessage/interfaces/nsIMobileMessageThread.idl
dom/mobilemessage/interfaces/nsISmsMessage.idl
dom/mobilemessage/interfaces/nsISmsMessenger.idl
dom/mobilemessage/interfaces/nsISmsService.idl
dom/mobilemessage/interfaces/nsIWapPushApplication.idl
dom/mobilemessage/ipc/PMobileMessageCursor.ipdl
dom/mobilemessage/ipc/PSms.ipdl
dom/mobilemessage/ipc/PSmsRequest.ipdl
dom/mobilemessage/ipc/SmsChild.cpp
dom/mobilemessage/ipc/SmsChild.h
dom/mobilemessage/ipc/SmsIPCService.cpp
dom/mobilemessage/ipc/SmsIPCService.h
dom/mobilemessage/ipc/SmsParent.cpp
dom/mobilemessage/ipc/SmsParent.h
dom/mobilemessage/ipc/SmsTypes.ipdlh
dom/mobilemessage/moz.build
dom/mobilemessage/tests/marionette/head.js
dom/mobilemessage/tests/marionette/manifest.ini
dom/mobilemessage/tests/marionette/mmdb_head.js
dom/mobilemessage/tests/marionette/test_between_emulators.py
dom/mobilemessage/tests/marionette/test_bug814761.js
dom/mobilemessage/tests/marionette/test_decode_spanish_fallback.js
dom/mobilemessage/tests/marionette/test_emulator_loopback.js
dom/mobilemessage/tests/marionette/test_error_of_mms_manual_retrieval.js
dom/mobilemessage/tests/marionette/test_error_of_mms_send.js
dom/mobilemessage/tests/marionette/test_error_of_sms_send.js
dom/mobilemessage/tests/marionette/test_filter_date.js
dom/mobilemessage/tests/marionette/test_filter_mixed.js
dom/mobilemessage/tests/marionette/test_filter_number.js
dom/mobilemessage/tests/marionette/test_filter_read.js
dom/mobilemessage/tests/marionette/test_filter_received.js
dom/mobilemessage/tests/marionette/test_filter_sent.js
dom/mobilemessage/tests/marionette/test_filter_unread.js
dom/mobilemessage/tests/marionette/test_getmessage.js
dom/mobilemessage/tests/marionette/test_getmessage_notfound.js
dom/mobilemessage/tests/marionette/test_getmessages.js
dom/mobilemessage/tests/marionette/test_getsegmentinfofortext.js
dom/mobilemessage/tests/marionette/test_getthreads.js
dom/mobilemessage/tests/marionette/test_incoming.js
dom/mobilemessage/tests/marionette/test_incoming_delete.js
dom/mobilemessage/tests/marionette/test_incoming_max_segments.js
dom/mobilemessage/tests/marionette/test_invalid_address.js
dom/mobilemessage/tests/marionette/test_mark_msg_read.js
dom/mobilemessage/tests/marionette/test_mark_msg_read_error.js
dom/mobilemessage/tests/marionette/test_massive_incoming_delete.js
dom/mobilemessage/tests/marionette/test_message_classes.js
dom/mobilemessage/tests/marionette/test_mmdb_foreachmatchedmmsdeliveryinfo.js
dom/mobilemessage/tests/marionette/test_mmdb_full_storage.js
dom/mobilemessage/tests/marionette/test_mmdb_new.js
dom/mobilemessage/tests/marionette/test_mmdb_ports_in_cdma_wappush.js
dom/mobilemessage/tests/marionette/test_mmdb_setmessagedeliverybyid_sms.js
dom/mobilemessage/tests/marionette/test_mmdb_upgradeSchema_22.js
dom/mobilemessage/tests/marionette/test_mmdb_upgradeSchema_current_structure.js
dom/mobilemessage/tests/marionette/test_mmsmessage_attachments.js
dom/mobilemessage/tests/marionette/test_mobilemessage_dsds_default_service_id.js
dom/mobilemessage/tests/marionette/test_mt_sms_concatenation.js
dom/mobilemessage/tests/marionette/test_ondeleted_event.js
dom/mobilemessage/tests/marionette/test_outgoing.js
dom/mobilemessage/tests/marionette/test_outgoing_delete.js
dom/mobilemessage/tests/marionette/test_outgoing_max_segments.js
dom/mobilemessage/tests/marionette/test_outgoing_unstable_voice_connection.js
dom/mobilemessage/tests/marionette/test_phone_number_normalization.js
dom/mobilemessage/tests/marionette/test_replace_short_message_type.js
dom/mobilemessage/tests/marionette/test_segment_info.js
dom/mobilemessage/tests/marionette/test_smsc_address.js
dom/mobilemessage/tests/marionette/test_strict_7bit_encoding.js
dom/mobilemessage/tests/marionette/test_thread_subject.js
dom/mobilemessage/tests/marionette/test_update_gsm_nl_on_mcc_chanages.js
dom/mobilemessage/tests/marionette/test_update_thread_record_in_delete.js
dom/mobilemessage/tests/mochitest/chrome.ini
dom/mobilemessage/tests/mochitest/test_sms_basics.html
dom/mobilemessage/tests/xpcshell/header_helpers.js
dom/mobilemessage/tests/xpcshell/test_mms_pdu_helper.js
dom/mobilemessage/tests/xpcshell/test_mms_service.js
dom/mobilemessage/tests/xpcshell/test_sms_segment_helper.js
dom/mobilemessage/tests/xpcshell/test_smsservice_createsmsmessage.js
dom/mobilemessage/tests/xpcshell/test_wsp_pdu_helper.js
dom/mobilemessage/tests/xpcshell/test_wsp_pdu_helper_header.js
dom/mobilemessage/tests/xpcshell/test_wsp_pdu_helper_numeric.js
dom/mobilemessage/tests/xpcshell/test_wsp_pdu_helper_parameter.js
dom/mobilemessage/tests/xpcshell/test_wsp_pdu_helper_text.js
dom/mobilemessage/tests/xpcshell/xpcshell.ini
dom/moz.build
dom/permission/moz.build
dom/permission/tests/mochitest-websms.ini
dom/permission/tests/test_sms.html
dom/webidl/DOMMobileMessageError.webidl
dom/webidl/MmsMessage.webidl
dom/webidl/MobileMessageThread.webidl
dom/webidl/MozMessageDeletedEvent.webidl
dom/webidl/MozMmsEvent.webidl
dom/webidl/MozMobileMessageManager.webidl
dom/webidl/MozSmsEvent.webidl
dom/webidl/Navigator.webidl
dom/webidl/SmsMessage.webidl
dom/webidl/moz.build
layout/build/nsLayoutModule.cpp
mobile/android/base/AppConstants.java.in
mobile/android/base/FennecManifest_permissions.xml.in
mobile/android/base/geckoview.ddf
mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
mobile/android/base/moz.build
mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoSmsManager.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/SmsManager.java
modules/libpref/init/all.js
testing/marionette/harness/marionette/tests/webapi-tests.ini
toolkit/moz.configure
widget/android/AndroidBridge.cpp
widget/android/AndroidBridge.h
widget/android/GeneratedJNINatives.h
widget/android/GeneratedJNIWrappers.cpp
widget/android/GeneratedJNIWrappers.h
--- a/b2g/app/b2g.js
+++ b/b2g/app/b2g.js
@@ -385,19 +385,16 @@ pref("dom.mozBrowserFramesEnabled", true
 pref("dom.ipc.processCount", 100000);
 
 pref("dom.ipc.browser_frames.oop_by_default", false);
 
 #if !defined(MOZ_MULET) && !defined(MOZ_GRAPHENE)
 pref("dom.meta-viewport.enabled", true);
 #endif
 
-// SMS/MMS
-pref("dom.sms.enabled", true);
-
 //The waiting time in network manager.
 pref("network.gonk.ms-release-mms-connection", 30000);
 
 // Shortnumber matching needed for e.g. Brazil:
 // 03187654321 can be found with 87654321
 pref("dom.phonenumber.substringmatching.BR", 8);
 pref("dom.phonenumber.substringmatching.CO", 10);
 pref("dom.phonenumber.substringmatching.VE", 7);
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -203,17 +203,16 @@
 @RESPATH@/components/dom_power.xpt
 @RESPATH@/components/dom_push.xpt
 @RESPATH@/components/dom_quota.xpt
 @RESPATH@/components/dom_range.xpt
 @RESPATH@/components/dom_security.xpt
 @RESPATH@/components/dom_settings.xpt
 @RESPATH@/components/dom_permissionsettings.xpt
 @RESPATH@/components/dom_sidebar.xpt
-@RESPATH@/components/dom_mobilemessage.xpt
 @RESPATH@/components/dom_storage.xpt
 @RESPATH@/components/dom_stylesheets.xpt
 @RESPATH@/components/dom_telephony.xpt
 @RESPATH@/components/dom_traversal.xpt
 #ifdef MOZ_WEBSPEECH
 @RESPATH@/components/dom_webspeechrecognition.xpt
 #endif
 @RESPATH@/components/dom_workers.xpt
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -37,17 +37,16 @@
 #endif
 #include "mozilla/dom/PowerManager.h"
 #include "mozilla/dom/WakeLock.h"
 #include "mozilla/dom/power/PowerManagerService.h"
 #include "mozilla/dom/FlyWebPublishedServer.h"
 #include "mozilla/dom/FlyWebService.h"
 #include "mozilla/dom/IccManager.h"
 #include "mozilla/dom/InputPortManager.h"
-#include "mozilla/dom/MobileMessageManager.h"
 #include "mozilla/dom/Permissions.h"
 #include "mozilla/dom/Presentation.h"
 #include "mozilla/dom/ServiceWorkerContainer.h"
 #include "mozilla/dom/StorageManager.h"
 #include "mozilla/dom/TCPSocket.h"
 #include "mozilla/dom/Telephony.h"
 #include "mozilla/dom/VRDisplay.h"
 #include "mozilla/dom/workers/RuntimeService.h"
@@ -211,17 +210,16 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPlugins)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPermissions)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGeolocation)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mNotification)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBatteryManager)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBatteryPromise)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPowerManager)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mIccManager)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMobileMessageManager)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTelephony)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mInputPortManager)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mConnection)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mStorageManager)
 #ifdef MOZ_B2G_RIL
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMobileConnections)
 #endif
 #ifdef MOZ_B2G_BT
@@ -287,21 +285,16 @@ Navigator::Invalidate()
     mPowerManager = nullptr;
   }
 
   if (mIccManager) {
     mIccManager->Shutdown();
     mIccManager = nullptr;
   }
 
-  if (mMobileMessageManager) {
-    mMobileMessageManager->Shutdown();
-    mMobileMessageManager = nullptr;
-  }
-
   if (mTelephony) {
     mTelephony = nullptr;
   }
 
   if (mInputPortManager) {
     mInputPortManager = nullptr;
   }
 
@@ -1619,31 +1612,16 @@ Navigator::RequestWakeLock(const nsAStri
   if (!pmService) {
     aRv.Throw(NS_ERROR_UNEXPECTED);
     return nullptr;
   }
 
   return pmService->NewWakeLock(aTopic, mWindow, aRv);
 }
 
-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(mWindow);
-    mMobileMessageManager->Init();
-  }
-
-  return mMobileMessageManager;
-}
-
 Telephony*
 Navigator::GetMozTelephony(ErrorResult& aRv)
 {
   if (!mTelephony) {
     if (!mWindow) {
       aRv.Throw(NS_ERROR_UNEXPECTED);
       return nullptr;
     }
--- a/dom/base/Navigator.h
+++ b/dom/base/Navigator.h
@@ -54,17 +54,16 @@ class Permissions;
 
 namespace battery {
 class BatteryManager;
 } // namespace battery
 
 class Promise;
 
 class DesktopNotificationCenter;
-class MobileMessageManager;
 class MozIdleObserver;
 #ifdef MOZ_GAMEPAD
 class Gamepad;
 class GamepadServiceTest;
 #endif // MOZ_GAMEPAD
 class NavigatorUserMediaSuccessCallback;
 class NavigatorUserMediaErrorCallback;
 class MozGetUserMediaDevicesSuccessCallback;
@@ -217,17 +216,16 @@ public:
                          ErrorResult& aRv);
 
   already_AddRefed<nsDOMDeviceStorage>
   GetDeviceStorageByNameAndType(const nsAString& aName, const nsAString& aType,
                                 ErrorResult& aRv);
 
   DesktopNotificationCenter* GetMozNotification(ErrorResult& aRv);
   IccManager* GetMozIccManager(ErrorResult& aRv);
-  MobileMessageManager* GetMozMobileMessage();
   Telephony* GetMozTelephony(ErrorResult& aRv);
   InputPortManager* GetInputPortManager(ErrorResult& aRv);
   already_AddRefed<LegacyMozTCPSocket> MozTCPSocket();
   network::Connection* GetConnection(ErrorResult& aRv);
   MediaDevices* GetMediaDevices(ErrorResult& aRv);
 
 #ifdef MOZ_B2G_RIL
   MobileConnectionArray* GetMozMobileConnections(ErrorResult& aRv);
@@ -322,17 +320,16 @@ private:
   RefPtr<nsPluginArray> mPlugins;
   RefPtr<Permissions> mPermissions;
   RefPtr<Geolocation> mGeolocation;
   RefPtr<DesktopNotificationCenter> mNotification;
   RefPtr<battery::BatteryManager> mBatteryManager;
   RefPtr<Promise> mBatteryPromise;
   RefPtr<PowerManager> mPowerManager;
   RefPtr<IccManager> mIccManager;
-  RefPtr<MobileMessageManager> mMobileMessageManager;
   RefPtr<Telephony> mTelephony;
   RefPtr<InputPortManager> mInputPortManager;
   RefPtr<network::Connection> mConnection;
 #ifdef MOZ_B2G_RIL
   RefPtr<MobileConnectionArray> mMobileConnections;
 #endif
 #ifdef MOZ_B2G_BT
   RefPtr<bluetooth::BluetoothManager> mBluetooth;
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -681,20 +681,16 @@ DOMInterfaces = {
 'MozMobileConnectionArray': {
     'nativeType': 'mozilla::dom::MobileConnectionArray',
 },
 
 'MozMobileConnectionInfo': {
     'nativeType': 'mozilla::dom::MobileConnectionInfo',
 },
 
-'MozMobileMessageManager': {
-    'nativeType': 'mozilla::dom::MobileMessageManager',
-},
-
 'MozMobileNetworkInfo': {
     'nativeType': 'mozilla::dom::MobileNetworkInfo',
 },
 
 'MozSpeakerManager': {
     'nativeType': 'mozilla::dom::SpeakerManager',
     'headerFile': 'SpeakerManager.h'
 },
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -167,17 +167,16 @@
 
 #ifdef ACCESSIBILITY
 #include "nsAccessibilityService.h"
 #endif
 
 #include "mozilla/dom/File.h"
 #include "mozilla/dom/icc/IccChild.h"
 #include "mozilla/dom/mobileconnection/MobileConnectionChild.h"
-#include "mozilla/dom/mobilemessage/SmsChild.h"
 #include "mozilla/dom/devicestorage/DeviceStorageRequestChild.h"
 #include "mozilla/dom/bluetooth/PBluetoothChild.h"
 #include "mozilla/dom/PPresentationChild.h"
 #include "mozilla/dom/PresentationIPCService.h"
 #include "mozilla/ipc/InputStreamUtils.h"
 
 #ifdef MOZ_WEBSPEECH
 #include "mozilla/dom/PSpeechSynthesisChild.h"
@@ -203,17 +202,16 @@
 
 using namespace mozilla;
 using namespace mozilla::docshell;
 using namespace mozilla::dom::bluetooth;
 using namespace mozilla::dom::devicestorage;
 using namespace mozilla::dom::icc;
 using namespace mozilla::dom::ipc;
 using namespace mozilla::dom::mobileconnection;
-using namespace mozilla::dom::mobilemessage;
 using namespace mozilla::dom::telephony;
 using namespace mozilla::dom::workers;
 using namespace mozilla::media;
 using namespace mozilla::embedding;
 using namespace mozilla::gmp;
 using namespace mozilla::hal_sandbox;
 using namespace mozilla::ipc;
 using namespace mozilla::layers;
@@ -1972,29 +1970,16 @@ ContentChild::AllocPHandlerServiceChild(
 }
 
 bool ContentChild::DeallocPHandlerServiceChild(PHandlerServiceChild* aHandlerServiceChild)
 {
   static_cast<HandlerServiceChild*>(aHandlerServiceChild)->Release();
   return true;
 }
 
-PSmsChild*
-ContentChild::AllocPSmsChild()
-{
-  return new SmsChild();
-}
-
-bool
-ContentChild::DeallocPSmsChild(PSmsChild* aSms)
-{
-  delete aSms;
-  return true;
-}
-
 PTelephonyChild*
 ContentChild::AllocPTelephonyChild()
 {
   MOZ_CRASH("No one should be allocating PTelephonyChild actors");
 }
 
 bool
 ContentChild::DeallocPTelephonyChild(PTelephonyChild* aActor)
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -330,20 +330,16 @@ public:
 
   virtual bool
   DeallocPExternalHelperAppChild(PExternalHelperAppChild *aService) override;
 
   virtual PHandlerServiceChild* AllocPHandlerServiceChild() override;
 
   virtual bool DeallocPHandlerServiceChild(PHandlerServiceChild*) override;
 
-  virtual PSmsChild* AllocPSmsChild() override;
-
-  virtual bool DeallocPSmsChild(PSmsChild*) override;
-
   virtual PTelephonyChild* AllocPTelephonyChild() override;
 
   virtual bool DeallocPTelephonyChild(PTelephonyChild*) override;
 
   virtual PMediaChild* AllocPMediaChild() override;
 
   virtual bool DeallocPMediaChild(PMediaChild* aActor) override;
 
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -56,17 +56,16 @@
 #include "mozilla/dom/PContentPermissionRequestParent.h"
 #include "mozilla/dom/PCycleCollectWithLogsParent.h"
 #include "mozilla/dom/PMemoryReportRequestParent.h"
 #include "mozilla/dom/ServiceWorkerRegistrar.h"
 #include "mozilla/dom/bluetooth/PBluetoothParent.h"
 #include "mozilla/dom/devicestorage/DeviceStorageRequestParent.h"
 #include "mozilla/dom/icc/IccParent.h"
 #include "mozilla/dom/mobileconnection/MobileConnectionParent.h"
-#include "mozilla/dom/mobilemessage/SmsParent.h"
 #include "mozilla/dom/power/PowerManagerService.h"
 #include "mozilla/dom/Permissions.h"
 #include "mozilla/dom/PresentationParent.h"
 #include "mozilla/dom/PPresentationParent.h"
 #include "mozilla/dom/PushNotifier.h"
 #include "mozilla/dom/FlyWebPublishedServerIPC.h"
 #include "mozilla/dom/quota/QuotaManagerService.h"
 #include "mozilla/dom/telephony/TelephonyParent.h"
@@ -287,17 +286,16 @@ using mozilla::ProfileGatherer;
 #ifdef MOZ_CRASHREPORTER
 using namespace CrashReporter;
 #endif
 using namespace mozilla::dom::bluetooth;
 using namespace mozilla::dom::devicestorage;
 using namespace mozilla::dom::icc;
 using namespace mozilla::dom::power;
 using namespace mozilla::dom::mobileconnection;
-using namespace mozilla::dom::mobilemessage;
 using namespace mozilla::dom::telephony;
 using namespace mozilla::media;
 using namespace mozilla::embedding;
 using namespace mozilla::gfx;
 using namespace mozilla::gmp;
 using namespace mozilla::hal;
 using namespace mozilla::ipc;
 using namespace mozilla::layers;
@@ -3427,35 +3425,16 @@ ContentParent::AllocPHandlerServiceParen
 
 bool
 ContentParent::DeallocPHandlerServiceParent(PHandlerServiceParent* aHandlerServiceParent)
 {
   static_cast<HandlerServiceParent*>(aHandlerServiceParent)->Release();
   return true;
 }
 
-PSmsParent*
-ContentParent::AllocPSmsParent()
-{
-  if (!AssertAppProcessPermission(this, "sms")) {
-    return nullptr;
-  }
-
-  SmsParent* parent = new SmsParent();
-  parent->AddRef();
-  return parent;
-}
-
-bool
-ContentParent::DeallocPSmsParent(PSmsParent* aSms)
-{
-  static_cast<SmsParent*>(aSms)->Release();
-  return true;
-}
-
 PTelephonyParent*
 ContentParent::AllocPTelephonyParent()
 {
   if (!AssertAppProcessPermission(this, "telephony")) {
     return nullptr;
   }
 
   TelephonyParent* actor = new TelephonyParent();
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -838,20 +838,16 @@ private:
 
   virtual bool
   DeallocPExternalHelperAppParent(PExternalHelperAppParent* aService) override;
 
   virtual PHandlerServiceParent* AllocPHandlerServiceParent() override;
 
   virtual bool DeallocPHandlerServiceParent(PHandlerServiceParent*) override;
 
-  virtual PSmsParent* AllocPSmsParent() override;
-
-  virtual bool DeallocPSmsParent(PSmsParent*) override;
-
   virtual PTelephonyParent* AllocPTelephonyParent() override;
 
   virtual bool DeallocPTelephonyParent(PTelephonyParent*) override;
 
   virtual PMediaParent* AllocPMediaParent() override;
 
   virtual bool DeallocPMediaParent(PMediaParent* aActor) override;
 
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -37,17 +37,16 @@ include protocol PGMPService;
 include protocol PPluginModule;
 include protocol PGMP;
 include protocol PPrinting;
 include protocol PSendStream;
 include protocol POfflineCacheUpdate;
 include protocol PRenderFrame;
 include protocol PScreenManager;
 include protocol PSharedBufferManager;
-include protocol PSms;
 include protocol PSpeechSynthesis;
 include protocol PStorage;
 include protocol PTelephony;
 include protocol PTestShell;
 include protocol PJavaScript;
 include protocol PRemoteSpellcheckEngine;
 include protocol PWebBrowserPersistDocument;
 include protocol PWebrtcGlobal;
@@ -366,17 +365,16 @@ nested(upto inside_cpow) sync protocol P
     manages PMedia;
     manages PMemoryReportRequest;
     manages PMobileConnection;
     manages PNecko;
     manages POfflineCacheUpdate;
     manages PPrinting;
     manages PSendStream;
     manages PScreenManager;
-    manages PSms;
     manages PSpeechSynthesis;
     manages PStorage;
     manages PTelephony;
     manages PTestShell;
     manages PJavaScript;
     manages PRemoteSpellcheckEngine;
     manages PWebBrowserPersistDocument;
     manages PWebrtcGlobal;
@@ -812,18 +810,16 @@ parent:
 
     async PSendStream();
 
     nested(inside_sync) sync PScreenManager()
         returns (uint32_t numberOfScreens,
                  float systemDefaultScale,
                  bool success);
 
-    async PSms();
-
     async PSpeechSynthesis();
 
     nested(inside_cpow) async PStorage();
 
     async PTelephony();
 
     async PMedia();
 
--- a/dom/ipc/moz.build
+++ b/dom/ipc/moz.build
@@ -127,17 +127,16 @@ LOCAL_INCLUDES += [
     '/dom/base',
     '/dom/bluetooth/common',
     '/dom/bluetooth/ipc',
     '/dom/devicestorage',
     '/dom/events',
     '/dom/filesystem',
     '/dom/geolocation',
     '/dom/media/webspeech/synth/ipc',
-    '/dom/mobilemessage/ipc',
     '/dom/security',
     '/dom/storage',
     '/dom/workers',
     '/embedding/components/printingui/ipc',
     '/extensions/cookie',
     '/extensions/spellcheck/src',
     '/gfx/2d',
     '/hal/sandbox',
deleted file mode 100644
--- a/dom/mobilemessage/Assertions.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/* 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 "mozilla/dom/MozMobileMessageManagerBinding.h"
-#include "nsISmsService.h"
-
-namespace mozilla {
-namespace dom {
-namespace mobilemessage {
-
-#define ASSERT_SMS_EQUALITY(webidlType, webidlState, xpidlState) \
-  static_assert(static_cast<uint32_t>(webidlType::webidlState) == nsISmsService::xpidlState, \
-  #webidlType "::" #webidlState " should equal to nsISmsService::" #xpidlState)
-
-/**
- * Enum TypeOfNumber
- */
-#define ASSERT_SMS_TYPE_OF_NUMBER_EQUALITY(webidlState, xpidlState) \
-  ASSERT_SMS_EQUALITY(TypeOfNumber, webidlState, xpidlState)
-
-ASSERT_SMS_TYPE_OF_NUMBER_EQUALITY(Unknown, TYPE_OF_NUMBER_UNKNOWN);
-ASSERT_SMS_TYPE_OF_NUMBER_EQUALITY(International, TYPE_OF_NUMBER_INTERNATIONAL);
-ASSERT_SMS_TYPE_OF_NUMBER_EQUALITY(National, TYPE_OF_NUMBER_NATIONAL);
-ASSERT_SMS_TYPE_OF_NUMBER_EQUALITY(Network_specific, TYPE_OF_NUMBER_NETWORK_SPECIFIC);
-ASSERT_SMS_TYPE_OF_NUMBER_EQUALITY(Dedicated_access_short_code, TYPE_OF_NUMBER_DEDICATED_ACCESS_SHORT_CODE);
-
-#undef ASSERT_SMS_TYPE_OF_NUMBER_EQUALITY
-
-/**
- * Enum NumberPlanIdentification
- */
-#define ASSERT_SMS_NUMBER_PLAN_IDENTIFICATION_EQUALITY(webidlState, xpidlState) \
-  ASSERT_SMS_EQUALITY(NumberPlanIdentification, webidlState, xpidlState)
-
-ASSERT_SMS_NUMBER_PLAN_IDENTIFICATION_EQUALITY(Unknown, NUMBER_PLAN_IDENTIFICATION_UNKNOWN);
-ASSERT_SMS_NUMBER_PLAN_IDENTIFICATION_EQUALITY(Isdn, NUMBER_PLAN_IDENTIFICATION_ISDN);
-ASSERT_SMS_NUMBER_PLAN_IDENTIFICATION_EQUALITY(Data, NUMBER_PLAN_IDENTIFICATION_DATA);
-ASSERT_SMS_NUMBER_PLAN_IDENTIFICATION_EQUALITY(Telex, NUMBER_PLAN_IDENTIFICATION_TELEX);
-ASSERT_SMS_NUMBER_PLAN_IDENTIFICATION_EQUALITY(National, NUMBER_PLAN_IDENTIFICATION_NATIONAL);
-ASSERT_SMS_NUMBER_PLAN_IDENTIFICATION_EQUALITY(Private, NUMBER_PLAN_IDENTIFICATION_PRIVATE);
-
-#undef ASSERT_SMS_EQUALITY
-
-} // namespace mobilemessage
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/mobilemessage/Constants.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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/. */
-
-namespace mozilla {
-namespace dom {
-namespace mobilemessage {
-
-const char* kSmsReceivedObserverTopic        = "sms-received";
-const char* kSmsRetrievingObserverTopic      = "sms-retrieving";
-const char* kSmsSendingObserverTopic         = "sms-sending";
-const char* kSmsSentObserverTopic            = "sms-sent";
-const char* kSmsFailedObserverTopic          = "sms-failed";
-const char* kSmsDeliverySuccessObserverTopic = "sms-delivery-success";
-const char* kSmsDeliveryErrorObserverTopic   = "sms-delivery-error";
-const char* kSilentSmsReceivedObserverTopic  = "silent-sms-received";
-const char* kSmsReadSuccessObserverTopic     = "sms-read-success";
-const char* kSmsReadErrorObserverTopic       = "sms-read-error";
-const char* kSmsDeletedObserverTopic         = "sms-deleted";
-
-} // namespace mobilemessage
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/mobilemessage/Constants.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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_Constants_h
-#define mozilla_dom_mobilemessage_Constants_h
-
-namespace mozilla {
-namespace dom {
-namespace mobilemessage {
-
-// Defined in the .cpp.
-extern const char* kSmsReceivedObserverTopic;
-extern const char* kSmsRetrievingObserverTopic;
-extern const char* kSmsSendingObserverTopic;
-extern const char* kSmsSentObserverTopic;
-extern const char* kSmsFailedObserverTopic;
-extern const char* kSmsDeliverySuccessObserverTopic;
-extern const char* kSmsDeliveryErrorObserverTopic;
-extern const char* kSilentSmsReceivedObserverTopic;
-extern const char* kSmsReadSuccessObserverTopic;
-extern const char* kSmsReadErrorObserverTopic;
-extern const char* kSmsDeletedObserverTopic;
-
-#define DELIVERY_RECEIVED       NS_LITERAL_STRING("received")
-#define DELIVERY_SENDING        NS_LITERAL_STRING("sending")
-#define DELIVERY_SENT           NS_LITERAL_STRING("sent")
-#define DELIVERY_ERROR          NS_LITERAL_STRING("error")
-#define DELIVERY_NOT_DOWNLOADED NS_LITERAL_STRING("not-downloaded")
-
-#define DELIVERY_STATUS_NOT_APPLICABLE NS_LITERAL_STRING("not-applicable")
-#define DELIVERY_STATUS_SUCCESS        NS_LITERAL_STRING("success")
-#define DELIVERY_STATUS_PENDING        NS_LITERAL_STRING("pending")
-#define DELIVERY_STATUS_ERROR          NS_LITERAL_STRING("error")
-#define DELIVERY_STATUS_REJECTED       NS_LITERAL_STRING("rejected")
-#define DELIVERY_STATUS_MANUAL         NS_LITERAL_STRING("manual")
-
-#define READ_STATUS_NOT_APPLICABLE NS_LITERAL_STRING("not-applicable")
-#define READ_STATUS_SUCCESS        NS_LITERAL_STRING("success")
-#define READ_STATUS_PENDING        NS_LITERAL_STRING("pending")
-#define READ_STATUS_ERROR          NS_LITERAL_STRING("error")
-
-#define MESSAGE_CLASS_NORMAL  NS_LITERAL_STRING("normal")
-#define MESSAGE_CLASS_CLASS_0 NS_LITERAL_STRING("class-0")
-#define MESSAGE_CLASS_CLASS_1 NS_LITERAL_STRING("class-1")
-#define MESSAGE_CLASS_CLASS_2 NS_LITERAL_STRING("class-2")
-#define MESSAGE_CLASS_CLASS_3 NS_LITERAL_STRING("class-3")
-
-#define MESSAGE_TYPE_SMS NS_LITERAL_STRING("sms")
-#define MESSAGE_TYPE_MMS NS_LITERAL_STRING("mms")
-
-} // namespace mobilemessage
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_mobilemessage_Constants_h
deleted file mode 100644
--- a/dom/mobilemessage/DOMMobileMessageError.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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 "DOMMobileMessageError.h"
-#include "mozilla/dom/DOMMobileMessageErrorBinding.h"
-#include "MmsMessage.h"
-#include "SmsMessage.h"
-
-namespace mozilla {
-namespace dom {
-
-NS_IMPL_CYCLE_COLLECTION_CLASS(DOMMobileMessageError)
-
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(DOMMobileMessageError, DOMError)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mSms)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mMms)
-NS_IMPL_CYCLE_COLLECTION_UNLINK_END
-
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(DOMMobileMessageError, DOMError)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSms)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMms)
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(DOMMobileMessageError)
-NS_INTERFACE_MAP_END_INHERITING(DOMError)
-
-NS_IMPL_ADDREF_INHERITED(DOMMobileMessageError, DOMError)
-NS_IMPL_RELEASE_INHERITED(DOMMobileMessageError, DOMError)
-
-DOMMobileMessageError::DOMMobileMessageError(nsPIDOMWindowInner* aWindow,
-                                             const nsAString& aName,
-                                             SmsMessage* aSms)
-  : DOMError(aWindow, aName)
-  , mSms(aSms)
-  , mMms(nullptr)
-{
-}
-
-DOMMobileMessageError::DOMMobileMessageError(nsPIDOMWindowInner* aWindow,
-                                             const nsAString& aName,
-                                             MmsMessage* aMms)
-  : DOMError(aWindow, aName)
-  , mSms(nullptr)
-  , mMms(aMms)
-{
-}
-
-void
-DOMMobileMessageError::GetData(OwningSmsMessageOrMmsMessage& aRetVal) const
-{
-  if (mSms) {
-    aRetVal.SetAsSmsMessage() = mSms;
-    return;
-  }
-
-  if (mMms) {
-    aRetVal.SetAsMmsMessage() = mMms;
-    return;
-  }
-
-  MOZ_CRASH("Bad object with invalid mSms and mMms.");
-}
-
-JSObject*
-DOMMobileMessageError::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
-{
-  return DOMMobileMessageErrorBinding::Wrap(aCx, this, aGivenProto);
-}
-
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/mobilemessage/DOMMobileMessageError.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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_MobileMessageError_h
-#define mozilla_dom_MobileMessageError_h
-
-#include "mozilla/dom/DOMError.h"
-
-namespace mozilla {
-namespace dom {
-
-class MmsMessage;
-class OwningSmsMessageOrMmsMessage;
-class SmsMessage;
-
-class DOMMobileMessageError final : public DOMError
-{
-public:
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DOMMobileMessageError, DOMError)
-
-  DOMMobileMessageError(nsPIDOMWindowInner* aWindow, const nsAString& aName,
-                        SmsMessage* aSms);
-
-  DOMMobileMessageError(nsPIDOMWindowInner* aWindow, const nsAString& aName,
-                        MmsMessage* aMms);
-
-  virtual JSObject*
-  WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
-
-  void GetData(OwningSmsMessageOrMmsMessage& aRetVal) const;
-
-private:
-  ~DOMMobileMessageError() {}
-
-  RefPtr<SmsMessage> mSms;
-  RefPtr<MmsMessage> mMms;
-};
-
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_MobileMessageError_h
deleted file mode 100644
--- a/dom/mobilemessage/DeletedMessageInfo.cpp
+++ /dev/null
@@ -1,123 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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 "DeletedMessageInfo.h"
-#include "nsComponentManagerUtils.h"    // for do_CreateInstance
-#include "nsVariant.h"
-
-namespace mozilla {
-namespace dom {
-namespace mobilemessage {
-
-NS_IMPL_ISUPPORTS(DeletedMessageInfo, nsIDeletedMessageInfo)
-
-DeletedMessageInfo::DeletedMessageInfo(const DeletedMessageInfoData& aData)
-  : mData(aData)
-{
-}
-
-DeletedMessageInfo::DeletedMessageInfo(int32_t* aMessageIds,
-                                       uint32_t aMsgCount,
-                                       uint64_t* aThreadIds,
-                                       uint32_t  aThreadCount)
-{
-  mData.deletedMessageIds().AppendElements(aMessageIds, aMsgCount);
-  mData.deletedThreadIds().AppendElements(aThreadIds, aThreadCount);
-}
-
-DeletedMessageInfo::~DeletedMessageInfo()
-{
-}
-
-/* static */ nsresult
-DeletedMessageInfo::Create(int32_t* aMessageIds,
-                           uint32_t aMsgCount,
-                           uint64_t* aThreadIds,
-                           uint32_t  aThreadCount,
-                           nsIDeletedMessageInfo** aDeletedInfo)
-{
-  NS_ENSURE_ARG_POINTER(aDeletedInfo);
-  NS_ENSURE_TRUE(aMsgCount || aThreadCount, NS_ERROR_INVALID_ARG);
-
-  nsCOMPtr<nsIDeletedMessageInfo> deletedInfo =
-    new DeletedMessageInfo(aMessageIds,
-                           aMsgCount,
-                           aThreadIds,
-                           aThreadCount);
-  deletedInfo.forget(aDeletedInfo);
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-DeletedMessageInfo::GetDeletedMessageIds(nsIVariant** aDeletedMessageIds)
-{
-  NS_ENSURE_ARG_POINTER(aDeletedMessageIds);
-
-  if (mDeletedMessageIds) {
-    NS_ADDREF(*aDeletedMessageIds = mDeletedMessageIds);
-    return NS_OK;
-  }
-
-  uint32_t length = mData.deletedMessageIds().Length();
-
-  if (length == 0) {
-    *aDeletedMessageIds = nullptr;
-    return NS_OK;
-  }
-
-  mDeletedMessageIds = new nsVariant();
-
-  nsresult rv;
-  rv = mDeletedMessageIds->SetAsArray(nsIDataType::VTYPE_INT32,
-                                      nullptr,
-                                      length,
-                                      mData.deletedMessageIds().Elements());
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  mDeletedMessageIds->SetWritable(false);
-
-  NS_ADDREF(*aDeletedMessageIds = mDeletedMessageIds);
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-DeletedMessageInfo::GetDeletedThreadIds(nsIVariant** aDeletedThreadIds)
-{
-  NS_ENSURE_ARG_POINTER(aDeletedThreadIds);
-
-  if (mDeletedThreadIds) {
-    NS_ADDREF(*aDeletedThreadIds = mDeletedThreadIds);
-    return NS_OK;
-  }
-
-  uint32_t length = mData.deletedThreadIds().Length();
-
-  if (length == 0) {
-    *aDeletedThreadIds = nullptr;
-    return NS_OK;
-  }
-
-  mDeletedThreadIds = new nsVariant();
-
-  nsresult rv;
-  rv = mDeletedThreadIds->SetAsArray(nsIDataType::VTYPE_UINT64,
-                                     nullptr,
-                                     length,
-                                     mData.deletedThreadIds().Elements());
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  mDeletedThreadIds->SetWritable(false);
-
-  NS_ADDREF(*aDeletedThreadIds = mDeletedThreadIds);
-
-  return NS_OK;
-}
-
-} // namespace mobilemessage
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/mobilemessage/DeletedMessageInfo.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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_DeletedMessageInfo_h
-#define mozilla_dom_mobilemessage_DeletedMessageInfo_h
-
-#include "mozilla/dom/mobilemessage/SmsTypes.h"
-#include "nsIDeletedMessageInfo.h"
-
-class nsIWritableVariant;
-
-namespace mozilla {
-namespace dom {
-namespace mobilemessage {
-
-class DeletedMessageInfo final : public nsIDeletedMessageInfo
-{
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIDELETEDMESSAGEINFO
-
-  explicit DeletedMessageInfo(const DeletedMessageInfoData& aData);
-
-  DeletedMessageInfo(int32_t* aMessageIds,
-                     uint32_t aMsgCount,
-                     uint64_t* aThreadIds,
-                     uint32_t  aThreadCount);
-
-  static nsresult Create(int32_t* aMessageIds,
-                         uint32_t aMsgCount,
-                         uint64_t* aThreadIds,
-                         uint32_t  aThreadCount,
-                         nsIDeletedMessageInfo** aDeletedInfo);
-
-  const DeletedMessageInfoData& GetData() const { return mData; }
-
-private:
-  // Don't try to use the default constructor.
-  DeletedMessageInfo();
-
-  ~DeletedMessageInfo();
-
-  DeletedMessageInfoData mData;
-
-  nsCOMPtr<nsIWritableVariant> mDeletedMessageIds;
-  nsCOMPtr<nsIWritableVariant> mDeletedThreadIds;
-
-protected:
-  /* additional members */
-};
-
-} // namespace mobilemessage
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_mobilemessage_DeletedMessageInfo_h
deleted file mode 100644
--- a/dom/mobilemessage/MmsMessage.cpp
+++ /dev/null
@@ -1,163 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et cindent: */
-/* 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 "MmsMessage.h"
-
-#include "MmsMessageInternal.h"
-#include "mozilla/dom/MmsMessageBinding.h"
-#include "nsPIDOMWindow.h"
-
-using namespace mozilla::dom::mobilemessage;
-
-namespace mozilla {
-namespace dom {
-
-NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(MmsMessage, mWindow, mMessage)
-NS_IMPL_CYCLE_COLLECTING_ADDREF(MmsMessage)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(MmsMessage)
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MmsMessage)
-  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
-  NS_INTERFACE_MAP_ENTRY(nsISupports)
-NS_INTERFACE_MAP_END
-
-MmsMessage::MmsMessage(nsPIDOMWindowInner* aWindow, MmsMessageInternal* aMessage)
-  : mWindow(aWindow)
-  , mMessage(aMessage)
-{
-}
-
-MmsMessage::~MmsMessage()
-{
-}
-
-JSObject*
-MmsMessage::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
-{
-  return MmsMessageBinding::Wrap(aCx, this, aGivenProto);
-}
-
-void
-MmsMessage::GetType(nsString& aRetVal) const
-{
-  mMessage->GetType(aRetVal);
-}
-
-int32_t
-MmsMessage::Id() const
-{
-  int32_t id;
-  mMessage->GetId(&id);
-  return id;
-}
-
-uint64_t
-MmsMessage::ThreadId() const
-{
-  uint64_t id;
-  mMessage->GetThreadId(&id);
-  return id;
-}
-
-void
-MmsMessage::GetIccId(nsString& aRetVal) const
-{
-  mMessage->GetIccId(aRetVal);
-}
-
-void
-MmsMessage::GetDelivery(nsString& aRetVal) const
-{
-  mMessage->GetDelivery(aRetVal);
-}
-
-void
-MmsMessage::GetDeliveryInfo(nsTArray<MmsDeliveryInfo>& aRetVal) const
-{
-  aRetVal = mMessage->mDeliveryInfo;
-}
-
-void
-MmsMessage::GetSender(nsString& aRetVal) const
-{
-  mMessage->GetSender(aRetVal);
-}
-
-void
-MmsMessage::GetReceivers(nsTArray<nsString>& aRetVal) const
-{
-  aRetVal = mMessage->mReceivers;
-}
-
-uint64_t
-MmsMessage::Timestamp() const
-{
-  uint64_t timestamp;
-  mMessage->GetTimestamp(&timestamp);
-  return timestamp;
-}
-
-uint64_t
-MmsMessage::SentTimestamp() const
-{
-  uint64_t timestamp;
-  mMessage->GetSentTimestamp(&timestamp);
-  return timestamp;
-}
-
-bool
-MmsMessage::Read() const
-{
-  bool read;
-  mMessage->GetRead(&read);
-  return read;
-}
-
-void
-MmsMessage::GetSubject(nsString& aRetVal) const
-{
-  mMessage->GetSubject(aRetVal);
-}
-
-void
-MmsMessage::GetSmil(nsString& aRetVal) const
-{
-  mMessage->GetSmil(aRetVal);
-}
-
-void
-MmsMessage::GetAttachments(nsTArray<MmsAttachment>& aRetVal) const
-{
-  uint32_t length = mMessage->mAttachments.Length();
-
-  // Duplicating the Blob with the correct parent object.
-  for (uint32_t i = 0; i < length; i++) {
-    MmsAttachment attachment;
-    const MmsAttachment &element = mMessage->mAttachments[i];
-    attachment.mId = element.mId;
-    attachment.mLocation = element.mLocation;
-    attachment.mContent = Blob::Create(mWindow, element.mContent->Impl());
-    aRetVal.AppendElement(attachment);
-  }
-}
-
-uint64_t
-MmsMessage::ExpiryDate() const
-{
-  uint64_t date;
-  mMessage->GetExpiryDate(&date);
-  return date;
-}
-
-bool
-MmsMessage::ReadReportRequested() const
-{
-  bool reportRequested;
-  mMessage->GetReadReportRequested(&reportRequested);
-  return reportRequested;
-}
-
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/mobilemessage/MmsMessage.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et cindent: */
-/* 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_MmsMessage_h
-#define mozilla_dom_MmsMessage_h
-
-#include "mozilla/dom/BindingDeclarations.h"
-#include "nsWrapperCache.h"
-
-class nsPIDOMWindowInner;
-
-namespace mozilla {
-namespace dom {
-
-namespace mobilemessage {
-class MmsMessageInternal;
-} // namespace mobilemessage
-
-struct MmsAttachment;
-struct MmsDeliveryInfo;
-
-class MmsMessage final : public nsISupports,
-                         public nsWrapperCache
-{
-public:
-  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MmsMessage)
-
-  MmsMessage(nsPIDOMWindowInner* aWindow,
-             mobilemessage::MmsMessageInternal* aMessage);
-
-  nsPIDOMWindowInner*
-  GetParentObject() const
-  {
-    return mWindow;
-  }
-
-  virtual JSObject*
-  WrapObject(JSContext* aCx,
-             JS::Handle<JSObject*> aGivenProto) override;
-
-  void
-  GetType(nsString& aRetVal) const;
-
-  int32_t
-  Id() const;
-
-  uint64_t
-  ThreadId() const;
-
-  void
-  GetIccId(nsString& aRetVal) const;
-
-  void
-  GetDelivery(nsString& aRetVal) const;
-
-  void
-  GetDeliveryInfo(nsTArray<MmsDeliveryInfo>& aRetVal) const;
-
-  void
-  GetSender(nsString& aRetVal) const;
-
-  void
-  GetReceivers(nsTArray<nsString>& aRetVal) const;
-
-  uint64_t
-  Timestamp() const;
-
-  uint64_t
-  SentTimestamp() const;
-
-  bool
-  Read() const;
-
-  void
-  GetSubject(nsString& aRetVal) const;
-
-  void
-  GetSmil(nsString& aRetVal) const;
-
-  void
-  GetAttachments(nsTArray<MmsAttachment>& aRetVal) const;
-
-  uint64_t
-  ExpiryDate() const;
-
-  bool
-  ReadReportRequested() const;
-
-private:
-  // Don't try to use the default constructor.
-  MmsMessage() = delete;
-
-  ~MmsMessage();
-
-  nsCOMPtr<nsPIDOMWindowInner> mWindow;
-  RefPtr<mobilemessage::MmsMessageInternal> mMessage;
-};
-
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_MmsMessage_h
deleted file mode 100644
--- a/dom/mobilemessage/MmsMessageInternal.cpp
+++ /dev/null
@@ -1,614 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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 "MmsMessageInternal.h"
-
-#include "nsIDOMClassInfo.h"
-#include "jsapi.h" // For JS_IsArrayObject, JS_GetElement, etc.
-#include "nsJSUtils.h"
-#include "nsContentUtils.h"
-#include "nsTArrayHelpers.h"
-#include "mozilla/dom/ContentParent.h"
-#include "mozilla/dom/File.h"
-#include "mozilla/dom/mobilemessage/Constants.h" // For MessageType
-#include "mozilla/dom/mobilemessage/SmsTypes.h"
-#include "mozilla/dom/ScriptSettings.h"
-#include "mozilla/dom/ToJSValue.h"
-#include "mozilla/dom/ipc/BlobChild.h"
-#include "mozilla/dom/ipc/BlobParent.h"
-
-
-namespace mozilla {
-namespace dom {
-namespace mobilemessage {
-
-NS_IMPL_CYCLE_COLLECTION_CLASS(MmsMessageInternal)
-
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(MmsMessageInternal)
-  for (uint32_t i = 0; i < tmp->mAttachments.Length(); i++) {
-    NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAttachments[i].mContent)
-  }
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
-
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(MmsMessageInternal)
-  for (uint32_t i = 0; i < tmp->mAttachments.Length(); i++) {
-    NS_IMPL_CYCLE_COLLECTION_UNLINK(mAttachments[i].mContent)
-  }
-NS_IMPL_CYCLE_COLLECTION_UNLINK_END
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MmsMessageInternal)
-  NS_INTERFACE_MAP_ENTRY(nsIMmsMessage)
-  NS_INTERFACE_MAP_ENTRY(nsISupports)
-NS_INTERFACE_MAP_END
-
-NS_IMPL_CYCLE_COLLECTING_ADDREF(MmsMessageInternal)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(MmsMessageInternal)
-
-MmsMessageInternal::MmsMessageInternal(int32_t                          aId,
-                                       uint64_t                         aThreadId,
-                                       const nsAString&                 aIccId,
-                                       DeliveryState                    aDelivery,
-                                       const nsTArray<MmsDeliveryInfo>& aDeliveryInfo,
-                                       const nsAString&                 aSender,
-                                       const nsTArray<nsString>&        aReceivers,
-                                       uint64_t                         aTimestamp,
-                                       uint64_t                         aSentTimestamp,
-                                       bool                             aRead,
-                                       const nsAString&                 aSubject,
-                                       const nsAString&                 aSmil,
-                                       const nsTArray<MmsAttachment>&   aAttachments,
-                                       uint64_t                         aExpiryDate,
-                                       bool                             aReadReportRequested)
-  : mId(aId),
-    mThreadId(aThreadId),
-    mIccId(aIccId),
-    mDelivery(aDelivery),
-    mDeliveryInfo(aDeliveryInfo),
-    mSender(aSender),
-    mReceivers(aReceivers),
-    mTimestamp(aTimestamp),
-    mSentTimestamp(aSentTimestamp),
-    mRead(aRead),
-    mSubject(aSubject),
-    mSmil(aSmil),
-    mAttachments(aAttachments),
-    mExpiryDate(aExpiryDate),
-    mReadReportRequested(aReadReportRequested)
-{
-}
-
-MmsMessageInternal::MmsMessageInternal(const MmsMessageData& aData)
-  : mId(aData.id())
-  , mThreadId(aData.threadId())
-  , mIccId(aData.iccId())
-  , mDelivery(aData.delivery())
-  , mSender(aData.sender())
-  , mReceivers(aData.receivers())
-  , mTimestamp(aData.timestamp())
-  , mSentTimestamp(aData.sentTimestamp())
-  , mRead(aData.read())
-  , mSubject(aData.subject())
-  , mSmil(aData.smil())
-  , mExpiryDate(aData.expiryDate())
-  , mReadReportRequested(aData.readReportRequested())
-{
-  uint32_t len = aData.attachments().Length();
-  mAttachments.SetCapacity(len);
-  for (uint32_t i = 0; i < len; i++) {
-    MmsAttachment att;
-    const MmsAttachmentData &element = aData.attachments()[i];
-    att.mId = element.id();
-    att.mLocation = element.location();
-
-    // mContent is not going to be exposed to JS directly so we can use
-    // nullptr as parent.
-    if (element.contentParent()) {
-      RefPtr<BlobImpl> impl = static_cast<BlobParent*>(element.contentParent())->GetBlobImpl();
-      att.mContent = Blob::Create(nullptr, impl);
-    } else if (element.contentChild()) {
-      RefPtr<BlobImpl> impl = static_cast<BlobChild*>(element.contentChild())->GetBlobImpl();
-      att.mContent = Blob::Create(nullptr, impl);
-    } else {
-      NS_WARNING("MmsMessage: Unable to get attachment content.");
-    }
-    mAttachments.AppendElement(att);
-  }
-
-  len = aData.deliveryInfo().Length();
-  mDeliveryInfo.SetCapacity(len);
-  for (uint32_t i = 0; i < len; i++) {
-    MmsDeliveryInfo info;
-    const MmsDeliveryInfoData &infoData = aData.deliveryInfo()[i];
-
-    // Prepare |info.mReceiver|.
-    info.mReceiver = infoData.receiver();
-
-    // Prepare |info.mDeliveryStatus|.
-    nsString statusStr;
-    switch (infoData.deliveryStatus()) {
-      case eDeliveryStatus_NotApplicable:
-        statusStr = DELIVERY_STATUS_NOT_APPLICABLE;
-        break;
-      case eDeliveryStatus_Success:
-        statusStr = DELIVERY_STATUS_SUCCESS;
-        break;
-      case eDeliveryStatus_Pending:
-        statusStr = DELIVERY_STATUS_PENDING;
-        break;
-      case eDeliveryStatus_Error:
-        statusStr = DELIVERY_STATUS_ERROR;
-        break;
-      case eDeliveryStatus_Reject:
-        statusStr = DELIVERY_STATUS_REJECTED;
-        break;
-      case eDeliveryStatus_Manual:
-        statusStr = DELIVERY_STATUS_MANUAL;
-        break;
-      case eDeliveryStatus_EndGuard:
-      default:
-        MOZ_CRASH("We shouldn't get any other delivery status!");
-    }
-    info.mDeliveryStatus = statusStr;
-
-    // Prepare |info.mDeliveryTimestamp|.
-    info.mDeliveryTimestamp = infoData.deliveryTimestamp();
-
-    // Prepare |info.mReadStatus|.
-    nsString statusReadString;
-    switch(infoData.readStatus()) {
-      case eReadStatus_NotApplicable:
-        statusReadString = READ_STATUS_NOT_APPLICABLE;
-        break;
-      case eReadStatus_Success:
-        statusReadString = READ_STATUS_SUCCESS;
-        break;
-      case eReadStatus_Pending:
-        statusReadString = READ_STATUS_PENDING;
-        break;
-      case eReadStatus_Error:
-        statusReadString = READ_STATUS_ERROR;
-        break;
-      case eReadStatus_EndGuard:
-      default:
-        MOZ_CRASH("We shouldn't get any other read status!");
-    }
-    info.mReadStatus = statusReadString;
-
-    // Prepare |info.mReadTimestamp|.
-    info.mReadTimestamp = infoData.readTimestamp();
-
-    mDeliveryInfo.AppendElement(info);
-  }
-}
-
-/* static */ nsresult
-MmsMessageInternal::Create(int32_t aId,
-                           uint64_t aThreadId,
-                           const nsAString& aIccId,
-                           const nsAString& aDelivery,
-                           const JS::Value& aDeliveryInfo,
-                           const nsAString& aSender,
-                           const JS::Value& aReceivers,
-                           uint64_t aTimestamp,
-                           uint64_t aSentTimestamp,
-                           bool aRead,
-                           const nsAString& aSubject,
-                           const nsAString& aSmil,
-                           const JS::Value& aAttachments,
-                           uint64_t aExpiryDate,
-                           bool aIsReadReportRequested,
-                           JSContext* aCx,
-                           nsIMmsMessage** aMessage)
-{
-  *aMessage = nullptr;
-
-  // Set |delivery|.
-  DeliveryState delivery;
-  if (aDelivery.Equals(DELIVERY_SENT)) {
-    delivery = eDeliveryState_Sent;
-  } else if (aDelivery.Equals(DELIVERY_RECEIVED)) {
-    delivery = eDeliveryState_Received;
-  } else if (aDelivery.Equals(DELIVERY_SENDING)) {
-    delivery = eDeliveryState_Sending;
-  } else if (aDelivery.Equals(DELIVERY_NOT_DOWNLOADED)) {
-    delivery = eDeliveryState_NotDownloaded;
-  } else if (aDelivery.Equals(DELIVERY_ERROR)) {
-    delivery = eDeliveryState_Error;
-  } else {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  // Set |deliveryInfo|.
-  if (!aDeliveryInfo.isObject()) {
-    return NS_ERROR_INVALID_ARG;
-  }
-  JS::Rooted<JSObject*> deliveryInfoObj(aCx, &aDeliveryInfo.toObject());
-  bool isArray;
-  if (!JS_IsArrayObject(aCx, deliveryInfoObj, &isArray)) {
-    return NS_ERROR_FAILURE;
-  }
-  if (!isArray) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  uint32_t length;
-  MOZ_ALWAYS_TRUE(JS_GetArrayLength(aCx, deliveryInfoObj, &length));
-
-  nsTArray<MmsDeliveryInfo> deliveryInfo;
-  JS::Rooted<JS::Value> infoJsVal(aCx);
-  for (uint32_t i = 0; i < length; ++i) {
-    if (!JS_GetElement(aCx, deliveryInfoObj, i, &infoJsVal) ||
-        !infoJsVal.isObject()) {
-      return NS_ERROR_INVALID_ARG;
-    }
-
-    MmsDeliveryInfo info;
-    if (!info.Init(aCx, infoJsVal)) {
-      return NS_ERROR_TYPE_ERR;
-    }
-
-    deliveryInfo.AppendElement(info);
-  }
-
-  // Set |receivers|.
-  if (!aReceivers.isObject()) {
-    return NS_ERROR_INVALID_ARG;
-  }
-  JS::Rooted<JSObject*> receiversObj(aCx, &aReceivers.toObject());
-  if (!JS_IsArrayObject(aCx, receiversObj, &isArray)) {
-    return NS_ERROR_FAILURE;
-  }
-  if (!isArray) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  MOZ_ALWAYS_TRUE(JS_GetArrayLength(aCx, receiversObj, &length));
-
-  nsTArray<nsString> receivers;
-  JS::Rooted<JS::Value> receiverJsVal(aCx);
-  for (uint32_t i = 0; i < length; ++i) {
-    if (!JS_GetElement(aCx, receiversObj, i, &receiverJsVal) ||
-        !receiverJsVal.isString()) {
-      return NS_ERROR_INVALID_ARG;
-    }
-
-    nsAutoJSString receiverStr;
-    if (!receiverStr.init(aCx, receiverJsVal.toString())) {
-      return NS_ERROR_FAILURE;
-    }
-
-    receivers.AppendElement(receiverStr);
-  }
-
-  // Set |attachments|.
-  if (!aAttachments.isObject()) {
-    return NS_ERROR_INVALID_ARG;
-  }
-  JS::Rooted<JSObject*> attachmentsObj(aCx, &aAttachments.toObject());
-  if (!JS_IsArrayObject(aCx, attachmentsObj, &isArray)) {
-    return NS_ERROR_FAILURE;
-  }
-  if (!isArray) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  nsTArray<MmsAttachment> attachments;
-  MOZ_ALWAYS_TRUE(JS_GetArrayLength(aCx, attachmentsObj, &length));
-
-  JS::Rooted<JS::Value> attachmentJsVal(aCx);
-  for (uint32_t i = 0; i < length; ++i) {
-    if (!JS_GetElement(aCx, attachmentsObj, i, &attachmentJsVal)) {
-      return NS_ERROR_INVALID_ARG;
-    }
-
-    MmsAttachment attachment;
-    if (!attachment.Init(aCx, attachmentJsVal)) {
-      return NS_ERROR_TYPE_ERR;
-    }
-
-    NS_ENSURE_TRUE(attachment.mContent, NS_ERROR_TYPE_ERR);
-
-    attachments.AppendElement(attachment);
-  }
-
-  nsCOMPtr<nsIMmsMessage> message =
-    new MmsMessageInternal(aId,
-                           aThreadId,
-                           aIccId,
-                           delivery,
-                           deliveryInfo,
-                           aSender,
-                           receivers,
-                           aTimestamp,
-                           aSentTimestamp,
-                           aRead,
-                           aSubject,
-                           aSmil,
-                           attachments,
-                           aExpiryDate,
-                           aIsReadReportRequested);
-  message.forget(aMessage);
-  return NS_OK;
-}
-
-bool
-MmsMessageInternal::GetData(ContentParent* aParent,
-                            MmsMessageData& aData)
-{
-  NS_ASSERTION(aParent, "aParent is null");
-
-  aData.id() = mId;
-  aData.threadId() = mThreadId;
-  aData.iccId() = mIccId;
-  aData.delivery() = mDelivery;
-  aData.sender().Assign(mSender);
-  aData.receivers() = mReceivers;
-  aData.timestamp() = mTimestamp;
-  aData.sentTimestamp() = mSentTimestamp;
-  aData.read() = mRead;
-  aData.subject() = mSubject;
-  aData.smil() = mSmil;
-  aData.expiryDate() = mExpiryDate;
-  aData.readReportRequested() = mReadReportRequested;
-
-  aData.deliveryInfo().SetCapacity(mDeliveryInfo.Length());
-  for (uint32_t i = 0; i < mDeliveryInfo.Length(); i++) {
-    MmsDeliveryInfoData infoData;
-    const MmsDeliveryInfo &info = mDeliveryInfo[i];
-
-    // Prepare |infoData.mReceiver|.
-    infoData.receiver().Assign(info.mReceiver);
-
-    // Prepare |infoData.mDeliveryStatus|.
-    DeliveryStatus status;
-    if (info.mDeliveryStatus.Equals(DELIVERY_STATUS_NOT_APPLICABLE)) {
-      status = eDeliveryStatus_NotApplicable;
-    } else if (info.mDeliveryStatus.Equals(DELIVERY_STATUS_SUCCESS)) {
-      status = eDeliveryStatus_Success;
-    } else if (info.mDeliveryStatus.Equals(DELIVERY_STATUS_PENDING)) {
-      status = eDeliveryStatus_Pending;
-    } else if (info.mDeliveryStatus.Equals(DELIVERY_STATUS_ERROR)) {
-      status = eDeliveryStatus_Error;
-    } else if (info.mDeliveryStatus.Equals(DELIVERY_STATUS_REJECTED)) {
-      status = eDeliveryStatus_Reject;
-    } else if (info.mDeliveryStatus.Equals(DELIVERY_STATUS_MANUAL)) {
-      status = eDeliveryStatus_Manual;
-    } else {
-      return false;
-    }
-    infoData.deliveryStatus() = status;
-
-    // Prepare |infoData.mDeliveryTimestamp|.
-    infoData.deliveryTimestamp() = info.mDeliveryTimestamp;
-
-    // Prepare |infoData.mReadStatus|.
-    ReadStatus readStatus;
-    if (info.mReadStatus.Equals(READ_STATUS_NOT_APPLICABLE)) {
-      readStatus = eReadStatus_NotApplicable;
-    } else if (info.mReadStatus.Equals(READ_STATUS_SUCCESS)) {
-      readStatus = eReadStatus_Success;
-    } else if (info.mReadStatus.Equals(READ_STATUS_PENDING)) {
-      readStatus = eReadStatus_Pending;
-    } else if (info.mReadStatus.Equals(READ_STATUS_ERROR)) {
-      readStatus = eReadStatus_Error;
-    } else {
-      return false;
-    }
-    infoData.readStatus() = readStatus;
-
-    // Prepare |infoData.mReadTimestamp|.
-    infoData.readTimestamp() = info.mReadTimestamp;
-
-    aData.deliveryInfo().AppendElement(infoData);
-  }
-
-  aData.attachments().SetCapacity(mAttachments.Length());
-  for (uint32_t i = 0; i < mAttachments.Length(); i++) {
-    MmsAttachmentData mma;
-    const MmsAttachment &element = mAttachments[i];
-    mma.id().Assign(element.mId);
-    mma.location().Assign(element.mLocation);
-
-    // This is a workaround. Sometimes the blob we get from the database
-    // doesn't have a valid last modified date, making the ContentParent
-    // send a "Mystery Blob" to the ContentChild. Attempting to get the
-    // last modified date of blob can force that value to be initialized.
-    RefPtr<BlobImpl> impl = element.mContent->Impl();
-    if (impl && impl->IsDateUnknown()) {
-      ErrorResult rv;
-      impl->GetLastModified(rv);
-      if (rv.Failed()) {
-        NS_WARNING("Failed to get last modified date!");
-        rv.SuppressException();
-      }
-    }
-
-    mma.contentParent() = aParent->GetOrCreateActorForBlob(element.mContent);
-    if (!mma.contentParent()) {
-      return false;
-    }
-    aData.attachments().AppendElement(mma);
-  }
-
-  return true;
-}
-
-NS_IMETHODIMP
-MmsMessageInternal::GetType(nsAString& aType)
-{
-  aType = NS_LITERAL_STRING("mms");
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MmsMessageInternal::GetId(int32_t* aId)
-{
-  *aId = mId;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MmsMessageInternal::GetThreadId(uint64_t* aThreadId)
-{
-  *aThreadId = mThreadId;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MmsMessageInternal::GetIccId(nsAString& aIccId)
-{
-  aIccId = mIccId;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MmsMessageInternal::GetDelivery(nsAString& aDelivery)
-{
-  switch (mDelivery) {
-    case eDeliveryState_Received:
-      aDelivery = DELIVERY_RECEIVED;
-      break;
-    case eDeliveryState_Sending:
-      aDelivery = DELIVERY_SENDING;
-      break;
-    case eDeliveryState_Sent:
-      aDelivery = DELIVERY_SENT;
-      break;
-    case eDeliveryState_Error:
-      aDelivery = DELIVERY_ERROR;
-      break;
-    case eDeliveryState_NotDownloaded:
-      aDelivery = DELIVERY_NOT_DOWNLOADED;
-      break;
-    case eDeliveryState_Unknown:
-    case eDeliveryState_EndGuard:
-    default:
-      MOZ_CRASH("We shouldn't get any other delivery state!");
-  }
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MmsMessageInternal::GetDeliveryInfo(JSContext* aCx, JS::MutableHandle<JS::Value> aDeliveryInfo)
-{
-  // TODO Bug 850525 It'd be better to depend on the delivery of MmsMessage
-  // to return a more correct value. Ex, if .delivery = 'received', we should
-  // also make .deliveryInfo = null, since the .deliveryInfo is useless.
-  uint32_t length = mDeliveryInfo.Length();
-  if (length == 0) {
-    aDeliveryInfo.setNull();
-    return NS_OK;
-  }
-
-  if (!ToJSValue(aCx, mDeliveryInfo, aDeliveryInfo)) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MmsMessageInternal::GetSender(nsAString& aSender)
-{
-  aSender = mSender;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MmsMessageInternal::GetReceivers(JSContext* aCx, JS::MutableHandle<JS::Value> aReceivers)
-{
-  JS::Rooted<JSObject*> receiversObj(aCx);
-  nsresult rv = nsTArrayToJSArray(aCx, mReceivers, &receiversObj);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  aReceivers.setObject(*receiversObj);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MmsMessageInternal::GetTimestamp(DOMTimeStamp* aTimestamp)
-{
-  *aTimestamp = mTimestamp;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MmsMessageInternal::GetSentTimestamp(DOMTimeStamp* aSentTimestamp)
-{
-  *aSentTimestamp = mSentTimestamp;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MmsMessageInternal::GetRead(bool* aRead)
-{
-  *aRead = mRead;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MmsMessageInternal::GetSubject(nsAString& aSubject)
-{
-  aSubject = mSubject;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MmsMessageInternal::GetSmil(nsAString& aSmil)
-{
-  aSmil = mSmil;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MmsMessageInternal::GetAttachments(JSContext* aCx, JS::MutableHandle<JS::Value> aAttachments)
-{
-  uint32_t length = mAttachments.Length();
-
-  if (length == 0) {
-    aAttachments.setNull();
-    return NS_OK;
-  }
-
-  // Duplicating the Blob with the correct parent object.
-  nsIGlobalObject* global = xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx));
-  MOZ_ASSERT(global);
-  nsTArray<MmsAttachment> result;
-  for (uint32_t i = 0; i < length; i++) {
-    MmsAttachment attachment;
-    const MmsAttachment &element = mAttachments[i];
-    attachment.mId = element.mId;
-    attachment.mLocation = element.mLocation;
-    attachment.mContent = Blob::Create(global, element.mContent->Impl());
-    result.AppendElement(attachment);
-  }
-
- if (!ToJSValue(aCx, result, aAttachments)) {
-    JS_ClearPendingException(aCx);
-    return NS_ERROR_TYPE_ERR;
- }
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MmsMessageInternal::GetExpiryDate(DOMTimeStamp* aExpiryDate)
-{
-  *aExpiryDate = mExpiryDate;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MmsMessageInternal::GetReadReportRequested(bool* aReadReportRequested)
-{
-  *aReadReportRequested = mReadReportRequested;
-  return NS_OK;
-}
-
-} // namespace mobilemessage
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/mobilemessage/MmsMessageInternal.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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_MmsMessageInternal_h
-#define mozilla_dom_mobilemessage_MmsMessageInternal_h
-
-#include "nsIMmsMessage.h"
-#include "nsString.h"
-#include "mozilla/dom/mobilemessage/Types.h"
-#include "mozilla/dom/MmsMessageBinding.h"
-#include "mozilla/dom/MozMobileMessageManagerBinding.h"
-#include "mozilla/Attributes.h"
-
-namespace mozilla {
-namespace dom {
-
-class ContentParent;
-class Blob;
-struct MmsAttachment;
-class MmsMessage;
-
-namespace mobilemessage {
-
-class MmsMessageData;
-
-class MmsMessageInternal final : public nsIMmsMessage
-{
-  // This allows the MmsMessage class to access jsval data members
-  // like |deliveryInfo|, |receivers|, and |attachments| without JS API.
-  friend class mozilla::dom::MmsMessage;
-
-public:
-  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_CLASS(MmsMessageInternal)
-  NS_DECL_NSIMMSMESSAGE
-
-  MmsMessageInternal(int32_t aId,
-                     uint64_t aThreadId,
-                     const nsAString& aIccId,
-                     mobilemessage::DeliveryState aDelivery,
-                     const nsTArray<MmsDeliveryInfo>& aDeliveryInfo,
-                     const nsAString& aSender,
-                     const nsTArray<nsString>& aReceivers,
-                     uint64_t aTimestamp,
-                     uint64_t aSentTimestamp,
-                     bool aRead,
-                     const nsAString& aSubject,
-                     const nsAString& aSmil,
-                     const nsTArray<MmsAttachment>& aAttachments,
-                     uint64_t aExpiryDate,
-                     bool aReadReportRequested);
-
-  explicit MmsMessageInternal(const MmsMessageData& aData);
-
-  static nsresult Create(int32_t aId,
-                         uint64_t aThreadId,
-                         const nsAString& aIccId,
-                         const nsAString& aDelivery,
-                         const JS::Value& aDeliveryInfo,
-                         const nsAString& aSender,
-                         const JS::Value& aReceivers,
-                         uint64_t aTimestamp,
-                         uint64_t aSentTimestamp,
-                         bool aRead,
-                         const nsAString& aSubject,
-                         const nsAString& aSmil,
-                         const JS::Value& aAttachments,
-                         uint64_t aExpiryDate,
-                         bool aReadReportRequested,
-                         JSContext* aCx,
-                         nsIMmsMessage** aMessage);
-
-  bool GetData(ContentParent* aParent,
-               MmsMessageData& aData);
-
-private:
-
-  ~MmsMessageInternal() {}
-
-  int32_t mId;
-  uint64_t mThreadId;
-  nsString mIccId;
-  mobilemessage::DeliveryState mDelivery;
-  nsTArray<MmsDeliveryInfo> mDeliveryInfo;
-  nsString mSender;
-  nsTArray<nsString> mReceivers;
-  uint64_t mTimestamp;
-  uint64_t mSentTimestamp;
-  bool mRead;
-  nsString mSubject;
-  nsString mSmil;
-  nsTArray<MmsAttachment> mAttachments;
-  uint64_t mExpiryDate;
-  bool mReadReportRequested;
-};
-
-} // namespace mobilemessage
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_mobilemessage_MmsMessageInternal_h
deleted file mode 100644
--- a/dom/mobilemessage/MobileMessageCallback.cpp
+++ /dev/null
@@ -1,381 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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 "MobileMessageCallback.h"
-#include "mozilla/dom/ToJSValue.h"
-#include "nsContentUtils.h"
-#include "nsIScriptGlobalObject.h"
-#include "nsPIDOMWindow.h"
-#include "MmsMessage.h"
-#include "MmsMessageInternal.h"
-#include "SmsMessage.h"
-#include "SmsMessageInternal.h"
-#include "mozilla/dom/ScriptSettings.h"
-#include "jsapi.h"
-#include "xpcpublic.h"
-#include "nsServiceManagerUtils.h"
-#include "nsTArrayHelpers.h"
-#include "DOMMobileMessageError.h"
-#include "mozilla/dom/Promise.h"
-
-namespace mozilla {
-namespace dom {
-namespace mobilemessage {
-
-static nsAutoString
-ConvertErrorCodeToErrorString(int32_t aError)
-{
-  nsAutoString errorStr;
-  switch (aError) {
-    case nsIMobileMessageCallback::NO_SIGNAL_ERROR:
-      errorStr = NS_LITERAL_STRING("NoSignalError");
-      break;
-    case nsIMobileMessageCallback::NOT_FOUND_ERROR:
-      errorStr = NS_LITERAL_STRING("NotFoundError");
-      break;
-    case nsIMobileMessageCallback::UNKNOWN_ERROR:
-      errorStr = NS_LITERAL_STRING("UnknownError");
-      break;
-    case nsIMobileMessageCallback::INTERNAL_ERROR:
-      errorStr = NS_LITERAL_STRING("InternalError");
-      break;
-    case nsIMobileMessageCallback::NO_SIM_CARD_ERROR:
-      errorStr = NS_LITERAL_STRING("NoSimCardError");
-      break;
-    case nsIMobileMessageCallback::RADIO_DISABLED_ERROR:
-      errorStr = NS_LITERAL_STRING("RadioDisabledError");
-      break;
-    case nsIMobileMessageCallback::INVALID_ADDRESS_ERROR:
-      errorStr = NS_LITERAL_STRING("InvalidAddressError");
-      break;
-    case nsIMobileMessageCallback::FDN_CHECK_ERROR:
-      errorStr = NS_LITERAL_STRING("FdnCheckError");
-      break;
-    case nsIMobileMessageCallback::NON_ACTIVE_SIM_CARD_ERROR:
-      errorStr = NS_LITERAL_STRING("NonActiveSimCardError");
-      break;
-    case nsIMobileMessageCallback::STORAGE_FULL_ERROR:
-      errorStr = NS_LITERAL_STRING("StorageFullError");
-      break;
-    case nsIMobileMessageCallback::SIM_NOT_MATCHED_ERROR:
-      errorStr = NS_LITERAL_STRING("SimNotMatchedError");
-      break;
-    case nsIMobileMessageCallback::NETWORK_PROBLEMS_ERROR:
-      errorStr = NS_LITERAL_STRING("NetworkProblemsError");
-      break;
-    case nsIMobileMessageCallback::GENERAL_PROBLEMS_ERROR:
-      errorStr = NS_LITERAL_STRING("GeneralProblemsError");
-      break;
-    case nsIMobileMessageCallback::SERVICE_NOT_AVAILABLE_ERROR:
-      errorStr = NS_LITERAL_STRING("ServiceNotAvailableError");
-      break;
-    case nsIMobileMessageCallback::MESSAGE_TOO_LONG_FOR_NETWORK_ERROR:
-      errorStr = NS_LITERAL_STRING("MessageTooLongForNetworkError");
-      break;
-    case nsIMobileMessageCallback::SERVICE_NOT_SUPPORTED_ERROR:
-      errorStr = NS_LITERAL_STRING("ServiceNotSupportedError");
-      break;
-    case nsIMobileMessageCallback::RETRY_REQUIRED_ERROR:
-      errorStr = NS_LITERAL_STRING("RetryRequiredError");
-      break;
-    default: // SUCCESS_NO_ERROR is handled above.
-      MOZ_CRASH("Should never get here!");
-  }
-
-  return errorStr;
-}
-
-NS_IMPL_ADDREF(MobileMessageCallback)
-NS_IMPL_RELEASE(MobileMessageCallback)
-
-NS_INTERFACE_MAP_BEGIN(MobileMessageCallback)
-  NS_INTERFACE_MAP_ENTRY(nsIMobileMessageCallback)
-  NS_INTERFACE_MAP_ENTRY(nsISupports)
-NS_INTERFACE_MAP_END
-
-MobileMessageCallback::MobileMessageCallback(DOMRequest* aDOMRequest)
-  : mDOMRequest(aDOMRequest)
-{
-}
-
-MobileMessageCallback::MobileMessageCallback(Promise* aPromise)
-  : mPromise(aPromise)
-{
-}
-
-MobileMessageCallback::~MobileMessageCallback()
-{
-}
-
-
-nsresult
-MobileMessageCallback::NotifySuccess(JS::Handle<JS::Value> aResult, bool aAsync)
-{
-  if (NS_WARN_IF(!mDOMRequest->GetOwner())) {
-    return NS_ERROR_FAILURE;
-  }
-
-  if (aAsync) {
-    nsCOMPtr<nsIDOMRequestService> rs =
-      do_GetService(DOMREQUEST_SERVICE_CONTRACTID);
-    NS_ENSURE_TRUE(rs, NS_ERROR_FAILURE);
-
-    return rs->FireSuccessAsync(mDOMRequest, aResult);
-  }
-
-  mDOMRequest->FireSuccess(aResult);
-  return NS_OK;
-}
-
-nsresult
-MobileMessageCallback::NotifySuccess(nsISupports *aMessage, bool aAsync)
-{
-  nsCOMPtr<nsPIDOMWindowInner> window = mDOMRequest->GetOwner();
-  NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
-
-  nsCOMPtr<nsISupports> result;
-
-  nsCOMPtr<nsISmsMessage> internalSms =
-    do_QueryInterface(aMessage);
-  if (internalSms) {
-    SmsMessageInternal* smsMsg = static_cast<SmsMessageInternal*>(internalSms.get());
-    result = new SmsMessage(window, smsMsg);
-  }
-
-  if (!result) {
-    nsCOMPtr<nsIMmsMessage> internalMms =
-      do_QueryInterface(aMessage);
-    if (internalMms) {
-      MmsMessageInternal* mmsMsg = static_cast<MmsMessageInternal*>(internalMms.get());
-      result = new MmsMessage(window, mmsMsg);
-    }
-  }
-
-  AutoJSAPI jsapi;
-  if (NS_WARN_IF(!jsapi.Init(window))) {
-    return NS_ERROR_FAILURE;
-  }
-  JSContext* cx = jsapi.cx();
-
-  JS::Rooted<JS::Value> wrappedMessage(cx);
-  nsresult rv =
-    nsContentUtils::WrapNative(cx, result, &wrappedMessage);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  return NotifySuccess(wrappedMessage, aAsync);
-}
-
-nsresult
-MobileMessageCallback::NotifyError(int32_t aError, DOMError *aDetailedError, bool aAsync)
-{
-  if (NS_WARN_IF(!mDOMRequest->GetOwner())) {
-    return NS_ERROR_FAILURE;
-  }
-
-  if (aAsync) {
-    NS_ASSERTION(!aDetailedError,
-      "No Support to FireDetailedErrorAsync() in nsIDOMRequestService!");
-
-    nsCOMPtr<nsIDOMRequestService> rs =
-      do_GetService(DOMREQUEST_SERVICE_CONTRACTID);
-    NS_ENSURE_TRUE(rs, NS_ERROR_FAILURE);
-
-    return rs->FireErrorAsync(mDOMRequest,
-                              ConvertErrorCodeToErrorString(aError));
-  }
-
-  if (aDetailedError) {
-    mDOMRequest->FireDetailedError(aDetailedError);
-  } else {
-    mDOMRequest->FireError(ConvertErrorCodeToErrorString(aError));
-  }
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileMessageCallback::NotifyMessageSent(nsISupports *aMessage)
-{
-  return NotifySuccess(aMessage);
-}
-
-NS_IMETHODIMP
-MobileMessageCallback::NotifySendMessageFailed(int32_t aError, nsISupports *aMessage)
-{
-  nsCOMPtr<nsPIDOMWindowInner> window = mDOMRequest->GetOwner();
-  if (NS_WARN_IF(!window)) {
-    return NS_ERROR_FAILURE;
-  }
-
-  RefPtr<DOMMobileMessageError> domMobileMessageError;
-  if (aMessage) {
-    nsAutoString errorStr = ConvertErrorCodeToErrorString(aError);
-    nsCOMPtr<nsISmsMessage> internalSms = do_QueryInterface(aMessage);
-    if (internalSms) {
-      domMobileMessageError =
-        new DOMMobileMessageError(window, errorStr,
-                                  new SmsMessage(window,
-                                  static_cast<SmsMessageInternal*>(internalSms.get())));
-    }
-    else {
-      nsCOMPtr<nsIMmsMessage> internalMms = do_QueryInterface(aMessage);
-      domMobileMessageError =
-        new DOMMobileMessageError(window, errorStr,
-                                  new MmsMessage(window,
-                                  static_cast<MmsMessageInternal*>(internalMms.get())));
-    }
-    NS_ASSERTION(domMobileMessageError, "Invalid DOMMobileMessageError!");
-  }
-
-  return NotifyError(aError, domMobileMessageError);
-}
-
-NS_IMETHODIMP
-MobileMessageCallback::NotifyMessageGot(nsISupports *aMessage)
-{
-  return NotifySuccess(aMessage);
-}
-
-NS_IMETHODIMP
-MobileMessageCallback::NotifyGetMessageFailed(int32_t aError)
-{
-  return NotifyError(aError);
-}
-
-NS_IMETHODIMP
-MobileMessageCallback::NotifyMessageDeleted(bool *aDeleted, uint32_t aSize)
-{
-  if (aSize == 1) {
-    AutoJSContext cx;
-    JS::Rooted<JS::Value> val(cx, JS::BooleanValue(*aDeleted));
-    return NotifySuccess(val);
-  }
-
-  AutoJSAPI jsapi;
-  if (NS_WARN_IF(!jsapi.Init(mDOMRequest->GetOwner()))) {
-    return NS_ERROR_FAILURE;
-  }
-  JSContext* cx = jsapi.cx();
-
-  JS::Rooted<JSObject*> deleteArrayObj(cx, JS_NewArrayObject(cx, aSize));
-  if (!deleteArrayObj) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
-  for (uint32_t i = 0; i < aSize; i++) {
-    if (!JS_DefineElement(cx, deleteArrayObj, i, aDeleted[i],
-                          JSPROP_ENUMERATE)) {
-      return NS_ERROR_UNEXPECTED;
-    }
-  }
-
-  JS::Rooted<JS::Value> deleteArrayVal(cx, JS::ObjectValue(*deleteArrayObj));
-  return NotifySuccess(deleteArrayVal);
-}
-
-NS_IMETHODIMP
-MobileMessageCallback::NotifyDeleteMessageFailed(int32_t aError)
-{
-  return NotifyError(aError);
-}
-
-NS_IMETHODIMP
-MobileMessageCallback::NotifyMessageMarkedRead(bool aRead)
-{
-  AutoJSContext cx;
-  JS::Rooted<JS::Value> val(cx, JS::BooleanValue(aRead));
-  return NotifySuccess(val);
-}
-
-NS_IMETHODIMP
-MobileMessageCallback::NotifyMarkMessageReadFailed(int32_t aError)
-{
-  return NotifyError(aError);
-}
-
-NS_IMETHODIMP
-MobileMessageCallback::NotifySegmentInfoForTextGot(int32_t aSegments,
-                                                   int32_t aCharsPerSegment,
-                                                   int32_t aCharsAvailableInLastSegment)
-{
-  AutoJSAPI jsapi;
-  if (NS_WARN_IF(!jsapi.Init(mDOMRequest->GetOwner()))) {
-    return NotifyError(nsIMobileMessageCallback::INTERNAL_ERROR);
-  }
-
-  SmsSegmentInfo info;
-  info.mSegments = aSegments;
-  info.mCharsPerSegment = aCharsPerSegment;
-  info.mCharsAvailableInLastSegment = aCharsAvailableInLastSegment;
-
-  JSContext* cx = jsapi.cx();
-  JS::Rooted<JS::Value> val(cx);
-  if (!ToJSValue(cx, info, &val)) {
-    jsapi.ClearException();
-    return NotifyError(nsIMobileMessageCallback::INTERNAL_ERROR);
-  }
-
-  return NotifySuccess(val, true);
-}
-
-NS_IMETHODIMP
-MobileMessageCallback::NotifyGetSegmentInfoForTextFailed(int32_t aError)
-{
-  return NotifyError(aError, nullptr, true);
-}
-
-NS_IMETHODIMP
-MobileMessageCallback::NotifyGetSmscAddress(const nsAString& aSmscAddress,
-                                            uint32_t aTypeOfNumber,
-                                            uint32_t aNumberPlanIdentification)
-{
-  TypeOfAddress toa;
-
-  // Check the value is valid and set TON accordingly.
-  bool isTonValid = aTypeOfNumber < uint32_t(TypeOfNumber::EndGuard_);
-  toa.mTypeOfNumber = (isTonValid) ?
-    static_cast<TypeOfNumber>(aTypeOfNumber) : TypeOfNumber::Unknown;
-
-  // Check the value is valid and set NPI accordingly.
-  bool isNpiValid =
-    aNumberPlanIdentification < uint32_t(NumberPlanIdentification::EndGuard_);
-  toa.mNumberPlanIdentification = (isNpiValid) ?
-    static_cast<NumberPlanIdentification>(aNumberPlanIdentification) :
-    NumberPlanIdentification::Unknown;
-
-  SmscAddress smsc;
-  smsc.mTypeOfAddress = toa;
-  smsc.mAddress.Construct(nsString(aSmscAddress));
-
-  mPromise->MaybeResolve(smsc);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileMessageCallback::NotifyGetSmscAddressFailed(int32_t aError)
-{
-  const nsAString& errorStr = ConvertErrorCodeToErrorString(aError);
-  mPromise->MaybeRejectBrokenly(errorStr);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileMessageCallback::NotifySetSmscAddress()
-{
-  mPromise->MaybeResolveWithUndefined();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileMessageCallback::NotifySetSmscAddressFailed(int32_t aError)
-{
-  const nsAString& errorStr = ConvertErrorCodeToErrorString(aError);
-  mPromise->MaybeRejectBrokenly(errorStr);
-  return NS_OK;
-}
-
-} // namespace mobilemessage
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/mobilemessage/MobileMessageCallback.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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_MobileMessageCallback_h
-#define mozilla_dom_mobilemessage_MobileMessageCallback_h
-
-#include "nsIMobileMessageCallback.h"
-#include "nsCOMPtr.h"
-#include "DOMRequest.h"
-
-class Promise;
-
-namespace mozilla {
-namespace dom {
-namespace mobilemessage {
-
-class MobileMessageCallback final : public nsIMobileMessageCallback
-{
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIMOBILEMESSAGECALLBACK
-
-  explicit MobileMessageCallback(DOMRequest* aDOMRequest);
-  explicit MobileMessageCallback(Promise* aPromise);
-
-private:
-  ~MobileMessageCallback();
-
-  RefPtr<DOMRequest> mDOMRequest;
-  RefPtr<Promise> mPromise;
-
-  nsresult NotifySuccess(JS::Handle<JS::Value> aResult, bool aAsync = false);
-  nsresult NotifySuccess(nsISupports *aMessage, bool aAsync = false);
-  nsresult NotifyError(int32_t aError, DOMError *aDetailedError = nullptr, bool aAsync = false);
-};
-
-} // namespace mobilemessage
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_mobilemessage_MobileMessageCallback_h
deleted file mode 100644
--- a/dom/mobilemessage/MobileMessageCursorCallback.cpp
+++ /dev/null
@@ -1,216 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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 "MobileMessageCursorCallback.h"
-#include "MmsMessage.h"
-#include "MmsMessageInternal.h"
-#include "MobileMessageThread.h"
-#include "MobileMessageThreadInternal.h"
-#include "mozilla/dom/ScriptSettings.h"
-#include "nsIDOMDOMRequest.h"
-#include "SmsMessage.h"
-#include "SmsMessageInternal.h"
-#include "nsIMobileMessageCallback.h"
-#include "nsServiceManagerUtils.h"      // for do_GetService
-
-namespace mozilla {
-namespace dom {
-
-NS_IMPL_CYCLE_COLLECTION_INHERITED(MobileMessageCursor, DOMCursor,
-                                   mPendingResults)
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(MobileMessageCursor)
-NS_INTERFACE_MAP_END_INHERITING(DOMCursor)
-
-NS_IMPL_ADDREF_INHERITED(MobileMessageCursor, DOMCursor)
-NS_IMPL_RELEASE_INHERITED(MobileMessageCursor, DOMCursor)
-
-MobileMessageCursor::MobileMessageCursor(nsPIDOMWindowInner* aWindow,
-                                         nsICursorContinueCallback* aCallback)
-  : DOMCursor(aWindow, aCallback)
-{
-}
-
-NS_IMETHODIMP
-MobileMessageCursor::Continue()
-{
-  // We have originally:
-  //
-  //   DOMCursor::Continue()
-  //   +-> DOMCursor::Continue(ErrorResult& aRv)
-  //
-  // Now it becomes:
-  //
-  //   MobileMessageCursor::Continue()
-  //   +-> DOMCursor::Continue()
-  //       +-> MobileMessageCursor::Continue(ErrorResult& aRv)
-  //           o-> DOMCursor::Continue(ErrorResult& aRv)
-  return DOMCursor::Continue();
-}
-
-void
-MobileMessageCursor::Continue(ErrorResult& aRv)
-{
-  // An ordinary DOMCursor works in following flow:
-  //
-  //   DOMCursor::Continue()
-  //   +-> DOMCursor::Reset()
-  //   +-> nsICursorContinueCallback::HandleContinue()
-  //       +-> nsIMobileMessageCursorCallback::NotifyCursorResult()
-  //           +-> DOMCursor::FireSuccess()
-  //
-  // With no pending result, we call to |DOMCursor::Continue()| as usual.
-  if (!mPendingResults.Length()) {
-    DOMCursor::Continue(aRv);
-    return;
-  }
-
-  // Otherwise, reset current result and fire a success event with the last
-  // pending one.
-  Reset();
-
-  nsresult rv = FireSuccessWithNextPendingResult();
-  if (NS_FAILED(rv)) {
-    aRv.Throw(rv);
-  }
-}
-
-nsresult
-MobileMessageCursor::FireSuccessWithNextPendingResult()
-{
-  // We're going to pop the last element from mPendingResults, so it must not
-  // be empty.
-  MOZ_ASSERT(mPendingResults.Length());
-
-  nsCOMPtr<nsISupports> result;
-
-  nsCOMPtr<nsIMobileMessageThread> internalThread =
-    do_QueryInterface(mPendingResults.LastElement());
-  if (internalThread) {
-    MobileMessageThreadInternal* thread =
-      static_cast<MobileMessageThreadInternal*>(internalThread.get());
-    result = new MobileMessageThread(GetOwner(), thread);
-  }
-
-  if (!result) {
-    nsCOMPtr<nsISmsMessage> internalSms =
-      do_QueryInterface(mPendingResults.LastElement());
-    if (internalSms) {
-      SmsMessageInternal* sms = static_cast<SmsMessageInternal*>(internalSms.get());
-      result = new SmsMessage(GetOwner(), sms);
-    }
-  }
-
-  if (!result) {
-    nsCOMPtr<nsIMmsMessage> internalMms =
-      do_QueryInterface(mPendingResults.LastElement());
-    if (internalMms) {
-      MmsMessageInternal* mms = static_cast<MmsMessageInternal*>(internalMms.get());
-      result = new MmsMessage(GetOwner(), mms);
-    }
-  }
-
-  MOZ_ASSERT(result);
-
-  AutoJSAPI jsapi;
-  if (NS_WARN_IF(!jsapi.Init(GetOwner()))) {
-    return NS_ERROR_FAILURE;
-  }
-
-  JSContext* cx = jsapi.cx();
-  JS::Rooted<JS::Value> val(cx);
-  nsresult rv =
-    nsContentUtils::WrapNative(cx, result, &val);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  mPendingResults.RemoveElementAt(mPendingResults.Length() - 1);
-
-  FireSuccess(val);
-  return NS_OK;
-}
-
-namespace mobilemessage {
-
-NS_IMPL_CYCLE_COLLECTION(MobileMessageCursorCallback, mDOMCursor)
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MobileMessageCursorCallback)
-  NS_INTERFACE_MAP_ENTRY(nsIMobileMessageCursorCallback)
-  NS_INTERFACE_MAP_ENTRY(nsISupports)
-NS_INTERFACE_MAP_END
-
-NS_IMPL_CYCLE_COLLECTING_ADDREF(MobileMessageCursorCallback)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(MobileMessageCursorCallback)
-
-// nsIMobileMessageCursorCallback
-
-NS_IMETHODIMP
-MobileMessageCursorCallback::NotifyCursorError(int32_t aError)
-{
-  MOZ_ASSERT(mDOMCursor);
-
-  RefPtr<DOMCursor> cursor = mDOMCursor.forget();
-
-  switch (aError) {
-    case nsIMobileMessageCallback::NO_SIGNAL_ERROR:
-      cursor->FireError(NS_LITERAL_STRING("NoSignalError"));
-      break;
-    case nsIMobileMessageCallback::NOT_FOUND_ERROR:
-      cursor->FireError(NS_LITERAL_STRING("NotFoundError"));
-      break;
-    case nsIMobileMessageCallback::UNKNOWN_ERROR:
-      cursor->FireError(NS_LITERAL_STRING("UnknownError"));
-      break;
-    case nsIMobileMessageCallback::INTERNAL_ERROR:
-      cursor->FireError(NS_LITERAL_STRING("InternalError"));
-      break;
-    default: // SUCCESS_NO_ERROR is handled above.
-      MOZ_CRASH("Should never get here!");
-  }
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileMessageCursorCallback::NotifyCursorResult(nsISupports** aResults,
-                                                uint32_t aSize)
-{
-  MOZ_ASSERT(mDOMCursor);
-  // We should only be notified with valid results. Or, either
-  // |NotifyCursorDone()| or |NotifyCursorError()| should be called instead.
-  MOZ_ASSERT(aResults && *aResults && aSize);
-  // There shouldn't be unexpected notifications before |Continue()| is called.
-  nsTArray<nsCOMPtr<nsISupports>>& pending = mDOMCursor->mPendingResults;
-  MOZ_ASSERT(pending.Length() == 0);
-
-  // Push pending results in reversed order.
-  pending.SetCapacity(pending.Length() + aSize);
-  while (aSize) {
-    --aSize;
-    pending.AppendElement(aResults[aSize]);
-  }
-
-  nsresult rv = mDOMCursor->FireSuccessWithNextPendingResult();
-  if (NS_FAILED(rv)) {
-    NotifyCursorError(nsIMobileMessageCallback::INTERNAL_ERROR);
-  }
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileMessageCursorCallback::NotifyCursorDone()
-{
-  MOZ_ASSERT(mDOMCursor);
-
-  RefPtr<DOMCursor> cursor = mDOMCursor.forget();
-  cursor->FireDone();
-
-  return NS_OK;
-}
-
-} // namespace mobilemessage
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/mobilemessage/MobileMessageCursorCallback.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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_MobileMessageCursorCallback_h
-#define mozilla_dom_mobilemessage_MobileMessageCursorCallback_h
-
-#include "mozilla/Attributes.h"
-#include "mozilla/dom/DOMCursor.h"
-#include "nsIMobileMessageCursorCallback.h"
-#include "nsCycleCollectionParticipant.h"
-#include "nsCOMPtr.h"
-
-class nsICursorContinueCallback;
-
-namespace mozilla {
-namespace dom {
-
-class MobileMessageManager;
-
-namespace mobilemessage {
-class MobileMessageCursorCallback;
-} // namespace mobilemessage
-
-class MobileMessageCursor final : public DOMCursor
-{
-  friend class mobilemessage::MobileMessageCursorCallback;
-
-public:
-  NS_DECL_ISUPPORTS_INHERITED
-
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MobileMessageCursor, DOMCursor)
-
-  MobileMessageCursor(nsPIDOMWindowInner* aWindow,
-                      nsICursorContinueCallback* aCallback);
-
-  // Override XPIDL continue function to suppress -Werror,-Woverloaded-virtual.
-  NS_IMETHOD
-  Continue(void) override;
-
-  virtual void
-  Continue(ErrorResult& aRv) override;
-
-private:
-  // final suppresses -Werror,-Wdelete-non-virtual-dtor
-  ~MobileMessageCursor() {}
-
-private:
-  // List of read-ahead results in reversed order.
-  nsTArray<nsCOMPtr<nsISupports>> mPendingResults;
-
-  nsresult
-  FireSuccessWithNextPendingResult();
-};
-
-namespace mobilemessage {
-
-class MobileMessageCursorCallback final : public nsIMobileMessageCursorCallback
-{
-  friend class mozilla::dom::MobileMessageManager;
-
-public:
-  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_NSIMOBILEMESSAGECURSORCALLBACK
-
-  NS_DECL_CYCLE_COLLECTION_CLASS(MobileMessageCursorCallback)
-
-  MobileMessageCursorCallback()
-  {
-    MOZ_COUNT_CTOR(MobileMessageCursorCallback);
-  }
-
-private:
-  // final suppresses -Werror,-Wdelete-non-virtual-dtor
-  ~MobileMessageCursorCallback()
-  {
-    MOZ_COUNT_DTOR(MobileMessageCursorCallback);
-  }
-
-  RefPtr<MobileMessageCursor> mDOMCursor;
-};
-
-} // namespace mobilemessage
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_mobilemessage_MobileMessageCursorCallback_h
-
deleted file mode 100644
--- a/dom/mobilemessage/MobileMessageManager.cpp
+++ /dev/null
@@ -1,905 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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 "MobileMessageManager.h"
-
-#include "DeletedMessageInfo.h"
-#include "DOMCursor.h"
-#include "DOMRequest.h"
-#include "MmsMessage.h"
-#include "MmsMessageInternal.h"
-#include "MobileMessageCallback.h"
-#include "MobileMessageCursorCallback.h"
-#include "SmsMessage.h"
-#include "SmsMessageInternal.h"
-#include "mozilla/dom/mobilemessage/Constants.h" // For kSms*ObserverTopic
-#include "mozilla/dom/MozMessageDeletedEvent.h"
-#include "mozilla/dom/MozMmsEvent.h"
-#include "mozilla/dom/MozMobileMessageManagerBinding.h"
-#include "mozilla/dom/MozSmsEvent.h"
-#include "mozilla/dom/Promise.h"
-#include "mozilla/dom/ToJSValue.h"
-#include "mozilla/Preferences.h"
-#include "mozilla/Services.h"
-#include "mozilla/UniquePtr.h"
-#include "nsIMmsService.h"
-#include "nsIMobileMessageCallback.h"
-#include "nsIMobileMessageDatabaseService.h"
-#include "nsIMobileMessageService.h"
-#include "nsIObserverService.h"
-#include "nsISmsService.h"
-#include "nsServiceManagerUtils.h" // For do_GetService()
-
-// Service instantiation
-#include "ipc/SmsIPCService.h"
-#include "MobileMessageService.h"
-#if defined(MOZ_WIDGET_ANDROID) && defined(MOZ_WEBSMS_BACKEND)
-#include "android/MobileMessageDatabaseService.h"
-#include "android/SmsService.h"
-#elif defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
-#include "nsIGonkMobileMessageDatabaseService.h"
-#include "nsIGonkSmsService.h"
-#endif
-#include "nsXULAppAPI.h" // For XRE_GetProcessType()
-
-#define RECEIVED_EVENT_NAME         NS_LITERAL_STRING("received")
-#define RETRIEVING_EVENT_NAME       NS_LITERAL_STRING("retrieving")
-#define SENDING_EVENT_NAME          NS_LITERAL_STRING("sending")
-#define SENT_EVENT_NAME             NS_LITERAL_STRING("sent")
-#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")
-#define DELETED_EVENT_NAME          NS_LITERAL_STRING("deleted")
-
-using namespace mozilla::dom::mobilemessage;
-
-namespace mozilla {
-namespace dom {
-
-NS_INTERFACE_MAP_BEGIN(MobileMessageManager)
-  NS_INTERFACE_MAP_ENTRY(nsIObserver)
-NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
-
-NS_IMPL_ADDREF_INHERITED(MobileMessageManager, DOMEventTargetHelper)
-NS_IMPL_RELEASE_INHERITED(MobileMessageManager, DOMEventTargetHelper)
-
-MobileMessageManager::MobileMessageManager(nsPIDOMWindowInner* aWindow)
-  : DOMEventTargetHelper(aWindow)
-{
-}
-
-void
-MobileMessageManager::Init()
-{
-  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);
-  obs->AddObserver(this, kSmsSendingObserverTopic, false);
-  obs->AddObserver(this, kSmsSentObserverTopic, false);
-  obs->AddObserver(this, kSmsFailedObserverTopic, false);
-  obs->AddObserver(this, kSmsDeliverySuccessObserverTopic, false);
-  obs->AddObserver(this, kSmsDeliveryErrorObserverTopic, false);
-  obs->AddObserver(this, kSmsReadSuccessObserverTopic, false);
-  obs->AddObserver(this, kSmsReadErrorObserverTopic, false);
-  obs->AddObserver(this, kSmsDeletedObserverTopic, false);
-}
-
-void
-MobileMessageManager::Shutdown()
-{
-  nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
-  // GetObserverService() can return null is some situations like shutdown.
-  if (!obs) {
-    return;
-  }
-
-  obs->RemoveObserver(this, kSmsReceivedObserverTopic);
-  obs->RemoveObserver(this, kSmsRetrievingObserverTopic);
-  obs->RemoveObserver(this, kSmsSendingObserverTopic);
-  obs->RemoveObserver(this, kSmsSentObserverTopic);
-  obs->RemoveObserver(this, kSmsFailedObserverTopic);
-  obs->RemoveObserver(this, kSmsDeliverySuccessObserverTopic);
-  obs->RemoveObserver(this, kSmsDeliveryErrorObserverTopic);
-  obs->RemoveObserver(this, kSmsReadSuccessObserverTopic);
-  obs->RemoveObserver(this, kSmsReadErrorObserverTopic);
-  obs->RemoveObserver(this, kSmsDeletedObserverTopic);
-}
-
-JSObject*
-MobileMessageManager::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
-{
-  return MozMobileMessageManagerBinding::Wrap(aCx, this, aGivenProto);
-}
-
-already_AddRefed<DOMRequest>
-MobileMessageManager::GetSegmentInfoForText(const nsAString& aText,
-                                            ErrorResult& aRv)
-{
-  nsCOMPtr<nsISmsService> smsService = do_GetService(SMS_SERVICE_CONTRACTID);
-  if (!smsService) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
-  if (!window) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  RefPtr<DOMRequest> request = new DOMRequest(window);
-  nsCOMPtr<nsIMobileMessageCallback> msgCallback =
-    new MobileMessageCallback(request);
-  nsresult rv = smsService->GetSegmentInfoForText(aText, msgCallback);
-  if (NS_FAILED(rv)) {
-    aRv.Throw(rv);
-    return nullptr;
-  }
-
-  return request.forget();
-}
-
-already_AddRefed<DOMRequest>
-MobileMessageManager::Send(nsISmsService* aSmsService,
-                           uint32_t aServiceId,
-                           const nsAString& aNumber,
-                           const nsAString& aText,
-                           ErrorResult& aRv)
-{
-  nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
-  if (!window) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  RefPtr<DOMRequest> request = new DOMRequest(window);
-  nsCOMPtr<nsIMobileMessageCallback> msgCallback =
-    new MobileMessageCallback(request);
-
-  // By default, we don't send silent messages via MobileMessageManager.
-  nsresult rv = aSmsService->Send(aServiceId, aNumber, aText,
-                                  false, msgCallback);
-  if (NS_FAILED(rv)) {
-    aRv.Throw(rv);
-    return nullptr;
-  }
-
-  return request.forget();
-}
-
-already_AddRefed<DOMRequest>
-MobileMessageManager::Send(const nsAString& aNumber,
-                           const nsAString& aText,
-                           const SmsSendParameters& aSendParams,
-                           ErrorResult& aRv)
-{
-  nsCOMPtr<nsISmsService> smsService = do_GetService(SMS_SERVICE_CONTRACTID);
-  if (!smsService) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  // Use the default one unless |aSendParams.serviceId| is available.
-  uint32_t serviceId;
-  if (aSendParams.mServiceId.WasPassed()) {
-    serviceId = aSendParams.mServiceId.Value();
-  } else {
-    nsresult rv = smsService->GetSmsDefaultServiceId(&serviceId);
-    if (NS_FAILED(rv)) {
-      aRv.Throw(rv);
-      return nullptr;
-    }
-  }
-
-  return Send(smsService, serviceId, aNumber, aText, aRv);
-}
-
-void
-MobileMessageManager::Send(const Sequence<nsString>& aNumbers,
-                           const nsAString& aText,
-                           const SmsSendParameters& aSendParams,
-                           nsTArray<RefPtr<DOMRequest>>& aReturn,
-                           ErrorResult& aRv)
-{
-  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;
-  if (aSendParams.mServiceId.WasPassed()) {
-    serviceId = aSendParams.mServiceId.Value();
-  } else {
-    nsresult rv = smsService->GetSmsDefaultServiceId(&serviceId);
-    if (NS_FAILED(rv)) {
-      aRv.Throw(rv);
-      return;
-    }
-  }
-
-  const uint32_t size = aNumbers.Length();
-  for (uint32_t i = 0; i < size; ++i) {
-    RefPtr<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);
-    if (NS_FAILED(rv)) {
-      aRv.Throw(rv);
-      return nullptr;
-    }
-  }
-
-  nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
-  if (!window) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  AutoJSAPI jsapi;
-  if (NS_WARN_IF(!jsapi.Init(window))) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  JSContext *cx = jsapi.cx();
-  JS::Rooted<JS::Value> val(cx);
-  aRv.MightThrowJSException();
-  if (!ToJSValue(cx, aParams, &val)) {
-    aRv.StealExceptionFromJSContext(cx);
-    return nullptr;
-  }
-
-  RefPtr<DOMRequest> request = new DOMRequest(window);
-  nsCOMPtr<nsIMobileMessageCallback> msgCallback = new MobileMessageCallback(request);
-  rv = mmsService->Send(serviceId, val, msgCallback);
-  if (NS_FAILED(rv)) {
-    aRv.Throw(rv);
-    return nullptr;
-  }
-
-  return request.forget();
-}
-
-already_AddRefed<DOMRequest>
-MobileMessageManager::GetMessage(int32_t aId,
-                                 ErrorResult& aRv)
-{
-  nsCOMPtr<nsIMobileMessageDatabaseService> dbService =
-    do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
-  if (!dbService) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
-  if (!window) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  RefPtr<DOMRequest> request = new DOMRequest(window);
-  nsCOMPtr<nsIMobileMessageCallback> msgCallback = new MobileMessageCallback(request);
-  nsresult rv = dbService->GetMessageMoz(aId, msgCallback);
-  if (NS_FAILED(rv)) {
-    aRv.Throw(rv);
-    return nullptr;
-  }
-
-  return request.forget();
-}
-
-already_AddRefed<DOMRequest>
-MobileMessageManager::Delete(int32_t* aIdArray,
-                             uint32_t aSize,
-                             ErrorResult& aRv)
-{
-  nsCOMPtr<nsIMobileMessageDatabaseService> dbService =
-    do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
-  if (!dbService) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
-  if (!window) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  RefPtr<DOMRequest> request = new DOMRequest(window);
-  nsCOMPtr<nsIMobileMessageCallback> msgCallback =
-    new MobileMessageCallback(request);
-
-  nsresult rv = dbService->DeleteMessage(aIdArray, aSize, msgCallback);
-  if (NS_FAILED(rv)) {
-    aRv.Throw(rv);
-    return nullptr;
-  }
-
-  return request.forget();
-}
-
-already_AddRefed<DOMRequest>
-MobileMessageManager::Delete(int32_t aId,
-                             ErrorResult& aRv)
-{
-  return Delete(&aId, 1, aRv);
-}
-
-already_AddRefed<DOMRequest>
-MobileMessageManager::Delete(SmsMessage& aMessage,
-                             ErrorResult& aRv)
-{
-  return Delete(aMessage.Id(), aRv);
-}
-
-already_AddRefed<DOMRequest>
-MobileMessageManager::Delete(MmsMessage& aMessage,
-                             ErrorResult& aRv)
-{
-  return Delete(aMessage.Id(), aRv);
-}
-
-already_AddRefed<DOMRequest>
-MobileMessageManager::Delete(const Sequence<OwningLongOrSmsMessageOrMmsMessage>& aParams,
-                             ErrorResult& aRv)
-{
-  const uint32_t size = aParams.Length();
-  FallibleTArray<int32_t> idArray;
-  if (!idArray.SetLength(size, fallible)) {
-    aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
-    return nullptr;
-  }
-
-  DebugOnly<nsresult> rv;
-  for (uint32_t i = 0; i < size; i++) {
-    const OwningLongOrSmsMessageOrMmsMessage& element = aParams[i];
-    int32_t &id = idArray[i];
-
-    if (element.IsLong()) {
-      id = element.GetAsLong();
-    } else if (element.IsMmsMessage()) {
-      id = element.GetAsMmsMessage()->Id();
-    } else /*if (element.IsSmsMessage())*/ {
-      id = element.GetAsSmsMessage()->Id();
-    }
-  }
-
-  return Delete(idArray.Elements(), size, aRv);
-}
-
-already_AddRefed<DOMCursor>
-MobileMessageManager::GetMessages(const MobileMessageFilter& aFilter,
-                                  bool aReverse,
-                                  ErrorResult& aRv)
-{
-  nsCOMPtr<nsIMobileMessageDatabaseService> dbService =
-    do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
-  if (!dbService) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  bool hasStartDate = !aFilter.mStartDate.IsNull();
-  uint64_t startDate = 0;
-  if (hasStartDate) {
-    startDate = aFilter.mStartDate.Value();
-  }
-
-  bool hasEndDate = !aFilter.mEndDate.IsNull();
-  uint64_t endDate = 0;
-  if (hasEndDate) {
-    endDate = aFilter.mEndDate.Value();
-  }
-
-  UniquePtr<const char16_t*[]> ptrNumbers;
-  uint32_t numbersCount = 0;
-  if (!aFilter.mNumbers.IsNull() &&
-      aFilter.mNumbers.Value().Length()) {
-    const FallibleTArray<nsString>& numbers = aFilter.mNumbers.Value();
-    uint32_t index;
-
-    numbersCount = numbers.Length();
-    ptrNumbers = MakeUnique<const char16_t*[]>(numbersCount);
-    for (index = 0; index < numbersCount; index++) {
-      ptrNumbers[index] = numbers[index].get();
-    }
-  }
-
-  nsString delivery;
-  delivery.SetIsVoid(true);
-  if (!aFilter.mDelivery.IsNull()) {
-    const uint32_t index = static_cast<uint32_t>(aFilter.mDelivery.Value());
-    const EnumEntry& entry =
-      MobileMessageFilterDeliveryValues::strings[index];
-    delivery.AssignASCII(entry.value, entry.length);
-  }
-
-  bool hasRead = !aFilter.mRead.IsNull();
-  bool read = false;
-  if (hasRead) {
-    read = aFilter.mRead.Value();
-  }
-
-  bool hasThreadId = !aFilter.mThreadId.IsNull();
-  uint64_t threadId = 0;
-  if (hasThreadId) {
-    threadId = aFilter.mThreadId.Value();
-  }
-
-  RefPtr<MobileMessageCursorCallback> cursorCallback =
-    new MobileMessageCursorCallback();
-  nsCOMPtr<nsICursorContinueCallback> continueCallback;
-  nsresult rv = dbService->CreateMessageCursor(hasStartDate, startDate,
-                                               hasEndDate, endDate,
-                                               ptrNumbers.get(), numbersCount,
-                                               delivery,
-                                               hasRead, read,
-                                               hasThreadId, threadId,
-                                               aReverse, cursorCallback,
-                                               getter_AddRefs(continueCallback));
-  if (NS_FAILED(rv)) {
-    aRv.Throw(rv);
-    return nullptr;
-  }
-
-  nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
-  if (!window) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  cursorCallback->mDOMCursor =
-    new MobileMessageCursor(window, continueCallback);
-
-  RefPtr<DOMCursor> cursor(cursorCallback->mDOMCursor);
-  return cursor.forget();
-}
-
-already_AddRefed<DOMRequest>
-MobileMessageManager::MarkMessageRead(int32_t aId,
-                                      bool aValue,
-                                      bool aSendReadReport,
-                                      ErrorResult& aRv)
-{
-  nsCOMPtr<nsIMobileMessageDatabaseService> dbService =
-    do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
-  if (!dbService) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
-  if (!window) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  RefPtr<DOMRequest> request = new DOMRequest(window);
-  nsCOMPtr<nsIMobileMessageCallback> msgCallback = new MobileMessageCallback(request);
-  nsresult rv = dbService->MarkMessageRead(aId, aValue, aSendReadReport,
-                                           msgCallback);
-  if (NS_FAILED(rv)) {
-    aRv.Throw(rv);
-    return nullptr;
-  }
-
-  return request.forget();
-}
-
-already_AddRefed<DOMCursor>
-MobileMessageManager::GetThreads(ErrorResult& aRv)
-{
-  nsCOMPtr<nsIMobileMessageDatabaseService> dbService =
-    do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
-  if (!dbService) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  RefPtr<MobileMessageCursorCallback> cursorCallback =
-    new MobileMessageCursorCallback();
-
-  nsCOMPtr<nsICursorContinueCallback> continueCallback;
-  nsresult rv = dbService->CreateThreadCursor(cursorCallback,
-                                              getter_AddRefs(continueCallback));
-  if (NS_FAILED(rv)) {
-    aRv.Throw(rv);
-    return nullptr;
-  }
-
-  nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
-  if (!window) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  cursorCallback->mDOMCursor =
-    new MobileMessageCursor(window, continueCallback);
-
-  RefPtr<DOMCursor> cursor(cursorCallback->mDOMCursor);
-  return cursor.forget();
-}
-
-already_AddRefed<DOMRequest>
-MobileMessageManager::RetrieveMMS(int32_t aId,
-                                  ErrorResult& aRv)
-{
-  nsCOMPtr<nsIMmsService> mmsService = do_GetService(MMS_SERVICE_CONTRACTID);
-  if (!mmsService) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
-  if (!window) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  RefPtr<DOMRequest> request = new DOMRequest(window);
-  nsCOMPtr<nsIMobileMessageCallback> msgCallback = new MobileMessageCallback(request);
-
-  nsresult rv = mmsService->Retrieve(aId, msgCallback);
-  if (NS_FAILED(rv)) {
-    aRv.Throw(rv);
-    return nullptr;
-  }
-
-  return request.forget();
-}
-
-already_AddRefed<DOMRequest>
-MobileMessageManager::RetrieveMMS(MmsMessage& aMessage,
-                                  ErrorResult& aRv)
-{
-  return RetrieveMMS(aMessage.Id(), aRv);
-}
-
-nsresult
-MobileMessageManager::DispatchTrustedSmsEventToSelf(const char* aTopic,
-                                                    const nsAString& aEventName,
-                                                    nsISupports* aMsg)
-{
-  nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
-  NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
-
-  nsCOMPtr<nsISmsMessage> sms = do_QueryInterface(aMsg);
-  if (sms) {
-    MozSmsEventInit init;
-    init.mBubbles = false;
-    init.mCancelable = false;
-    init.mMessage =
-      new SmsMessage(window, static_cast<SmsMessageInternal*>(sms.get()));
-
-    RefPtr<MozSmsEvent> event =
-      MozSmsEvent::Constructor(this, aEventName, init);
-    return DispatchTrustedEvent(event);
-  }
-
-  nsCOMPtr<nsIMmsMessage> mms = do_QueryInterface(aMsg);
-  if (mms) {
-    MozMmsEventInit init;
-    init.mBubbles = false;
-    init.mCancelable = false;
-    init.mMessage =
-      new MmsMessage(window, static_cast<MmsMessageInternal*>(mms.get()));
-
-    RefPtr<MozMmsEvent> event =
-      MozMmsEvent::Constructor(this, aEventName, init);
-    return DispatchTrustedEvent(event);
-  }
-
-  nsAutoCString errorMsg;
-  errorMsg.AssignLiteral("Got a '");
-  errorMsg.Append(aTopic);
-  errorMsg.AppendLiteral("' topic without a valid message!");
-  NS_ERROR(errorMsg.get());
-  return NS_OK;
-}
-
-nsresult
-MobileMessageManager::DispatchTrustedDeletedEventToSelf(nsISupports* aDeletedInfo)
-{
-  nsCOMPtr<nsIDeletedMessageInfo> deletedInfo = do_QueryInterface(aDeletedInfo);
-  if (deletedInfo) {
-    MozMessageDeletedEventInit init;
-    init.mBubbles = false;
-    init.mCancelable = false;
-    DeletedMessageInfo* info =
-      static_cast<DeletedMessageInfo*>(deletedInfo.get());
-
-    uint32_t msgIdLength = info->GetData().deletedMessageIds().Length();
-    if (msgIdLength) {
-      Sequence<int32_t>& deletedMsgIds = init.mDeletedMessageIds.SetValue();
-      if (!deletedMsgIds.AppendElements(info->GetData().deletedMessageIds(),
-                                        fallible)) {
-        return NS_ERROR_OUT_OF_MEMORY;
-      }
-    }
-
-    uint32_t threadIdLength = info->GetData().deletedThreadIds().Length();
-    if (threadIdLength) {
-      Sequence<uint64_t>& deletedThreadIds = init.mDeletedThreadIds.SetValue();
-      if (!deletedThreadIds.AppendElements(info->GetData().deletedThreadIds(),
-                                           fallible)) {
-        return NS_ERROR_OUT_OF_MEMORY;
-      }
-    }
-
-    RefPtr<MozMessageDeletedEvent> event =
-      MozMessageDeletedEvent::Constructor(this, DELETED_EVENT_NAME, init);
-    return DispatchTrustedEvent(event);
-  }
-
-  NS_ERROR("Got a 'deleted' topic without a valid message!");
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileMessageManager::Observe(nsISupports* aSubject, const char* aTopic,
-                              const char16_t* aData)
-{
-  if (!strcmp(aTopic, kSmsReceivedObserverTopic)) {
-    return DispatchTrustedSmsEventToSelf(aTopic, RECEIVED_EVENT_NAME, aSubject);
-  }
-
-  if (!strcmp(aTopic, kSmsRetrievingObserverTopic)) {
-    return DispatchTrustedSmsEventToSelf(aTopic, RETRIEVING_EVENT_NAME, aSubject);
-  }
-
-  if (!strcmp(aTopic, kSmsSendingObserverTopic)) {
-    return DispatchTrustedSmsEventToSelf(aTopic, SENDING_EVENT_NAME, aSubject);
-  }
-
-  if (!strcmp(aTopic, kSmsSentObserverTopic)) {
-    return DispatchTrustedSmsEventToSelf(aTopic, SENT_EVENT_NAME, aSubject);
-  }
-
-  if (!strcmp(aTopic, kSmsFailedObserverTopic)) {
-    return DispatchTrustedSmsEventToSelf(aTopic, FAILED_EVENT_NAME, aSubject);
-  }
-
-  if (!strcmp(aTopic, kSmsDeliverySuccessObserverTopic)) {
-    return DispatchTrustedSmsEventToSelf(aTopic, DELIVERY_SUCCESS_EVENT_NAME, aSubject);
-  }
-
-  if (!strcmp(aTopic, kSmsDeliveryErrorObserverTopic)) {
-    return DispatchTrustedSmsEventToSelf(aTopic, DELIVERY_ERROR_EVENT_NAME, aSubject);
-  }
-
-  if (!strcmp(aTopic, kSmsReadSuccessObserverTopic)) {
-    return DispatchTrustedSmsEventToSelf(aTopic, READ_SUCCESS_EVENT_NAME, aSubject);
-  }
-
-  if (!strcmp(aTopic, kSmsReadErrorObserverTopic)) {
-    return DispatchTrustedSmsEventToSelf(aTopic, READ_ERROR_EVENT_NAME, aSubject);
-  }
-
-  if (!strcmp(aTopic, kSmsDeletedObserverTopic)) {
-    return DispatchTrustedDeletedEventToSelf(aSubject);
-  }
-
-  return NS_OK;
-}
-
-already_AddRefed<Promise>
-MobileMessageManager::GetSmscAddress(const Optional<uint32_t>& aServiceId,
-                                     ErrorResult& aRv)
-{
-  nsCOMPtr<nsISmsService> smsService = do_GetService(SMS_SERVICE_CONTRACTID);
-  if (!smsService) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  // Use the default one unless |aSendParams.serviceId| is available.
-  uint32_t serviceId;
-  nsresult rv;
-  if (aServiceId.WasPassed()) {
-    serviceId = aServiceId.Value();
-  } else {
-    rv = smsService->GetSmsDefaultServiceId(&serviceId);
-    if (NS_FAILED(rv)) {
-      aRv.Throw(rv);
-      return nullptr;
-    }
-  }
-
-  nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
-  if (!window) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(window);
-  if (!global) {
-    aRv.Throw(NS_ERROR_UNEXPECTED);
-    return nullptr;
-  }
-
-  RefPtr<Promise> promise = Promise::Create(global, aRv);
-  if (aRv.Failed()) {
-    return nullptr;
-  }
-
-  nsCOMPtr<nsIMobileMessageCallback> msgCallback =
-    new MobileMessageCallback(promise);
-
-  rv = smsService->GetSmscAddress(serviceId, msgCallback);
-  if (NS_FAILED(rv)) {
-    promise->MaybeReject(rv);
-    return promise.forget();
-  }
-
-  return promise.forget();
-}
-
-already_AddRefed<Promise>
-MobileMessageManager::SetSmscAddress(const SmscAddress& aSmscAddress,
-                                     const Optional<uint32_t>& aServiceId,
-                                     ErrorResult& aRv)
-{
-  nsCOMPtr<nsISmsService> smsService = do_GetService(SMS_SERVICE_CONTRACTID);
-  if (!smsService) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  // Use the default one unless |serviceId| is available.
-  uint32_t serviceId;
-  nsresult rv;
-  if (aServiceId.WasPassed()) {
-    serviceId = aServiceId.Value();
-  } else {
-    rv = smsService->GetSmsDefaultServiceId(&serviceId);
-    if (NS_FAILED(rv)) {
-      aRv.Throw(rv);
-      return nullptr;
-    }
-  }
-
-  nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
-  if (!window) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(window);
-  if (!global) {
-    aRv.Throw(NS_ERROR_UNEXPECTED);
-    return nullptr;
-  }
-
-  RefPtr<Promise> promise = Promise::Create(global, aRv);
-  if (aRv.Failed()) {
-    return nullptr;
-  }
-
-  if (!aSmscAddress.mAddress.WasPassed()) {
-    NS_WARNING("SmscAddress.address is a mandatory field and can not be omitted.");
-    promise->MaybeReject(NS_ERROR_DOM_INVALID_ACCESS_ERR);
-    return promise.forget();
-  }
-
-  nsString address = aSmscAddress.mAddress.Value();
-  TypeOfNumber ton = aSmscAddress.mTypeOfAddress.mTypeOfNumber;
-  NumberPlanIdentification npi =
-    aSmscAddress.mTypeOfAddress.mNumberPlanIdentification;
-
-  // If the address begins with +, set TON to international no matter what has
-  // passed in.
-  if (!address.IsEmpty() && address[0] == '+') {
-    ton = TypeOfNumber::International;
-  }
-
-  nsCOMPtr<nsIMobileMessageCallback> msgCallback =
-    new MobileMessageCallback(promise);
-
-  rv = smsService->SetSmscAddress(serviceId, address,
-    static_cast<uint32_t>(ton), static_cast<uint32_t>(npi), msgCallback);
-  if (NS_FAILED(rv)) {
-    promise->MaybeReject(rv);
-    return promise.forget();
-  }
-
-  return promise.forget();
-}
-
-
-} // namespace dom
-} // namespace mozilla
-
-already_AddRefed<nsISmsService>
-NS_CreateSmsService()
-{
-  nsCOMPtr<nsISmsService> smsService;
-
-  if (XRE_IsContentProcess()) {
-    smsService = SmsIPCService::GetSingleton();
-  } else {
-#if defined(MOZ_WIDGET_ANDROID) && defined(MOZ_WEBSMS_BACKEND)
-    smsService = new SmsService();
-#elif defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
-    smsService = do_GetService(GONK_SMSSERVICE_CONTRACTID);
-#endif
-  }
-
-  return smsService.forget();
-}
-
-already_AddRefed<nsIMobileMessageDatabaseService>
-NS_CreateMobileMessageDatabaseService()
-{
-  nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService;
-  if (XRE_IsContentProcess()) {
-    mobileMessageDBService = SmsIPCService::GetSingleton();
-  } else {
-#if defined(MOZ_WIDGET_ANDROID) && defined(MOZ_WEBSMS_BACKEND)
-    mobileMessageDBService = new MobileMessageDatabaseService();
-#elif defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
-    mobileMessageDBService =
-      do_CreateInstance(GONK_MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
-#endif
-  }
-
-  return mobileMessageDBService.forget();
-}
-
-already_AddRefed<nsIMmsService>
-NS_CreateMmsService()
-{
-  nsCOMPtr<nsIMmsService> mmsService;
-
-  if (XRE_IsContentProcess()) {
-    mmsService = SmsIPCService::GetSingleton();
-  } else {
-#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
-    mmsService = do_CreateInstance("@mozilla.org/mms/gonkmmsservice;1");
-#endif
-  }
-
-  return mmsService.forget();
-}
-
-already_AddRefed<nsIMobileMessageService>
-NS_CreateMobileMessageService()
-{
-  nsCOMPtr<nsIMobileMessageService> service = new MobileMessageService();
-  return service.forget();
-}
deleted file mode 100644
--- a/dom/mobilemessage/MobileMessageManager.h
+++ /dev/null
@@ -1,167 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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/DOMEventTargetHelper.h"
-#include "nsIObserver.h"
-
-class nsISmsService;
-
-namespace mozilla {
-namespace dom {
-
-class Promise;
-class DOMRequest;
-class DOMCursor;
-class MmsMessage;
-struct MmsParameters;
-struct MmsSendParameters;
-struct MobileMessageFilter;
-class OwningLongOrSmsMessageOrMmsMessage;
-class SmsMessage;
-struct SmsSendParameters;
-struct SmscAddress;
-
-class MobileMessageManager final : public DOMEventTargetHelper
-                                 , public nsIObserver
-{
-public:
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_NSIOBSERVER
-
-  NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
-
-  explicit MobileMessageManager(nsPIDOMWindowInner* aWindow);
-
-  void Init();
-  void Shutdown();
-
-  nsPIDOMWindowInner*
-  GetParentObject() const { return GetOwner(); }
-
-  // WrapperCache
-  virtual JSObject*
-  WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) 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<RefPtr<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(SmsMessage& aMessage,
-         ErrorResult& aRv);
-
-  already_AddRefed<DOMRequest>
-  Delete(MmsMessage& aMessage,
-         ErrorResult& aRv);
-
-  already_AddRefed<DOMRequest>
-  Delete(const Sequence<OwningLongOrSmsMessageOrMmsMessage>& aParams,
-         ErrorResult& aRv);
-
-  already_AddRefed<DOMCursor>
-  GetMessages(const MobileMessageFilter& 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(MmsMessage& aMessage,
-              ErrorResult& aRv);
-
-  already_AddRefed<Promise>
-  GetSmscAddress(const Optional<uint32_t>& aServiceId,
-                 ErrorResult& aRv);
-
-  already_AddRefed<Promise>
-  SetSmscAddress(const SmscAddress& aSmscAddress,
-                 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)
-  IMPL_EVENT_HANDLER(deleted)
-
-private:
-  ~MobileMessageManager() {}
-
-  /**
-   * Internal Send() method used to send one message.
-   */
-  already_AddRefed<DOMRequest>
-  Send(nsISmsService* aSmsService,
-       uint32_t aServiceId,
-       const nsAString& aNumber,
-       const nsAString& aText,
-       ErrorResult& aRv);
-
-  already_AddRefed<DOMRequest>
-  Delete(int32_t* aIdArray,
-         uint32_t aSize,
-         ErrorResult& aRv);
-
-  nsresult
-  DispatchTrustedSmsEventToSelf(const char* aTopic,
-                                const nsAString& aEventName,
-                                nsISupports* aMsg);
-
-  nsresult
-  DispatchTrustedDeletedEventToSelf(nsISupports* aDeletedInfo);
-};
-
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_mobilemessage_MobileMessageManager_h
deleted file mode 100644
--- a/dom/mobilemessage/MobileMessageService.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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 "SmsMessageInternal.h"
-#include "MmsMessageInternal.h"
-#include "MobileMessageThreadInternal.h"
-#include "MobileMessageService.h"
-#include "DeletedMessageInfo.h"
-
-namespace mozilla {
-namespace dom {
-namespace mobilemessage {
-
-NS_IMPL_ISUPPORTS(MobileMessageService, nsIMobileMessageService)
-
-NS_IMETHODIMP
-MobileMessageService::CreateSmsMessage(int32_t aId,
-                                       uint64_t aThreadId,
-                                       const nsAString& aIccId,
-                                       const nsAString& aDelivery,
-                                       const nsAString& aDeliveryStatus,
-                                       const nsAString& aSender,
-                                       const nsAString& aReceiver,
-                                       const nsAString& aBody,
-                                       const nsAString& aMessageClass,
-                                       uint64_t aTimestamp,
-                                       uint64_t aSentTimestamp,
-                                       uint64_t aDeliveryTimestamp,
-                                       bool aRead,
-                                       JSContext* aCx,
-                                       nsISmsMessage** aMessage)
-{
-  return SmsMessageInternal::Create(aId,
-                                    aThreadId,
-                                    aIccId,
-                                    aDelivery,
-                                    aDeliveryStatus,
-                                    aSender,
-                                    aReceiver,
-                                    aBody,
-                                    aMessageClass,
-                                    aTimestamp,
-                                    aSentTimestamp,
-                                    aDeliveryTimestamp,
-                                    aRead,
-                                    aCx,
-                                    aMessage);
-}
-
-NS_IMETHODIMP
-MobileMessageService::CreateMmsMessage(int32_t aId,
-                                       uint64_t aThreadId,
-                                       const nsAString& aIccId,
-                                       const nsAString& aDelivery,
-                                       JS::Handle<JS::Value> aDeliveryInfo,
-                                       const nsAString& aSender,
-                                       JS::Handle<JS::Value> aReceivers,
-                                       uint64_t aTimestamp,
-                                       uint64_t aSentTimestamp,
-                                       bool aRead,
-                                       const nsAString& aSubject,
-                                       const nsAString& aSmil,
-                                       JS::Handle<JS::Value> aAttachments,
-                                       uint64_t aExpiryDate,
-                                       bool aReadReportRequested,
-                                       JSContext* aCx,
-                                       nsIMmsMessage** aMessage)
-{
-  return MmsMessageInternal::Create(aId,
-                                    aThreadId,
-                                    aIccId,
-                                    aDelivery,
-                                    aDeliveryInfo,
-                                    aSender,
-                                    aReceivers,
-                                    aTimestamp,
-                                    aSentTimestamp,
-                                    aRead,
-                                    aSubject,
-                                    aSmil,
-                                    aAttachments,
-                                    aExpiryDate,
-                                    aReadReportRequested,
-                                    aCx,
-                                    aMessage);
-}
-
-NS_IMETHODIMP
-MobileMessageService::CreateThread(uint64_t aId,
-                                   JS::Handle<JS::Value> aParticipants,
-                                   uint64_t aTimestamp,
-                                   const nsAString& aLastMessageSubject,
-                                   const nsAString& aBody,
-                                   uint64_t aUnreadCount,
-                                   const nsAString& aLastMessageType,
-                                   JSContext* aCx,
-                                   nsIMobileMessageThread** aThread)
-{
-  return MobileMessageThreadInternal::Create(aId,
-                                             aParticipants,
-                                             aTimestamp,
-                                             aLastMessageSubject,
-                                             aBody,
-                                             aUnreadCount,
-                                             aLastMessageType,
-                                             aCx,
-                                             aThread);
-}
-
-NS_IMETHODIMP
-MobileMessageService::CreateDeletedMessageInfo(int32_t* aMessageIds,
-                                               uint32_t aMsgCount,
-                                               uint64_t* aThreadIds,
-                                               uint32_t  aThreadCount,
-                                               nsIDeletedMessageInfo** aDeletedInfo)
-{
-  return DeletedMessageInfo::Create(aMessageIds,
-                                    aMsgCount,
-                                    aThreadIds,
-                                    aThreadCount,
-                                    aDeletedInfo);
-}
-
-} // namespace mobilemessage
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/mobilemessage/MobileMessageService.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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_MobileMessageService_h
-#define mozilla_dom_mobilemessage_MobileMessageService_h
-
-#include "mozilla/Attributes.h" // For final
-#include "nsIMobileMessageService.h"
-
-namespace mozilla {
-namespace dom {
-namespace mobilemessage {
-
-class MobileMessageService final : public nsIMobileMessageService
-{
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIMOBILEMESSAGESERVICE
-
-  MobileMessageService() { MOZ_COUNT_CTOR(MobileMessageService); }
-
-private:
-  // final suppresses -Werror,-Wdelete-non-virtual-dtor
-  ~MobileMessageService() { MOZ_COUNT_DTOR(MobileMessageService); }
-};
-
-} // namespace mobilemessage
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_mobilemessage_MobileMessageService_h
deleted file mode 100644
--- a/dom/mobilemessage/MobileMessageThread.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et cindent: */
-/* 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 "MobileMessageThreadInternal.h"
-#include "mozilla/dom/MobileMessageThreadBinding.h"
-
-using namespace mozilla::dom::mobilemessage;
-
-namespace mozilla {
-namespace dom {
-
-NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(MobileMessageThread, mWindow, mThread)
-NS_IMPL_CYCLE_COLLECTING_ADDREF(MobileMessageThread)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(MobileMessageThread)
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MobileMessageThread)
-  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
-  NS_INTERFACE_MAP_ENTRY(nsISupports)
-NS_INTERFACE_MAP_END
-
-MobileMessageThread::MobileMessageThread(nsPIDOMWindowInner* aWindow,
-                                         MobileMessageThreadInternal* aThread)
-  : mWindow(aWindow)
-  , mThread(aThread)
-{
-}
-
-MobileMessageThread::~MobileMessageThread()
-{
-}
-
-JSObject*
-MobileMessageThread::WrapObject(JSContext* aCx,
-                                JS::Handle<JSObject*> aGivenProto)
-{
-  return MobileMessageThreadBinding::Wrap(aCx, this, aGivenProto);
-}
-
-uint64_t
-MobileMessageThread::Id() const
-{
-  uint64_t id;
-  mThread->GetId(&id);
-  return id;
-}
-
-void
-MobileMessageThread::GetLastMessageSubject(nsString& aRetVal) const
-{
-  mThread->GetLastMessageSubject(aRetVal);
-}
-
-void
-MobileMessageThread::GetBody(nsString& aRetVal) const
-{
-  mThread->GetBody(aRetVal);
-}
-
-uint64_t
-MobileMessageThread::UnreadCount() const
-{
-  uint64_t count;
-  mThread->GetUnreadCount(&count);
-  return count;
-}
-
-void
-MobileMessageThread::GetParticipants(nsTArray<nsString>& aRetVal) const
-{
-  aRetVal = mThread->mData.participants();
-}
-
-DOMTimeStamp
-MobileMessageThread::Timestamp() const
-{
-  DOMTimeStamp timestamp;
-  mThread->GetTimestamp(&timestamp);
-  return timestamp;
-}
-
-void
-MobileMessageThread::GetLastMessageType(nsString& aRetVal) const
-{
-  mThread->GetLastMessageType(aRetVal);
-}
-
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/mobilemessage/MobileMessageThread.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et cindent: */
-/* 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_MobileMessageThread_h
-#define mozilla_dom_MobileMessageThread_h
-
-#include "mozilla/dom/BindingDeclarations.h"
-#include "nsWrapperCache.h"
-
-class nsPIDOMWindowInner;
-
-namespace mozilla {
-namespace dom {
-
-namespace mobilemessage {
-class MobileMessageThreadInternal;
-} // namespace mobilemessage
-
-/**
- * Each instance of this class provides the DOM-level representation of
- * a MobileMessageThread object to bind it to a window being exposed to.
- */
-class MobileMessageThread final : public nsISupports,
-                                  public nsWrapperCache
-{
-public:
-  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MobileMessageThread)
-
-  MobileMessageThread(nsPIDOMWindowInner* aWindow,
-                      mobilemessage::MobileMessageThreadInternal* aThread);
-
-  nsPIDOMWindowInner*
-  GetParentObject() const
-  {
-    return mWindow;
-  }
-
-  virtual JSObject*
-  WrapObject(JSContext* aCx,
-             JS::Handle<JSObject*> aGivenProto) override;
-
-  uint64_t
-  Id() const;
-
-  void
-  GetLastMessageSubject(nsString& aRetVal) const;
-
-  void
-  GetBody(nsString& aRetVal) const;
-
-  uint64_t
-  UnreadCount() const;
-
-  void
-  GetParticipants(nsTArray<nsString>& aRetVal) const;
-
-  DOMTimeStamp
-  Timestamp() const;
-
-  void
-  GetLastMessageType(nsString& aRetVal) const;
-
-private:
-  // Don't try to use the default constructor.
-  MobileMessageThread() = delete;
-
-  ~MobileMessageThread();
-
-  nsCOMPtr<nsPIDOMWindowInner> mWindow;
-  RefPtr<mobilemessage::MobileMessageThreadInternal> mThread;
-};
-
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_MobileMessageThread_h
deleted file mode 100644
--- a/dom/mobilemessage/MobileMessageThreadInternal.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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 "MobileMessageThreadInternal.h"
-#include "nsIDOMClassInfo.h"
-#include "jsapi.h"           // For OBJECT_TO_JSVAL and JS_NewDateObjectMsec
-#include "nsJSUtils.h"       // For nsAutoJSString
-#include "nsTArrayHelpers.h" // For nsTArrayToJSArray
-#include "mozilla/dom/mobilemessage/Constants.h" // For MessageType
-
-namespace mozilla {
-namespace dom {
-namespace mobilemessage {
-
-NS_IMPL_ISUPPORTS(MobileMessageThreadInternal, nsIMobileMessageThread)
-
-/* static */ nsresult
-MobileMessageThreadInternal::Create(uint64_t aId,
-                                    const JS::Value& aParticipants,
-                                    uint64_t aTimestamp,
-                                    const nsAString& aLastMessageSubject,
-                                    const nsAString& aBody,
-                                    uint64_t aUnreadCount,
-                                    const nsAString& aLastMessageType,
-                                    JSContext* aCx,
-                                    nsIMobileMessageThread** aThread)
-{
-  *aThread = nullptr;
-
-  // ThreadData exposes these as references, so we can simply assign
-  // to them.
-  ThreadData data;
-  data.id() = aId;
-  data.lastMessageSubject().Assign(aLastMessageSubject);
-  data.body().Assign(aBody);
-  data.unreadCount() = aUnreadCount;
-
-  // Participants.
-  {
-    if (!aParticipants.isObject()) {
-      return NS_ERROR_INVALID_ARG;
-    }
-
-    JS::Rooted<JSObject*> obj(aCx, &aParticipants.toObject());
-    bool isArray;
-    if (!JS_IsArrayObject(aCx, obj, &isArray)) {
-      return NS_ERROR_FAILURE;
-    }
-    if (!isArray) {
-      return NS_ERROR_INVALID_ARG;
-    }
-
-    uint32_t length;
-    MOZ_ALWAYS_TRUE(JS_GetArrayLength(aCx, obj, &length));
-    NS_ENSURE_TRUE(length, NS_ERROR_INVALID_ARG);
-
-    for (uint32_t i = 0; i < length; ++i) {
-      JS::Rooted<JS::Value> val(aCx);
-
-      if (!JS_GetElement(aCx, obj, i, &val) || !val.isString()) {
-        return NS_ERROR_INVALID_ARG;
-      }
-
-      nsAutoJSString str;
-      if (!str.init(aCx, val.toString())) {
-        return NS_ERROR_FAILURE;
-      }
-
-      data.participants().AppendElement(str);
-    }
-  }
-
-  // Set |timestamp|;
-  data.timestamp() = aTimestamp;
-
-  // Set |lastMessageType|.
-  {
-    MessageType lastMessageType;
-    if (aLastMessageType.Equals(MESSAGE_TYPE_SMS)) {
-      lastMessageType = eMessageType_SMS;
-    } else if (aLastMessageType.Equals(MESSAGE_TYPE_MMS)) {
-      lastMessageType = eMessageType_MMS;
-    } else {
-      return NS_ERROR_INVALID_ARG;
-    }
-    data.lastMessageType() = lastMessageType;
-  }
-
-  nsCOMPtr<nsIMobileMessageThread> thread =
-    new MobileMessageThreadInternal(data);
-  thread.forget(aThread);
-  return NS_OK;
-}
-
-MobileMessageThreadInternal::MobileMessageThreadInternal(uint64_t aId,
-                                                         const nsTArray<nsString>& aParticipants,
-                                                         uint64_t aTimestamp,
-                                                         const nsString& aLastMessageSubject,
-                                                         const nsString& aBody,
-                                                         uint64_t aUnreadCount,
-                                                         MessageType aLastMessageType)
-  : mData(aId, aParticipants, aTimestamp, aLastMessageSubject, aBody,
-          aUnreadCount, aLastMessageType)
-{
-  MOZ_ASSERT(aParticipants.Length());
-}
-
-MobileMessageThreadInternal::MobileMessageThreadInternal(const ThreadData& aData)
-  : mData(aData)
-{
-  MOZ_ASSERT(aData.participants().Length());
-}
-
-NS_IMETHODIMP
-MobileMessageThreadInternal::GetId(uint64_t* aId)
-{
-  *aId = mData.id();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileMessageThreadInternal::GetLastMessageSubject(nsAString& aLastMessageSubject)
-{
-  aLastMessageSubject = mData.lastMessageSubject();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileMessageThreadInternal::GetBody(nsAString& aBody)
-{
-  aBody = mData.body();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileMessageThreadInternal::GetUnreadCount(uint64_t* aUnreadCount)
-{
-  *aUnreadCount = mData.unreadCount();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileMessageThreadInternal::GetParticipants(JSContext* aCx,
-                                             JS::MutableHandle<JS::Value> aParticipants)
-{
-  JS::Rooted<JSObject*> obj(aCx);
-
-  nsresult rv = nsTArrayToJSArray(aCx, mData.participants(), &obj);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  aParticipants.setObject(*obj);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileMessageThreadInternal::GetTimestamp(DOMTimeStamp* aDate)
-{
-  *aDate = mData.timestamp();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileMessageThreadInternal::GetLastMessageType(nsAString& aLastMessageType)
-{
-  switch (mData.lastMessageType()) {
-    case eMessageType_SMS:
-      aLastMessageType = MESSAGE_TYPE_SMS;
-      break;
-    case eMessageType_MMS:
-      aLastMessageType = MESSAGE_TYPE_MMS;
-      break;
-    case eMessageType_EndGuard:
-    default:
-      MOZ_CRASH("We shouldn't get any other message type!");
-  }
-
-  return NS_OK;
-}
-
-} // namespace mobilemessage
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/mobilemessage/MobileMessageThreadInternal.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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_MobileMessageThreadInternal_h
-#define mozilla_dom_mobilemessage_MobileMessageThreadInternal_h
-
-#include "mozilla/Attributes.h"
-#include "mozilla/dom/mobilemessage/SmsTypes.h"
-#include "nsIMobileMessageThread.h"
-#include "nsString.h"
-
-namespace mozilla {
-namespace dom {
-
-class MobileMessageThread;
-
-namespace mobilemessage {
-
-class ThreadData;
-
-class MobileMessageThreadInternal final : public nsIMobileMessageThread
-{
-  // This allows the MobileMessageThread class to access data members, i.e. participants
-  // without JS API.
-  friend class mozilla::dom::MobileMessageThread;
-
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIMOBILEMESSAGETHREAD
-
-  MobileMessageThreadInternal(uint64_t aId,
-                              const nsTArray<nsString>& aParticipants,
-                              uint64_t aTimestamp,
-                              const nsString& aLastMessageSubject,
-                              const nsString& aBody,
-                              uint64_t aUnreadCount,
-                              mobilemessage::MessageType aLastMessageType);
-
-  explicit MobileMessageThreadInternal(const ThreadData& aData);
-
-  static nsresult Create(uint64_t aId,
-                         const JS::Value& aParticipants,
-                         uint64_t aTimestamp,
-                         const nsAString& aLastMessageSubject,
-                         const nsAString& aBody,
-                         uint64_t aUnreadCount,
-                         const nsAString& aLastMessageType,
-                         JSContext* aCx,
-                         nsIMobileMessageThread** aThread);
-
-  const ThreadData& GetData() const { return mData; }
-
-private:
-  ~MobileMessageThreadInternal() {}
-
-  // Don't try to use the default constructor.
-  MobileMessageThreadInternal() = delete;
-
-  ThreadData mData;
-};
-
-} // namespace mobilemessage
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_mobilemessage_MobileMessageThreadInternal_h
deleted file mode 100644
--- a/dom/mobilemessage/SmsMessage.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et cindent: */
-/* 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 "SmsMessageInternal.h"
-#include "mozilla/dom/SmsMessageBinding.h"
-
-namespace mozilla {
-namespace dom {
-
-NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(SmsMessage, mWindow, mMessage)
-NS_IMPL_CYCLE_COLLECTING_ADDREF(SmsMessage)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(SmsMessage)
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SmsMessage)
-  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
-  NS_INTERFACE_MAP_ENTRY(nsISupports)
-NS_INTERFACE_MAP_END
-
-SmsMessage::SmsMessage(nsPIDOMWindowInner* aWindow, SmsMessageInternal* aMessage)
-  : mWindow(aWindow)
-  , mMessage(aMessage)
-{
-}
-
-SmsMessage::~SmsMessage()
-{
-}
-
-JSObject*
-SmsMessage::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
-{
-  return SmsMessageBinding::Wrap(aCx, this, aGivenProto);
-}
-
-void
-SmsMessage::GetType(nsString& aRetVal) const
-{
-  mMessage->GetType(aRetVal);
-}
-
-int32_t
-SmsMessage::Id() const
-{
-  int32_t id;
-  mMessage->GetId(&id);
-  return id;
-}
-
-uint64_t
-SmsMessage::ThreadId() const
-{
-  uint64_t id;
-  mMessage->GetThreadId(&id);
-  return id;
-}
-
-void
-SmsMessage::GetIccId(nsString& aRetVal) const
-{
-  mMessage->GetIccId(aRetVal);
-}
-
-void
-SmsMessage::GetDelivery(nsString& aRetVal) const
-{
-  mMessage->GetDelivery(aRetVal);
-}
-
-void
-SmsMessage::GetDeliveryStatus(nsString& aRetVal) const
-{
-  mMessage->GetDeliveryStatus(aRetVal);
-}
-
-void
-SmsMessage::GetSender(nsString& aRetVal) const
-{
-  mMessage->GetSender(aRetVal);
-}
-
-void
-SmsMessage::GetReceiver(nsString& aRetVal) const
-{
-  mMessage->GetReceiver(aRetVal);
-}
-
-void
-SmsMessage::GetBody(nsString& aRetVal) const
-{
-  mMessage->GetBody(aRetVal);
-}
-
-void
-SmsMessage::GetMessageClass(nsString& aRetVal) const
-{
-  mMessage->GetMessageClass(aRetVal);
-}
-
-uint64_t
-SmsMessage::Timestamp() const
-{
-  uint64_t timestamp;
-  mMessage->GetTimestamp(&timestamp);
-  return timestamp;
-}
-
-uint64_t
-SmsMessage::SentTimestamp() const
-{
-  uint64_t timestamp;
-  mMessage->GetSentTimestamp(&timestamp);
-  return timestamp;
-}
-
-uint64_t
-SmsMessage::DeliveryTimestamp() const
-{
-  uint64_t timestamp;
-  mMessage->GetDeliveryTimestamp(&timestamp);
-  return timestamp;
-}
-
-bool
-SmsMessage::Read() const
-{
-  bool read;
-  mMessage->GetRead(&read);
-  return read;
-}
-
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/mobilemessage/SmsMessage.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et cindent: */
-/* 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_SmsMessage_h
-#define mozilla_dom_SmsMessage_h
-
-#include "mozilla/dom/BindingDeclarations.h"
-#include "nsWrapperCache.h"
-
-class nsPIDOMWindowInner;
-
-namespace mozilla {
-namespace dom {
-
-namespace mobilemessage {
-class SmsMessageInternal;
-} // namespace mobilemessage
-
-/**
- * Each instance of this class provides the DOM-level representation of
- * a SmsMessage object to bind it to a window being exposed to.
- */
-class SmsMessage final : public nsISupports,
-                         public nsWrapperCache
-{
-public:
-  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(SmsMessage)
-
-  SmsMessage(nsPIDOMWindowInner* aWindow,
-             mobilemessage::SmsMessageInternal* aMessage);
-
-public:
-  nsPIDOMWindowInner*
-  GetParentObject() const
-  {
-    return mWindow;
-  }
-
-  virtual JSObject*
-  WrapObject(JSContext* aCx,
-             JS::Handle<JSObject*> aGivenProto) override;
-
-  void
-  GetType(nsString& aRetVal) const;
-
-  int32_t
-  Id() const;
-
-  uint64_t
-  ThreadId() const;
-
-  void
-  GetIccId(nsString& aRetVal) const;
-
-  void
-  GetDelivery(nsString& aRetVal) const;
-
-  void
-  GetDeliveryStatus(nsString& aRetVal) const;
-
-  void
-  GetSender(nsString& aRetVal) const;
-
-  void
-  GetReceiver(nsString& aRetVal) const;
-
-  void
-  GetBody(nsString& aRetVal) const;
-
-  void
-  GetMessageClass(nsString& aRetVal) const;
-
-  uint64_t
-  Timestamp() const;
-
-  uint64_t
-  SentTimestamp() const;
-
-  uint64_t
-  DeliveryTimestamp() const;
-
-  bool
-  Read() const;
-
-private:
-  // Don't try to use the default constructor.
-  SmsMessage() = delete;
-
-  ~SmsMessage();
-
-  nsCOMPtr<nsPIDOMWindowInner> mWindow;
-  RefPtr<mobilemessage::SmsMessageInternal> mMessage;
-};
-
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_SmsMessage_h
deleted file mode 100644
--- a/dom/mobilemessage/SmsMessageInternal.cpp
+++ /dev/null
@@ -1,283 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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 "SmsMessageInternal.h"
-#include "nsIDOMClassInfo.h"
-#include "mozilla/dom/mobilemessage/Constants.h" // For MessageType
-
-namespace mozilla {
-namespace dom {
-namespace mobilemessage {
-
-NS_IMPL_ISUPPORTS(SmsMessageInternal, nsISmsMessage)
-
-SmsMessageInternal::SmsMessageInternal(int32_t aId,
-                                       uint64_t aThreadId,
-                                       const nsString& aIccId,
-                                       DeliveryState aDelivery,
-                                       DeliveryStatus aDeliveryStatus,
-                                       const nsString& aSender,
-                                       const nsString& aReceiver,
-                                       const nsString& aBody,
-                                       MessageClass aMessageClass,
-                                       uint64_t aTimestamp,
-                                       uint64_t aSentTimestamp,
-                                       uint64_t aDeliveryTimestamp,
-                                       bool aRead)
-  : mData(aId, aThreadId, aIccId, aDelivery, aDeliveryStatus,
-          aSender, aReceiver, aBody, aMessageClass, aTimestamp, aSentTimestamp,
-          aDeliveryTimestamp, aRead)
-{
-}
-
-SmsMessageInternal::SmsMessageInternal(const SmsMessageData& aData)
-  : mData(aData)
-{
-}
-
-/* static */ nsresult
-SmsMessageInternal::Create(int32_t aId,
-                           uint64_t aThreadId,
-                           const nsAString& aIccId,
-                           const nsAString& aDelivery,
-                           const nsAString& aDeliveryStatus,
-                           const nsAString& aSender,
-                           const nsAString& aReceiver,
-                           const nsAString& aBody,
-                           const nsAString& aMessageClass,
-                           uint64_t aTimestamp,
-                           uint64_t aSentTimestamp,
-                           uint64_t aDeliveryTimestamp,
-                           bool aRead,
-                           JSContext* aCx,
-                           nsISmsMessage** aMessage)
-{
-  *aMessage = nullptr;
-
-  // SmsMessageData exposes these as references, so we can simply assign
-  // to them.
-  SmsMessageData data;
-  data.id() = aId;
-  data.threadId() = aThreadId;
-  data.iccId() = nsString(aIccId);
-  data.sender() = nsString(aSender);
-  data.receiver() = nsString(aReceiver);
-  data.body() = nsString(aBody);
-  data.read() = aRead;
-
-  if (aDelivery.Equals(DELIVERY_RECEIVED)) {
-    data.delivery() = eDeliveryState_Received;
-  } else if (aDelivery.Equals(DELIVERY_SENDING)) {
-    data.delivery() = eDeliveryState_Sending;
-  } else if (aDelivery.Equals(DELIVERY_SENT)) {
-    data.delivery() = eDeliveryState_Sent;
-  } else if (aDelivery.Equals(DELIVERY_ERROR)) {
-    data.delivery() = eDeliveryState_Error;
-  } else {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  if (aDeliveryStatus.Equals(DELIVERY_STATUS_NOT_APPLICABLE)) {
-    data.deliveryStatus() = eDeliveryStatus_NotApplicable;
-  } else if (aDeliveryStatus.Equals(DELIVERY_STATUS_SUCCESS)) {
-    data.deliveryStatus() = eDeliveryStatus_Success;
-  } else if (aDeliveryStatus.Equals(DELIVERY_STATUS_PENDING)) {
-    data.deliveryStatus() = eDeliveryStatus_Pending;
-  } else if (aDeliveryStatus.Equals(DELIVERY_STATUS_ERROR)) {
-    data.deliveryStatus() = eDeliveryStatus_Error;
-  } else {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  if (aMessageClass.Equals(MESSAGE_CLASS_NORMAL)) {
-    data.messageClass() = eMessageClass_Normal;
-  } else if (aMessageClass.Equals(MESSAGE_CLASS_CLASS_0)) {
-    data.messageClass() = eMessageClass_Class0;
-  } else if (aMessageClass.Equals(MESSAGE_CLASS_CLASS_1)) {
-    data.messageClass() = eMessageClass_Class1;
-  } else if (aMessageClass.Equals(MESSAGE_CLASS_CLASS_2)) {
-    data.messageClass() = eMessageClass_Class2;
-  } else if (aMessageClass.Equals(MESSAGE_CLASS_CLASS_3)) {
-    data.messageClass() = eMessageClass_Class3;
-  } else {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  // Set |timestamp|.
-  data.timestamp() = aTimestamp;
-
-  // Set |sentTimestamp|.
-  data.sentTimestamp() = aSentTimestamp;
-
-  // Set |deliveryTimestamp|.
-  data.deliveryTimestamp() = aDeliveryTimestamp;
-
-  nsCOMPtr<nsISmsMessage> message = new SmsMessageInternal(data);
-  message.swap(*aMessage);
-  return NS_OK;
-}
-
-const SmsMessageData&
-SmsMessageInternal::GetData() const
-{
-  return mData;
-}
-
-NS_IMETHODIMP
-SmsMessageInternal::GetType(nsAString& aType)
-{
-  aType = NS_LITERAL_STRING("sms");
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-SmsMessageInternal::GetId(int32_t* aId)
-{
-  *aId = mData.id();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-SmsMessageInternal::GetThreadId(uint64_t* aThreadId)
-{
-  *aThreadId = mData.threadId();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-SmsMessageInternal::GetIccId(nsAString& aIccId)
-{
-  aIccId = mData.iccId();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-SmsMessageInternal::GetDelivery(nsAString& aDelivery)
-{
-  switch (mData.delivery()) {
-    case eDeliveryState_Received:
-      aDelivery = DELIVERY_RECEIVED;
-      break;
-    case eDeliveryState_Sending:
-      aDelivery = DELIVERY_SENDING;
-      break;
-    case eDeliveryState_Sent:
-      aDelivery = DELIVERY_SENT;
-      break;
-    case eDeliveryState_Error:
-      aDelivery = DELIVERY_ERROR;
-      break;
-    case eDeliveryState_Unknown:
-    case eDeliveryState_EndGuard:
-    default:
-      MOZ_CRASH("We shouldn't get any other delivery state!");
-  }
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-SmsMessageInternal::GetDeliveryStatus(nsAString& aDeliveryStatus)
-{
-  switch (mData.deliveryStatus()) {
-    case eDeliveryStatus_NotApplicable:
-      aDeliveryStatus = DELIVERY_STATUS_NOT_APPLICABLE;
-      break;
-    case eDeliveryStatus_Success:
-      aDeliveryStatus = DELIVERY_STATUS_SUCCESS;
-      break;
-    case eDeliveryStatus_Pending:
-      aDeliveryStatus = DELIVERY_STATUS_PENDING;
-      break;
-    case eDeliveryStatus_Error:
-      aDeliveryStatus = DELIVERY_STATUS_ERROR;
-      break;
-    case eDeliveryStatus_EndGuard:
-    default:
-      MOZ_CRASH("We shouldn't get any other delivery status!");
-  }
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-SmsMessageInternal::GetSender(nsAString& aSender)
-{
-  aSender = mData.sender();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-SmsMessageInternal::GetReceiver(nsAString& aReceiver)
-{
-  aReceiver = mData.receiver();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-SmsMessageInternal::GetBody(nsAString& aBody)
-{
-  aBody = mData.body();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-SmsMessageInternal::GetMessageClass(nsAString& aMessageClass)
-{
-  switch (mData.messageClass()) {
-    case eMessageClass_Normal:
-      aMessageClass = MESSAGE_CLASS_NORMAL;
-      break;
-    case eMessageClass_Class0:
-      aMessageClass = MESSAGE_CLASS_CLASS_0;
-      break;
-    case eMessageClass_Class1:
-      aMessageClass = MESSAGE_CLASS_CLASS_1;
-      break;
-    case eMessageClass_Class2:
-      aMessageClass = MESSAGE_CLASS_CLASS_2;
-      break;
-    case eMessageClass_Class3:
-      aMessageClass = MESSAGE_CLASS_CLASS_3;
-      break;
-    default:
-      MOZ_CRASH("We shouldn't get any other message class!");
-  }
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-SmsMessageInternal::GetTimestamp(DOMTimeStamp* aTimestamp)
-{
-  *aTimestamp = mData.timestamp();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-SmsMessageInternal::GetSentTimestamp(DOMTimeStamp* aSentTimestamp)
-{
-  *aSentTimestamp = mData.sentTimestamp();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-SmsMessageInternal::GetDeliveryTimestamp(DOMTimeStamp* aDate)
-{
-  *aDate = mData.deliveryTimestamp();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-SmsMessageInternal::GetRead(bool* aRead)
-{
-  *aRead = mData.read();
-  return NS_OK;
-}
-
-} // namespace mobilemessage
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/mobilemessage/SmsMessageInternal.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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_SmsMessageInternal_h
-#define mozilla_dom_mobilemessage_SmsMessageInternal_h
-
-#include "mozilla/dom/mobilemessage/SmsTypes.h"
-#include "nsISmsMessage.h"
-#include "nsString.h"
-#include "mozilla/dom/mobilemessage/Types.h"
-#include "mozilla/Attributes.h"
-
-namespace mozilla {
-namespace dom {
-namespace mobilemessage {
-
-class SmsMessageData;
-
-class SmsMessageInternal final : public nsISmsMessage
-{
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSISMSMESSAGE
-
-  SmsMessageInternal(int32_t aId,
-                     uint64_t aThreadId,
-                     const nsString& aIccId,
-                     mobilemessage::DeliveryState aDelivery,
-                     mobilemessage::DeliveryStatus aDeliveryStatus,
-                     const nsString& aSender,
-                     const nsString& aReceiver,
-                     const nsString& aBody,
-                     mobilemessage::MessageClass aMessageClass,
-                     uint64_t aTimestamp,
-                     uint64_t aSentTimestamp,
-                     uint64_t aDeliveryTimestamp,
-                     bool aRead);
-
-  explicit SmsMessageInternal(const SmsMessageData& aData);
-
-  static nsresult Create(int32_t aId,
-                         uint64_t aThreadId,
-                         const nsAString& aIccId,
-                         const nsAString& aDelivery,
-                         const nsAString& aDeliveryStatus,
-                         const nsAString& aSender,
-                         const nsAString& aReceiver,
-                         const nsAString& aBody,
-                         const nsAString& aMessageClass,
-                         uint64_t aTimestamp,
-                         uint64_t aSentTimestamp,
-                         uint64_t aDeliveryTimestamp,
-                         bool aRead,
-                         JSContext* aCx,
-                         nsISmsMessage** aMessage);
-  const SmsMessageData& GetData() const;
-
-private:
-  ~SmsMessageInternal() {}
-
-  // Don't try to use the default constructor.
-  SmsMessageInternal();
-
-  SmsMessageData mData;
-};
-
-} // namespace mobilemessage
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_mobilemessage_SmsMessageInternal_h
deleted file mode 100644
--- a/dom/mobilemessage/Types.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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_Types_h
-#define mozilla_dom_mobilemessage_Types_h
-
-#include "IPCMessageUtils.h"
-
-namespace mozilla {
-namespace dom {
-namespace mobilemessage {
-
-// For MmsMessageData.state and SmsMessageData.deliveryState
-// Please keep the following files in sync with enum below:
-// mobile/android/base/GeckoSmsManager.java
-enum DeliveryState {
-  eDeliveryState_Sent = 0,
-  eDeliveryState_Received,
-  eDeliveryState_Sending,
-  eDeliveryState_Error,
-  eDeliveryState_Unknown,
-  eDeliveryState_NotDownloaded,
-  // This state should stay at the end.
-  eDeliveryState_EndGuard
-};
-
-// For {Mms,Sms}MessageData.deliveryStatus.
-enum DeliveryStatus {
-  eDeliveryStatus_NotApplicable = 0,
-  eDeliveryStatus_Success,
-  eDeliveryStatus_Pending,
-  eDeliveryStatus_Error,
-  eDeliveryStatus_Reject,
-  eDeliveryStatus_Manual,
-  // This state should stay at the end.
-  eDeliveryStatus_EndGuard
-};
-
-// For MmsMessageData.readStatus.
-enum ReadStatus {
-  eReadStatus_NotApplicable = 0,
-  eReadStatus_Success,
-  eReadStatus_Pending,
-  eReadStatus_Error,
-  // This state should stay at the end.
-  eReadStatus_EndGuard
-};
-
-// For {Mms,Sms}MessageData.messageClass.
-enum MessageClass {
-  eMessageClass_Normal = 0,
-  eMessageClass_Class0,
-  eMessageClass_Class1,
-  eMessageClass_Class2,
-  eMessageClass_Class3,
-  // This state should stay at the end.
-  eMessageClass_EndGuard
-};
-
-// For ThreadData.
-enum MessageType {
-  eMessageType_SMS = 0,
-  eMessageType_MMS,
-  // This state should stay at the end.
-  eMessageType_EndGuard
-};
-
-} // namespace mobilemessage
-} // namespace dom
-} // namespace mozilla
-
-namespace IPC {
-
-/**
- * Delivery state serializer.
- */
-template <>
-struct ParamTraits<mozilla::dom::mobilemessage::DeliveryState>
-  : public ContiguousEnumSerializer<
-             mozilla::dom::mobilemessage::DeliveryState,
-             mozilla::dom::mobilemessage::eDeliveryState_Sent,
-             mozilla::dom::mobilemessage::eDeliveryState_EndGuard>
-{};
-
-/**
- * Delivery status serializer.
- */
-template <>
-struct ParamTraits<mozilla::dom::mobilemessage::DeliveryStatus>
-  : public ContiguousEnumSerializer<
-             mozilla::dom::mobilemessage::DeliveryStatus,
-             mozilla::dom::mobilemessage::eDeliveryStatus_NotApplicable,
-             mozilla::dom::mobilemessage::eDeliveryStatus_EndGuard>
-{};
-
-/**
- * Read status serializer.
- */
-template <>
-struct ParamTraits<mozilla::dom::mobilemessage::ReadStatus>
-  : public ContiguousEnumSerializer<
-             mozilla::dom::mobilemessage::ReadStatus,
-             mozilla::dom::mobilemessage::eReadStatus_NotApplicable,
-             mozilla::dom::mobilemessage::eReadStatus_EndGuard>
-{};
-
-/**
- * Message class serializer.
- */
-template <>
-struct ParamTraits<mozilla::dom::mobilemessage::MessageClass>
-  : public ContiguousEnumSerializer<
-             mozilla::dom::mobilemessage::MessageClass,
-             mozilla::dom::mobilemessage::eMessageClass_Normal,
-             mozilla::dom::mobilemessage::eMessageClass_EndGuard>
-{};
-
-/**
- * MessageType class serializer.
- */
-template <>
-struct ParamTraits<mozilla::dom::mobilemessage::MessageType>
-  : public ContiguousEnumSerializer<
-             mozilla::dom::mobilemessage::MessageType,
-             mozilla::dom::mobilemessage::eMessageType_SMS,
-             mozilla::dom::mobilemessage::eMessageType_EndGuard>
-{};
-
-} // namespace IPC
-
-#endif // mozilla_dom_mobilemessage_Types_h
deleted file mode 100644
--- a/dom/mobilemessage/android/MobileMessageDatabaseService.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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 "MobileMessageDatabaseService.h"
-
-#include "AndroidBridge.h"
-#include "SmsManager.h"
-
-namespace mozilla {
-namespace dom {
-namespace mobilemessage {
-
-NS_IMPL_ISUPPORTS(MobileMessageDatabaseService, nsIMobileMessageDatabaseService)
-
-MobileMessageDatabaseService::MobileMessageDatabaseService()
-{
-  SmsManager::Init();
-}
-
-NS_IMETHODIMP
-MobileMessageDatabaseService::GetMessageMoz(int32_t aMessageId,
-                                            nsIMobileMessageCallback* aRequest)
-{
-  if (!AndroidBridge::Bridge()) {
-    return NS_OK;
-  }
-
-  AndroidBridge::Bridge()->GetMessage(aMessageId, aRequest);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileMessageDatabaseService::DeleteMessage(int32_t *aMessageIds,
-                                            uint32_t aLength,
-                                            nsIMobileMessageCallback* aRequest)
-{
-  if (!AndroidBridge::Bridge()) {
-    return NS_OK;
-  }
-
-  if (!aMessageIds) {
-    return NS_OK;
-  }
-
-  if (aLength != 1) {
-    return NS_ERROR_FAILURE;
-  }
-
-  AndroidBridge::Bridge()->DeleteMessage(aMessageIds[0], aRequest);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileMessageDatabaseService::CreateMessageCursor(bool aHasStartDate,
-                                                  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** aCursor)
-{
-  if (!AndroidBridge::Bridge()) {
-    *aCursor = nullptr;
-    return NS_OK;
-  }
-
-  nsCOMPtr<nsICursorContinueCallback> cursor =
-    AndroidBridge::Bridge()->CreateMessageCursor(aHasStartDate,
-                                                 aStartDate,
-                                                 aHasEndDate,
-                                                 aEndDate,
-                                                 aNumbers,
-                                                 aNumbersCount,
-                                                 aDelivery,
-                                                 aHasRead,
-                                                 aRead,
-                                                 aHasThreadId,
-                                                 aThreadId,
-                                                 aReverse,
-                                                 aCallback);
-  cursor.forget(aCursor);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileMessageDatabaseService::MarkMessageRead(int32_t aMessageId,
-                                              bool aValue,
-                                              bool aSendReadReport,
-                                              nsIMobileMessageCallback* aRequest)
-{
-  if (!AndroidBridge::Bridge()) {
-    return NS_OK;
-  }
-
-  AndroidBridge::Bridge()->MarkMessageRead(aMessageId,
-                                           aValue,
-                                           aSendReadReport,
-                                           aRequest);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-MobileMessageDatabaseService::CreateThreadCursor(nsIMobileMessageCursorCallback* aRequest,
-                                                 nsICursorContinueCallback** aCursor)
-{
-  if (!AndroidBridge::Bridge()) {
-    *aCursor = nullptr;
-    return NS_OK;
-  }
-
-  nsCOMPtr<nsICursorContinueCallback> cursor =
-    AndroidBridge::Bridge()->CreateThreadCursor(aRequest);
-  cursor.forget(aCursor);
-  return NS_OK;
-}
-
-} // namespace mobilemessage
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/mobilemessage/android/MobileMessageDatabaseService.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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_MobileMessageDatabaseService_h
-#define mozilla_dom_mobilemessage_MobileMessageDatabaseService_h
-
-#include "nsIMobileMessageDatabaseService.h"
-#include "mozilla/Attributes.h"
-
-namespace mozilla {
-namespace dom {
-namespace mobilemessage {
-
-class MobileMessageDatabaseService final : public nsIMobileMessageDatabaseService
-{
-private:
-  ~MobileMessageDatabaseService() {}
-
-public:
-  MobileMessageDatabaseService();
-
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIMOBILEMESSAGEDATABASESERVICE
-};
-
-} // namespace mobilemessage
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_mobilemessage_MobileMessageDatabaseService_h
deleted file mode 100644
--- a/dom/mobilemessage/android/SmsManager.cpp
+++ /dev/null
@@ -1,391 +0,0 @@
-/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
- * 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 "SmsManager.h"
-
-#include "mozilla/dom/mobilemessage/Constants.h"
-#include "mozilla/dom/mobilemessage/PSms.h"
-#include "mozilla/dom/mobilemessage/SmsParent.h"
-#include "mozilla/dom/mobilemessage/SmsTypes.h"
-#include "mozilla/dom/mobilemessage/Types.h"
-#include "MobileMessageThreadInternal.h"
-#include "SmsMessageInternal.h"
-#include "mozilla/Services.h"
-#include "nsIMobileMessageDatabaseService.h"
-#include "nsIObserverService.h"
-#include "nsThreadUtils.h"
-#include "AndroidJavaWrappers.h"
-
-using namespace mozilla::dom;
-using namespace mozilla::dom::mobilemessage;
-
-namespace mozilla {
-
-/*static*/
-void
-SmsManager::NotifySmsReceived(int32_t aId,
-                              jni::String::Param aSender,
-                              jni::String::Param aBody,
-                              int32_t aMessageClass,
-                              int64_t aSentTimestamp,
-                              int64_t aTimestamp)
-{
-    // TODO Need to correct the message `threadId` parameter value. Bug 859098
-    SmsMessageData message;
-    message.id() = aId;
-    message.threadId() = 0;
-    message.iccId() = EmptyString();
-    message.delivery() = eDeliveryState_Received;
-    message.deliveryStatus() = eDeliveryStatus_Success;
-    message.sender() = aSender ? aSender->ToString() : EmptyString();
-    message.receiver() = EmptyString();
-    message.body() = aBody ? aBody->ToString() : EmptyString();
-    message.messageClass() = static_cast<MessageClass>(aMessageClass);
-    message.timestamp() = aTimestamp;
-    message.sentTimestamp() = aSentTimestamp;
-    message.deliveryTimestamp() = aTimestamp;
-    message.read() = false;
-
-    nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
-    if (!obs) {
-        return;
-    }
-
-    nsCOMPtr<nsISmsMessage> domMessage = new SmsMessageInternal(message);
-    obs->NotifyObservers(domMessage, kSmsReceivedObserverTopic, nullptr);
-}
-
-/*static*/
-void
-SmsManager::NotifySmsSent(int32_t aId,
-                          jni::String::Param aReceiver,
-                          jni::String::Param aBody,
-                          int64_t aTimestamp,
-                          int32_t aRequestId)
-{
-    // TODO Need to add the message `messageClass` parameter value. Bug 804476
-    // TODO Need to correct the message `threadId` parameter value. Bug 859098
-    SmsMessageData message;
-    message.id() = aId;
-    message.threadId() = 0;
-    message.iccId() = EmptyString();
-    message.delivery() = eDeliveryState_Sent;
-    message.deliveryStatus() = eDeliveryStatus_Pending;
-    message.sender() = EmptyString();
-    message.receiver() = aReceiver ? aReceiver->ToString() : EmptyString();
-    message.body() = aBody ? aBody->ToString() : EmptyString();
-    message.messageClass() = eMessageClass_Normal;
-    message.timestamp() = aTimestamp;
-    message.sentTimestamp() = aTimestamp;
-    message.deliveryTimestamp() = aTimestamp;
-    message.read() = true;
-
-    /*
-     * First, we are going to notify all SmsManager that a message has
-     * been sent. Then, we will notify the SmsRequest object about it.
-     */
-    nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
-    if (!obs) {
-        return;
-    }
-
-    nsCOMPtr<nsISmsMessage> domMessage = new SmsMessageInternal(message);
-    obs->NotifyObservers(domMessage, kSmsSentObserverTopic, nullptr);
-
-    nsCOMPtr<nsIMobileMessageCallback> request =
-        AndroidBridge::Bridge()->DequeueSmsRequest(aRequestId);
-    if (!request) {
-        return;
-    }
-
-    request->NotifyMessageSent(domMessage);
-}
-
-/*static*/
-void
-SmsManager::NotifySmsDelivery(int32_t aId,
-                              int32_t aDeliveryStatus,
-                              jni::String::Param aReceiver,
-                              jni::String::Param aBody,
-                              int64_t aTimestamp)
-{
-    // TODO Need to add the message `messageClass` parameter value. Bug 804476
-    // TODO Need to correct the message `threadId` parameter value. Bug 859098
-    SmsMessageData message;
-    message.id() = aId;
-    message.threadId() = 0;
-    message.iccId() = EmptyString();
-    message.delivery() = eDeliveryState_Sent;
-    message.deliveryStatus() = static_cast<DeliveryStatus>(aDeliveryStatus);
-    message.sender() = EmptyString();
-    message.receiver() = aReceiver ? aReceiver->ToString() : EmptyString();
-    message.body() = aBody ? aBody->ToString() : EmptyString();
-    message.messageClass() = eMessageClass_Normal;
-    message.timestamp() = aTimestamp;
-    message.sentTimestamp() = aTimestamp;
-    message.deliveryTimestamp() = aTimestamp;
-    message.read() = true;
-
-    nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
-    if (!obs) {
-        return;
-    }
-
-    nsCOMPtr<nsISmsMessage> domMessage = new SmsMessageInternal(message);
-    const char* topic = (message.deliveryStatus() == eDeliveryStatus_Success)
-                        ? kSmsDeliverySuccessObserverTopic
-                        : kSmsDeliveryErrorObserverTopic;
-    obs->NotifyObservers(domMessage, topic, nullptr);
-}
-
-/*static*/
-void
-SmsManager::NotifySmsSendFailed(int32_t aError, int32_t aRequestId)
-{
-    nsCOMPtr<nsIMobileMessageCallback> request =
-        AndroidBridge::Bridge()->DequeueSmsRequest(aRequestId);
-    if(!request) {
-        return;
-    }
-
-    request->NotifySendMessageFailed(aError, nullptr);
-}
-
-/*static*/
-void
-SmsManager::NotifyGetSms(int32_t aId,
-                         int32_t aDeliveryStatus,
-                         jni::String::Param aReceiver,
-                         jni::String::Param aSender,
-                         jni::String::Param aBody,
-                         int64_t aTimestamp,
-                         bool aRead,
-                         int32_t aRequestId)
-{
-    nsString receiver(aReceiver->ToString());
-    DeliveryState state = receiver.IsEmpty() ? eDeliveryState_Received
-                                             : eDeliveryState_Sent;
-
-    // TODO Need to add the message `messageClass` parameter value. Bug 804476
-    // TODO Need to correct the message `threadId` parameter value. Bug 859098
-    SmsMessageData message;
-    message.id() = aId;
-    message.threadId() = 0;
-    message.iccId() = EmptyString();
-    message.delivery() = state;
-    message.deliveryStatus() = static_cast<DeliveryStatus>(aDeliveryStatus);
-    message.sender() = aSender ? aSender->ToString() : EmptyString();
-    message.receiver() = receiver;
-    message.body() = aBody ? aBody->ToString() : EmptyString();
-    message.messageClass() = eMessageClass_Normal;
-    message.timestamp() = aTimestamp;
-    message.sentTimestamp() = aTimestamp;
-    message.deliveryTimestamp() = aTimestamp;
-    message.read() = aRead;
-
-    nsCOMPtr<nsIMobileMessageCallback> request =
-        AndroidBridge::Bridge()->DequeueSmsRequest(aRequestId);
-    if (!request) {
-        return;
-    }
-
-    nsCOMPtr<nsISmsMessage> domMessage = new SmsMessageInternal(message);
-    request->NotifyMessageGot(domMessage);
-}
-
-/*static*/
-void
-SmsManager::NotifyGetSmsFailed(int32_t aError, int32_t aRequestId)
-{
-    nsCOMPtr<nsIMobileMessageCallback> request =
-        AndroidBridge::Bridge()->DequeueSmsRequest(aRequestId);
-    if (!request) {
-        return;
-    }
-
-    request->NotifyGetMessageFailed(aError);
-}
-
-/*static*/
-void
-SmsManager::NotifySmsDeleted(bool aDeleted, int32_t aRequestId)
-{
-    nsCOMPtr<nsIMobileMessageCallback> request =
-        AndroidBridge::Bridge()->DequeueSmsRequest(aRequestId);
-    if (!request) {
-        return;
-    }
-
-    // For android, we support only single SMS deletion.
-    bool deleted = aDeleted;
-    request->NotifyMessageDeleted(&deleted, 1);
-}
-
-/*static*/
-void
-SmsManager::NotifySmsDeleteFailed(int32_t aError, int32_t aRequestId)
-{
-    nsCOMPtr<nsIMobileMessageCallback> request =
-        AndroidBridge::Bridge()->DequeueSmsRequest(aRequestId);
-    if (!request) {
-        return;
-    }
-
-    request->NotifyDeleteMessageFailed(aError);
-}
-
-/*static*/
-void
-SmsManager::NotifyCursorError(int32_t aError, int32_t aRequestId)
-{
-    nsCOMPtr<nsIMobileMessageCursorCallback> request =
-        AndroidBridge::Bridge()->DequeueSmsCursorRequest(aRequestId);
-    if (!request) {
-        return;
-    }
-
-    request->NotifyCursorError(aError);
-}
-
-/*static*/
-void
-SmsManager::NotifyThreadCursorResult(int64_t aId,
-                                     jni::String::Param aLastMessageSubject,
-                                     jni::String::Param aBody,
-                                     int64_t aUnreadCount,
-                                     jni::ObjectArray::Param aParticipants,
-                                     int64_t aTimestamp,
-                                     jni::String::Param aLastMessageType,
-                                     int32_t aRequestId)
-{
-    ThreadData thread;
-    thread.id() = aId;
-    thread.lastMessageSubject() = aLastMessageSubject ?
-                                    aLastMessageSubject->ToString() :
-                                    EmptyString();
-    thread.body() = aBody ? aBody->ToString() : EmptyString();
-    thread.unreadCount() = aUnreadCount;
-    thread.timestamp() = aTimestamp;
-    thread.lastMessageType() = eMessageType_SMS;
-
-    JNIEnv* const env = jni::GetGeckoThreadEnv();
-
-    jobjectArray participants = aParticipants.Get();
-    jsize length = env->GetArrayLength(participants);
-    for (jsize i = 0; i < length; ++i) {
-        jstring participant =
-            static_cast<jstring>(env->GetObjectArrayElement(participants, i));
-        if (participant) {
-            thread.participants().AppendElement(nsJNIString(participant, env));
-            env->DeleteLocalRef(participant);
-        }
-    }
-
-    nsCOMPtr<nsIMobileMessageCursorCallback> request =
-        AndroidBridge::Bridge()->GetSmsCursorRequest(aRequestId);
-    if (!request) {
-        return;
-    }
-
-    nsCOMArray<nsIMobileMessageThread> arr;
-    arr.AppendElement(new MobileMessageThreadInternal(thread));
-
-    nsIMobileMessageThread** elements;
-    int32_t size;
-    size = arr.Forget(&elements);
-
-    request->NotifyCursorResult(reinterpret_cast<nsISupports**>(elements),
-                                size);
-}
-
-/*static*/
-void
-SmsManager::NotifyMessageCursorResult(int32_t aMessageId,
-                                      int32_t aDeliveryStatus,
-                                      jni::String::Param aReceiver,
-                                      jni::String::Param aSender,
-                                      jni::String::Param aBody,
-                                      int64_t aTimestamp,
-                                      int64_t aThreadId,
-                                      bool aRead,
-                                      int32_t aRequestId)
-{
-    nsString receiver = aReceiver->ToString();
-    DeliveryState state = receiver.IsEmpty() ? eDeliveryState_Received
-                                             : eDeliveryState_Sent;
-
-    // TODO Need to add the message `messageClass` parameter value. Bug 804476
-    SmsMessageData message;
-    message.id() = aMessageId;
-    message.threadId() = aThreadId;
-    message.iccId() = EmptyString();
-    message.delivery() = state;
-    message.deliveryStatus() = static_cast<DeliveryStatus>(aDeliveryStatus);
-    message.sender() = aSender ? aSender->ToString() : EmptyString();
-    message.receiver() = receiver;
-    message.body() = aBody ? aBody->ToString() : EmptyString();
-    message.messageClass() = eMessageClass_Normal;
-    message.timestamp() = aTimestamp;
-    message.sentTimestamp() = aTimestamp;
-    message.deliveryTimestamp() = aTimestamp;
-    message.read() = aRead;
-
-    nsCOMPtr<nsIMobileMessageCursorCallback> request =
-        AndroidBridge::Bridge()->GetSmsCursorRequest(aRequestId);
-    if (!request) {
-        return;
-    }
-
-    nsCOMArray<nsISmsMessage> arr;
-    arr.AppendElement(new SmsMessageInternal(message));
-
-    nsISmsMessage** elements;
-    int32_t size;
-    size = arr.Forget(&elements);
-
-    request->NotifyCursorResult(reinterpret_cast<nsISupports**>(elements),
-                                size);
-}
-
-/*static*/
-void
-SmsManager::NotifyCursorDone(int32_t aRequestId)
-{
-    nsCOMPtr<nsIMobileMessageCursorCallback> request =
-        AndroidBridge::Bridge()->DequeueSmsCursorRequest(aRequestId);
-    if (!request) {
-        return;
-    }
-
-    request->NotifyCursorDone();
-}
-
-/*static*/
-void
-SmsManager::NotifySmsMarkedAsRead(bool aMarkedAsRead, int32_t aRequestId)
-{
-    nsCOMPtr<nsIMobileMessageCallback> request =
-        AndroidBridge::Bridge()->DequeueSmsRequest(aRequestId);
-    if (!request) {
-        return;
-    }
-
-    request->NotifyMessageMarkedRead(aMarkedAsRead);
-}
-
-/*static*/
-void
-SmsManager::NotifySmsMarkAsReadFailed(int32_t aError, int32_t aRequestId)
-{
-    nsCOMPtr<nsIMobileMessageCallback> request =
-        AndroidBridge::Bridge()->DequeueSmsRequest(aRequestId);
-    if (!request) {
-        return;
-    }
-
-    request->NotifyMarkMessageReadFailed(aError);
-}
-
-} // namespace
deleted file mode 100644
--- a/dom/mobilemessage/android/SmsManager.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
- * 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 SmsManager_h__
-#define SmsManager_h__
-
-#include "GeneratedJNINatives.h"
-
-namespace mozilla {
-
-class SmsManager : public java::GeckoSmsManager::Natives<SmsManager>
-{
-private:
-    SmsManager();
-
-public:
-    static void NotifySmsReceived(int32_t aId,
-                                  jni::String::Param aSender,
-                                  jni::String::Param aBody,
-                                  int32_t aMessageClass,
-                                  int64_t aSentTimestamp,
-                                  int64_t aTimestamp);
-    static void NotifySmsSent(int32_t aId,
-                              jni::String::Param aReceiver,
-                              jni::String::Param aBody,
-                              int64_t aTimestamp,
-                              int32_t aRequestId);
-    static void NotifySmsDelivery(int32_t aId,
-                                  int32_t aDeliveryStatus,
-                                  jni::String::Param aReceiver,
-                                  jni::String::Param aBody,
-                                  int64_t aTimestamp);
-    static void NotifySmsSendFailed(int32_t aError,
-                                    int32_t aRequestId);
-    static void NotifyGetSms(int32_t aId,
-                             int32_t aDeliveryStatus,
-                             jni::String::Param aReceiver,
-                             jni::String::Param aSender,
-                             jni::String::Param aBody,
-                             int64_t aTimestamp,
-                             bool aRead,
-                             int32_t aRequestId);
-    static void NotifyGetSmsFailed(int32_t aError,
-                                   int32_t aRequestId);
-    static void NotifySmsDeleted(bool aDeleted,
-                                 int32_t aRequestId);
-    static void NotifySmsDeleteFailed(int32_t aError,
-                                      int32_t aRequestId);
-    static void NotifyCursorError(int32_t aError,
-                                  int32_t aRequestId);
-    static void NotifyThreadCursorResult(int64_t aId,
-                                         jni::String::Param aLastMessageSubject,
-                                         jni::String::Param aBody,
-                                         int64_t aUnreadCount,
-                                         jni::ObjectArray::Param aParticipants,
-                                         int64_t aTimestamp,
-                                         jni::String::Param aLastMessageType,
-                                         int32_t aRequestId);
-    static void NotifyMessageCursorResult(int32_t aMessageId,
-                                          int32_t aDeliveryStatus,
-                                          jni::String::Param aReceiver,
-                                          jni::String::Param aSender,
-                                          jni::String::Param aBody,
-                                          int64_t aTimestamp,
-                                          int64_t aThreadId,
-                                          bool aRead,
-                                          int32_t aRequestId);
-    static void NotifyCursorDone(int32_t aRequestId);
-    static void NotifySmsMarkedAsRead(bool aMarkedAsRead, int32_t aRequestId);
-    static void NotifySmsMarkAsReadFailed(int32_t aError, int32_t aRequestId);
-};
-
-} // namespace
-
-#endif // SmsManager_h__
deleted file mode 100644
--- a/dom/mobilemessage/android/SmsService.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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 "SmsService.h"
-#include "AndroidBridge.h"
-
-namespace mozilla {
-namespace dom {
-namespace mobilemessage {
-
-NS_IMPL_ISUPPORTS(SmsService, nsISmsService)
-
-NS_IMETHODIMP
-SmsService::GetSmsDefaultServiceId(uint32_t* aServiceId)
-{
-  // Android has no official DSDS support.
-  *aServiceId = 0;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-SmsService::GetSegmentInfoForText(const nsAString& aText,
-                                  nsIMobileMessageCallback* aRequest)
-{
-  if (!AndroidBridge::Bridge()) {
-    return NS_ERROR_FAILURE;
-  }
-
-  nsresult rv = AndroidBridge::Bridge()->GetSegmentInfoForText(aText, aRequest);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-SmsService::Send(uint32_t aServiceId,
-                 const nsAString& aNumber,
-                 const nsAString& aMessage,
-                 bool aSilent,
-                 nsIMobileMessageCallback* aRequest)
-{
-  if (!AndroidBridge::Bridge()) {
-    return NS_OK;
-  }
-
-  AndroidBridge::Bridge()->SendMessage(aNumber, aMessage, aRequest);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-SmsService::AddSilentNumber(const nsAString& aNumber)
-{
-  NS_NOTYETIMPLEMENTED("Implement me!");
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
-SmsService::RemoveSilentNumber(const nsAString& aNumber)
-{
-  NS_NOTYETIMPLEMENTED("Implement me!");
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
-SmsService::GetSmscAddress(uint32_t aServiceId,
-                           nsIMobileMessageCallback *aRequest)
-{
-  // TODO: bug 878016 - Android backend: implement getSMSCAddress/setSMSCAddress
-  NS_NOTYETIMPLEMENTED("Implement me!");
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
-SmsService::SetSmscAddress(uint32_t aServiceId,
-                           const nsAString& aNumber,
-                           uint32_t aTypeOfNumber,
-                           uint32_t aNumberPlanIdentification,
-                           nsIMobileMessageCallback* aRequest)
-{
-  // TODO: bug 878016 - Android backend: implement getSMSCAddress/setSMSCAddress
-  NS_NOTYETIMPLEMENTED("Implement me!");
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-} // namespace mobilemessage
-} // namespace dom
-} // namespace mozilla
deleted file mode 100644
--- a/dom/mobilemessage/android/SmsService.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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_SmsService_h
-#define mozilla_dom_mobilemessage_SmsService_h
-
-#include "nsISmsService.h"
-
-namespace mozilla {
-namespace dom {
-namespace mobilemessage {
-
-class SmsService final : public nsISmsService
-{
-private:
-  ~SmsService() {}
-
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSISMSSERVICE
-};
-
-} // namespace mobilemessage
-} // namespace dom
-} // namespace mozilla
-
-#endif // mozilla_dom_mobilemessage_SmsService_h
deleted file mode 100644
--- a/dom/mobilemessage/gonk/MmsPduHelper.jsm
+++ /dev/null
@@ -1,1710 +0,0 @@
-/* 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/. */
-
-"use strict";
-
-const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
-
-var WSP = {};
-Cu.import("resource://gre/modules/WspPduHelper.jsm", WSP);
-
-Cu.import("resource://gre/modules/mms_consts.js");
-
-Cu.import("resource://gre/modules/PhoneNumberUtils.jsm");
-
-var DEBUG; // set to true to see debug messages
-
-this.MMS_VERSION = (function() {
-  Cu.import("resource://gre/modules/Services.jsm");
-
-  try {
-    return Services.prefs.getIntPref("dom.mms.version");
-  } catch(ex) {}
-
-  return MMS_VERSION_1_3;
-})();
-
-this.translatePduErrorToStatus = function translatePduErrorToStatus(error) {
-  if (error == MMS_PDU_ERROR_OK) {
-    return MMS_PDU_STATUS_RETRIEVED;
-  }
-
-  if ((error >= MMS_PDU_ERROR_TRANSIENT_FAILURE)
-      && (error < MMS_PDU_ERROR_PERMANENT_FAILURE)) {
-    return MMS_PDU_STATUS_DEFERRED;
-  }
-
-  return MMS_PDU_STATUS_UNRECOGNISED;
-}
-
-function defineLazyRegExp(obj, name, pattern) {
-  obj.__defineGetter__(name, function() {
-    delete obj[name];
-    return obj[name] = new RegExp(pattern);
-  });
-}
-
-function RangedValue(name, min, max) {
-  this.name = name;
-  this.min = min;
-  this.max = max;
-}
-RangedValue.prototype = {
-  name: null,
-  min: null,
-  max: null,
-
-  /**
-   * @param data
-   *        A wrapped object containing raw PDU data.
-   *
-   * @return A decoded integer.
-   *
-   * @throws CodeError if decoded value is not in the range [this.min, this.max].
-   */
-  decode: function(data) {
-    let value = WSP.Octet.decode(data);
-    if ((value >= this.min) && (value <= this.max)) {
-      return value;
-    }
-
-    throw new WSP.CodeError(this.name + ": invalid value " + value);
-  },
-
-  /**
-   * @param data
-   *        A wrapped object to store encoded raw data.
-   * @param value
-   *        An integer value within thr range [this.min, this.max].
-   */
-  encode: function(data, value) {
-    if ((value < this.min) || (value > this.max)) {
-      throw new WSP.CodeError(this.name + ": invalid value " + value);
-    }
-
-    WSP.Octet.encode(data, value);
-  },
-};
-
-/**
- * Internal decoding function for boolean values.
- *
- * Boolean-value = Yes | No
- * Yes = <Octet 128>
- * No = <Octet 129>
- */
-this.BooleanValue = {
-  /**
-   * @param data
-   *        A wrapped object containing raw PDU data.
-   *
-   * @return Boolean true or false.
-   *
-   * @throws CodeError if read octet equals to neither 128 nor 129.
-   */
-  decode: function(data) {
-    let value = WSP.Octet.decode(data);
-    if ((value != 128) && (value != 129)) {
-      throw new WSP.CodeError("Boolean-value: invalid value " + value);
-    }
-
-    return value == 128;
-  },
-
-  /**
-   * @param data
-   *        A wrapped object to store encoded raw data.
-   * @param value
-   *        A boolean value to be encoded.
-   */
-  encode: function(data, value) {
-    WSP.Octet.encode(data, value ? 128 : 129);
-  },
-};
-
-/**
- * MMS Address
- *
- * address = email | device-address | alphanum-shortcode | num-shortcode
- *
- * @see OMA-TS-MMS_ENC-V1_3-20110913-A section 8
- */
-this.Address = {
-  /**
-   * @param data
-   *        A wrapped object to store encoded raw data.
-   *
-   * @return An object of two string-typed attributes: address and type.
-   */
-  decode: function(data) {
-    let str = EncodedStringValue.decode(data);
-
-    let result;
-    if (((result = str.match(this.REGEXP_DECODE_PLMN)) != null)
-        || ((result = str.match(this.REGEXP_DECODE_IPV4)) != null)
-        || ((result = str.match(this.REGEXP_DECODE_IPV6)) != null)
-        || (((result = str.match(this.REGEXP_DECODE_CUSTOM)) != null)
-            && (result[2] != "PLMN")
-            && (result[2] != "IPv4")
-            && (result[2] != "IPv6"))) {
-      return {address: result[1], type: result[2]};
-    }
-
-    let type;
-    if (str.match(this.REGEXP_NUM)) {
-      type = "num";
-    } else if (str.match(this.REGEXP_ALPHANUM)) {
-      type = "alphanum";
-    } else if (str.match(this.REGEXP_EMAIL)) {
-      type = "email";
-    } else {
-      throw new WSP.CodeError("Address: invalid address");
-    }
-
-    return {address: str, type: type};
-  },
-
-  /**
-   * @param data
-   *        A wrapped object to store encoded raw data.
-   * @param value
-   *        An object of two string-typed attributes: address and type.
-   */
-  encode: function(data, value) {
-    if (!value || !value.type || !value.address) {
-      throw new WSP.CodeError("Address: invalid value");
-    }
-
-    let str;
-    switch (value.type) {
-      case "email":
-        if (value.address.match(this.REGEXP_EMAIL)) {
-          str = value.address;
-        }
-        break;
-      case "num":
-        if (value.address.match(this.REGEXP_NUM)) {
-          str = value.address;
-        }
-        break;
-      case "alphanum":
-        if (value.address.match(this.REGEXP_ALPHANUM)) {
-          str = value.address;
-        }
-        break;
-      case "IPv4":
-        if (value.address.match(this.REGEXP_ENCODE_IPV4)) {
-          str = value.address + "/TYPE=IPv4";
-        }
-        break;
-      case "IPv6":
-        if (value.address.match(this.REGEXP_ENCODE_IPV6)) {
-          str = value.address + "/TYPE=IPv6";
-        }
-        break;
-      case "PLMN":
-        if (value.address.match(this.REGEXP_ENCODE_PLMN)) {
-          str = value.address + "/TYPE=PLMN";
-        }
-        break;
-      default:
-        if (value.type.match(this.REGEXP_ENCODE_CUSTOM_TYPE)
-            && value.address.match(this.REGEXP_ENCODE_CUSTOM_ADDR)) {
-          str = value.address + "/TYPE=" + value.type;
-        }
-        break;
-    }
-
-    if (!str) {
-      throw new WSP.CodeError("Address: invalid value: " + JSON.stringify(value));
-    }
-
-    EncodedStringValue.encode(data, str);
-  },
-
-  /**
-   * @param address
-   *        Address string which want to find the type.
-   *
-   * @return Address type.
-   */
-  resolveType: function(address) {
-    if (address.match(this.REGEXP_EMAIL)) {
-      return "email";
-    }
-
-    if (address.match(this.REGEXP_ENCODE_IPV4)) {
-      return "IPv4";
-    }
-
-    if (address.match(this.REGEXP_ENCODE_IPV6)) {
-      return "IPv6";
-    }
-
-    let normalizedAddress = PhoneNumberUtils.normalize(address, false);
-    if (PhoneNumberUtils.isPlainPhoneNumber(normalizedAddress)) {
-      return "PLMN";
-    }
-
-    return "Others";
-  },
-};
-
-defineLazyRegExp(Address, "REGEXP_DECODE_PLMN",        "^(\\+?[\\d.-]+)\\/TYPE=(PLMN)$");
-defineLazyRegExp(Address, "REGEXP_DECODE_IPV4",        "^((?:(?:25[0-5]|(?:2[0-4]|1[0-9]|[1-9]){0,1}[0-9])\\.){3,3}(?:25[0-5]|(?:2[0-4]|1[0-9]|[1-9]){0,1}[0-9]))\\/TYPE=(IPv4)$");
-defineLazyRegExp(Address, "REGEXP_DECODE_IPV6",        "^(" +
-                                                       "(?:[0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|" +
-                                                       "(?:[0-9a-fA-F]{1,4}:){1,7}:|" +
-                                                       "(?:[0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|" +
-                                                       "(?:[0-9a-fA-F]{1,4}:){1,5}(?::[0-9a-fA-F]{1,4}){1,2}|" +
-                                                       "(?:[0-9a-fA-F]{1,4}:){1,4}(?::[0-9a-fA-F]{1,4}){1,3}|" +
-                                                       "(?:[0-9a-fA-F]{1,4}:){1,3}(?::[0-9a-fA-F]{1,4}){1,4}|" +
-                                                       "(?:[0-9a-fA-F]{1,4}:){1,2}(?::[0-9a-fA-F]{1,4}){1,5}|" +
-                                                       "[0-9a-fA-F]{1,4}:(?:(?::[0-9a-fA-F]{1,4}){1,6})|" +
-                                                       ":(?:(?::[0-9a-fA-F]{1,4}){1,7}|:)|" +
-                                                       "(?:[0-9a-fA-F]{1,4}:){1,4}:(?:(?:25[0-5]|(?:2[0-4]|1[0-9]|[1-9]){0,1}[0-9])\\.){3,3}(?:25[0-5]|(?:2[0-4]|1[0-9]|[1-9]){0,1}[0-9])" +
-                                                       ")\\/TYPE=(IPv6)$");
-defineLazyRegExp(Address, "REGEXP_DECODE_CUSTOM",      "^([\\w\\+\\-.%]+)\\/TYPE=(\\w+)$");
-defineLazyRegExp(Address, "REGEXP_ENCODE_PLMN",        "^\\+?[\\d.-]+$");
-defineLazyRegExp(Address, "REGEXP_ENCODE_IPV4",        "^(?:(?:25[0-5]|(?:2[0-4]|1[0-9]|[1-9]){0,1}[0-9])\\.){3,3}(?:25[0-5]|(?:2[0-4]|1[0-9]|[1-9]){0,1}[0-9])$");
-defineLazyRegExp(Address, "REGEXP_ENCODE_IPV6",        "^(?:" +
-                                                       "(?:[0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|" +
-                                                       "(?:[0-9a-fA-F]{1,4}:){1,7}:|" +
-                                                       "(?:[0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|" +
-                                                       "(?:[0-9a-fA-F]{1,4}:){1,5}(?::[0-9a-fA-F]{1,4}){1,2}|" +
-                                                       "(?:[0-9a-fA-F]{1,4}:){1,4}(?::[0-9a-fA-F]{1,4}){1,3}|" +
-                                                       "(?:[0-9a-fA-F]{1,4}:){1,3}(?::[0-9a-fA-F]{1,4}){1,4}|" +
-                                                       "(?:[0-9a-fA-F]{1,4}:){1,2}(?::[0-9a-fA-F]{1,4}){1,5}|" +
-                                                       "[0-9a-fA-F]{1,4}:(?::[0-9a-fA-F]{1,4}){1,6}|" +
-                                                       ":(?:(?::[0-9a-fA-F]{1,4}){1,7}|:)" +
-                                                       ")$");
-defineLazyRegExp(Address, "REGEXP_ENCODE_CUSTOM_TYPE", "^\\w+$");
-defineLazyRegExp(Address, "REGEXP_ENCODE_CUSTOM_ADDR", "^[\\w\\+\\-.%]+$");
-defineLazyRegExp(Address, "REGEXP_NUM",                "^[\\+*#]?\\d+$");
-defineLazyRegExp(Address, "REGEXP_ALPHANUM",           "^\\w+$");
-// OMA-TS-MMS_ENC-V1_3-20110913-A chapter 8:
-//
-//   E-mail should match the definition of `mailbox` as described in section
-//   3.4 of RFC2822, but excluding the obsolete definitions as indicated by
-//   the "obs-" prefix.
-//
-// Here we try to match addr-spec only.
-defineLazyRegExp(Address, "REGEXP_EMAIL",              "(?:" +
-                                                       "[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|" +
-                                                       "\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\"" +
-                                                       ")@(?:" +
-                                                       "[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|" +
-                                                       "\\[(?:" +
-                                                       "[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\\\[\x01-\x09\x0b\x0c\x0e-\x7f]" +
-                                                       ")*\\]" +
-                                                       ")");
-
-/**
- * Header-field = MMS-header | Application-header
- *
- * @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.2
- */
-this.HeaderField = {
-  /**
-   * @param data
-   *        A wrapped object containing raw PDU data.
-   * @param options
-   *        Extra context for decoding.
-   *
-   * @return A decoded object containing `name` and `value` properties or null
-   *         in case of a failed parsing. The `name` property must be a string,
-   *         but the `value` property can be many different types depending on
-   *         `name`.
-   */
-  decode: function(data, options) {
-    return WSP.decodeAlternatives(data, options,
-                                  MmsHeader, WSP.ApplicationHeader);
-  },
-
-  /**
-   * @param data
-   *        A wrapped object to store encoded raw data.
-   * @param octet
-   *        Octet value to be encoded.
-   * @param options
-   *        Extra context for encoding.
-   */
-  encode: function(data, value, options) {
-    WSP.encodeAlternatives(data, value, options,
-                           MmsHeader, WSP.ApplicationHeader);
-  },
-};
-
-/**
- * MMS-header = MMS-field-name MMS-value
- * MMS-field-name = Short-integer
- *
- * @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.2
- */
-this.MmsHeader = {
-  /**
-   * @param data
-   *        A wrapped object containing raw PDU data.
-   * @param options
-   *        Extra context for decoding.
-   *
-   * @return A decoded object containing `name` and `value` properties or null
-   *         in case of a failed parsing. The `name` property must be a string,
-   *         but the `value` property can be many different types depending on
-   *         `name`.
-   *
-   * @throws NotWellKnownEncodingError if decoded well-known header field
-   *         number is not registered or supported.
-   */
-  decode: function(data, options) {
-    let index = WSP.ShortInteger.decode(data);
-
-    let entry = MMS_HEADER_FIELDS[index];
-    if (!entry) {
-      throw new WSP.NotWellKnownEncodingError(
-        "MMS-header: not well known header " + index);
-    }
-
-    let cur = data.offset, value;
-    try {
-      value = entry.coder.decode(data, options);
-    } catch (e) {
-      data.offset = cur;
-
-      value = WSP.skipValue(data);
-      debug("Skip malformed well known header: "
-            + JSON.stringify({name: entry.name, value: value}));
-
-      return null;
-    }
-
-    return {
-      name: entry.name,
-      value: value,
-    };
-  },
-
-  /**
-   * @param data
-   *        A wrapped object to store encoded raw data.
-   * @param header
-   *        An object containing two attributes: a string-typed `name` and a
-   *        `value` of arbitrary type.
-   *
-   * @throws CodeError if got an empty header name.
-   * @throws NotWellKnownEncodingError if the well-known header field number is
-   *         not registered or supported.
-   */
-  encode: function(data, header) {
-    if (!header.name) {
-      throw new WSP.CodeError("MMS-header: empty header name");
-    }
-
-    let entry = MMS_HEADER_FIELDS[header.name.toLowerCase()];
-    if (!entry) {
-      throw new WSP.NotWellKnownEncodingError(
-        "MMS-header: not well known header " + header.name);
-    }
-
-    WSP.ShortInteger.encode(data, entry.number);
-    entry.coder.encode(data, header.value);
-  },
-};
-
-/**
- * Cancel-status-value = Cancel Request Successfully received |
- *                       Cancel Request corrupted
- *
- * @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.7
- */
-this.CancelStatusValue = new RangedValue("Cancel-status-value", 128, 129);
-
-/**
- * Content-class-value = text | image-basic| image-rich | video-basic |
- *                       video-rich | megapixel | content-basic | content-rich
- *
- * @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.9
- */
-this.ContentClassValue = new RangedValue("Content-class-value", 128, 135);
-
-/**
- * When used in a PDU other than M-Mbox-Delete.conf and M-Delete.conf:
- *
- *   Content-location-value = Uri-value
- *
- * When used in the M-Mbox-Delete.conf and M-Delete.conf PDU:
- *
- *   Content-location-Del-value = Value-length Status-count-value Content-location-value
- *   Status-count-value = Integer-value
- *
- * @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.10
- */
-this.ContentLocationValue = {
-  /**
-   * @param data
-   *        A wrapped object containing raw PDU data.
-   * @param options
-   *        Extra context for decoding.
-   *
-   * @return A decoded object containing `uri` and conditional `statusCount`
-   *         properties.
-   */
-  decode: function(data, options) {
-    let type = WSP.ensureHeader(options, "x-mms-message-type");
-
-    let result = {};
-    if ((type == MMS_PDU_TYPE_MBOX_DELETE_CONF)
-        || (type == MMS_PDU_TYPE_DELETE_CONF)) {
-      let length = WSP.ValueLength.decode(data);
-      let end = data.offset + length;
-
-      result.statusCount = WSP.IntegerValue.decode(data);
-      result.uri = WSP.UriValue.decode(data);
-
-      if (data.offset != end) {
-        data.offset = end;
-      }
-    } else {
-      result.uri = WSP.UriValue.decode(data);
-    }
-
-    return result;
-  },
-};
-
-/**
- * Element-Descriptor-value = Value-length Content-Reference-value *(Parameter)
- * Content-Reference-value = Text-string
- *
- * @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.18
- */
-this.ElementDescriptorValue = {
-  /**
-   * @param data
-   *        A wrapped object containing raw PDU data.
-   *
-   * @return A decoded object containing a string property `contentReference`
-   *         and an optinal `params` name-value map.
-   */
-  decode: function(data) {
-    let length = WSP.ValueLength.decode(data);
-    let end = data.offset + length;
-
-    let result = {};
-    result.contentReference = WSP.TextString.decode(data);
-    if (data.offset < end) {
-      result.params = Parameter.decodeMultiple(data, end);
-    }
-
-    if (data.offset != end) {
-      // Explicitly seek to end in case of skipped parameters.
-      data.offset = end;
-    }
-
-    return result;
-  },
-};
-
-/**
- * OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.18:
- * `For well-known parameter names binary tokens MUST be used as defined in
- * Table 27.` So we can't reuse that of WSP.
- *
- *   Parameter = Parameter-name Parameter-value
- *   Parameter-name = Short-integer | Text-string
- *   Parameter-value = Constrained-encoding | Text-string
- *
- * @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.18
- */
-this.Parameter = {
-  /**
-   * @param data
-   *        A wrapped object containing raw PDU data.
-   *
-   * @return A decoded string.
-   *
-   * @throws NotWellKnownEncodingError if decoded well-known parameter number
-   *         is not registered or supported.
-   */
-  decodeParameterName: function(data) {
-    let begin = data.offset;
-    let number;
-    try {
-      number = WSP.ShortInteger.decode(data);
-    } catch (e) {
-      data.offset = begin;
-      return WSP.TextString.decode(data).toLowerCase();
-    }
-
-    let entry = MMS_WELL_KNOWN_PARAMS[number];
-    if (!entry) {
-      throw new WSP.NotWellKnownEncodingError(
-        "Parameter-name: not well known parameter " + number);
-    }
-
-    return entry.name;
-  },
-
-  /**
-   * @param data
-   *        A wrapped object containing raw PDU data.
-   *
-   * @return A decoded object containing `name` and `value` properties or null
-   *         in case of a failed parsing. The `name` property must be a string,
-   *         but the `value` property can be many different types depending on
-   *         `name`.
-   */
-  decode: function(data) {
-    let name = this.decodeParameterName(data);
-    let value = WSP.decodeAlternatives(data, null,
-                                       WSP.ConstrainedEncoding, WSP.TextString);
-    return {
-      name: name,
-      value: value,
-    };
-  },
-
-  /**
-   * @param data
-   *        A wrapped object containing raw PDU data.
-   * @param end
-   *        Ending offset of following parameters.
-   *
-   * @return An array of decoded objects.
-   */
-  decodeMultiple: function(data, end) {
-    let params, param;
-
-    while (data.offset < end) {
-      try {
-        param = this.decode(data);
-      } catch (e) {
-        break;
-      }
-      if (param) {
-        if (!params) {
-          params = {};
-        }
-        params[param.name] = param.value;
-      }
-    }
-
-    return params;
-  },
-
-  /**
-   * @param data
-   *        A wrapped object to store encoded raw data.
-   * @param param
-   *        An object containing two attributes: `name` and `value`.
-   * @param options
-   *        Extra context for encoding.
-   */
-  encode: function(data, param, options) {
-    if (!param || !param.name) {
-      throw new WSP.CodeError("Parameter-name: empty param name");
-    }
-
-    let entry = MMS_WELL_KNOWN_PARAMS[param.name.toLowerCase()];
-    if (entry) {
-      WSP.ShortInteger.encode(data, entry.number);
-    } else {
-      WSP.TextString.encode(data, param.name);
-    }
-
-    WSP.encodeAlternatives(data, param.value, options,
-                           WSP.ConstrainedEncoding, WSP.TextString);
-  },
-};
-
-/**
- * The Char-set values are registered by IANA as MIBEnum value and SHALL be
- * encoded as Integer-value.
- *
- *   Encoded-string-value = Text-string | Value-length Char-set Text-string
- *
- * @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.19
- * @see OMA-TS-MMS_CONF-V1_3-20110913-A clause 10.2.1
- */
-this.EncodedStringValue = {
-  /**
-   * @param data
-   *        A wrapped object containing raw PDU data.
-   *
-   * @return Decoded string.
-   *
-   * @throws CodeError if the raw octets cannot be converted.
-   * @throws NotWellKnownEncodingError if decoded well-known charset number is
-   *         not registered or supported.
-   */
-  decodeCharsetEncodedString: function(data) {
-    let length = WSP.ValueLength.decode(data);
-    let end = data.offset + length;
-
-    let charset = WSP.IntegerValue.decode(data);
-    let entry = WSP.WSP_WELL_KNOWN_CHARSETS[charset];
-    if (!entry) {
-      throw new WSP.NotWellKnownEncodingError(
-        "Charset-encoded-string: not well known charset " + charset);
-    }
-
-    let str;
-    if (entry.converter) {
-      // Read a possible string quote(<Octet 127>).
-      let begin = data.offset;
-      if (WSP.Octet.decode(data) != 127) {
-        data.offset = begin;
-      }
-
-      let raw = WSP.Octet.decodeMultiple(data, end - 1);
-      // Read NUL character.
-      WSP.Octet.decodeEqualTo(data, 0);
-
-      if (!raw) {
-        str = "";
-      } else {
-        let conv = Cc["@mozilla.org/intl/scriptableunicodeconverter"]
-                   .createInstance(Ci.nsIScriptableUnicodeConverter);
-        conv.charset = entry.converter;
-        try {
-          str = conv.convertFromByteArray(raw, raw.length);
-        } catch (e) {
-          throw new WSP.CodeError("Charset-encoded-string: " + e.message);
-        }
-      }
-    } else {
-      str = WSP.TextString.decode(data);
-    }
-
-    if (data.offset != end) {
-      data.offset = end;
-    }
-
-    return str;
-  },
-
-  /**
-   * @param data
-   *        A wrapped object containing raw PDU data.
-   *
-   * @return Decoded string.
-   */
-  decode: function(data) {
-    let begin = data.offset;
-    try {
-      return WSP.TextString.decode(data);
-    } catch (e) {
-      data.offset = begin;
-      return this.decodeCharsetEncodedString(data);
-    }
-  },
-
-  /**
-   * Always encode target string with UTF-8 encoding.
-   *
-   * @param data
-   *        A wrapped object to store encoded raw data.
-   * @param str
-   *        A string.
-   */
-  encodeCharsetEncodedString: function(data, str) {
-    let conv = Cc["@mozilla.org/intl/scriptableunicodeconverter"]
-               .createInstance(Ci.nsIScriptableUnicodeConverter);
-    // `When the text string cannot be represented as us-ascii, the character
-    // set SHALL be encoded as utf-8(IANA MIBenum 106) which has unique byte
-    // ordering.` ~ OMA-TS-MMS_CONF-V1_3-20110913-A clause 10.2.1
-    conv.charset = "UTF-8";
-
-    let raw;
-    try {
-      raw = conv.convertToByteArray(str);
-    } catch (e) {
-      throw new WSP.CodeError("Charset-encoded-string: " + e.message);
-    }
-
-    let length = raw.length + 2; // Charset number and NUL character
-    // Prepend <Octet 127> if necessary.
-    if (raw[0] >= 128) {
-      ++length;
-    }
-
-    WSP.ValueLength.encode(data, length);
-
-    let entry = WSP.WSP_WELL_KNOWN_CHARSETS["utf-8"];
-    WSP.IntegerValue.encode(data, entry.number);
-
-    if (raw[0] >= 128) {
-      WSP.Octet.encode(data, 127);
-    }
-    WSP.Octet.encodeMultiple(data, raw);
-    WSP.Octet.encode(data, 0);
-  },
-
-  /**
-   * @param data
-   *        A wrapped object to store encoded raw data.
-   * @param str
-   *        A string.
-   */
-  encode: function(data, str) {
-    let begin = data.offset;
-    try {
-      // Quoted from OMA-TS-MMS-CONF-V1_3-20110913-A:
-      // Some of the MMS headers have been defined as "Encoded-string-value".
-      // The character set IANA MIBEnum value in these headers SHALL be
-      // encoded as Integer-value ([WAPWSP] section 8.4.2.3). The character
-      // set us-ascii (IANA MIBenum 3) SHALL always be accepted. If the
-      // character set is not specified (simple Text-string encoding) the
-      // character set SHALL be identified as us-ascii (lower half of ISO
-      // 8859-1 [ISO8859-1]). When the text string cannot be represented as
-      // us-ascii, the character set SHALL be encoded as utf-8 (IANA MIBenum
-      // 106) which has unique byte ordering.
-      WSP.TextString.encode(data, str, true);
-    } catch (e) {
-      data.offset = begin;
-      this.encodeCharsetEncodedString(data, str);
-    }
-  },
-};
-
-/**
- * Expiry-value = Value-length (Absolute-token Date-value | Relative-token Delta-seconds-value)
- * Absolute-token = <Octet 128>
- * Relative-token = <Octet 129>
- *
- * @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.20
- */
-this.ExpiryValue = {
-  /**
-   * @param data
-   *        A wrapped object containing raw PDU data.
-   *
-   * @return A Date object for absolute expiry or an integer for relative one.
-   *
-   * @throws CodeError if decoded token equals to neither 128 nor 129.
-   */
-  decode: function(data) {
-    let length = WSP.ValueLength.decode(data);
-    let end = data.offset + length;
-
-    let token = WSP.Octet.decode(data);
-    if ((token != 128) && (token != 129)) {
-      throw new WSP.CodeError("Expiry-value: invalid token " + token);
-    }
-
-    let result;
-    if (token == 128) {
-      result = WSP.DateValue.decode(data);
-    } else {
-      result = WSP.DeltaSecondsValue.decode(data);
-    }
-
-    if (data.offset != end) {
-      data.offset = end;
-    }
-
-    return result;
-  },
-
-  /**
-   * @param data
-   *        A wrapped object to store encoded raw data.
-   * @param value
-   *        A Date object for absolute expiry or an integer for relative one.
-   */
-  encode: function(data, value) {
-    let isDate, begin = data.offset;
-    if (value instanceof Date) {
-      isDate = true;
-      WSP.DateValue.encode(data, value);
-    } else if (typeof value == "number") {
-      isDate = false;
-      WSP.DeltaSecondsValue.encode(data, value);
-    } else {
-      throw new CodeError("Expiry-value: invalid value type");
-    }
-
-    // Calculate how much octets will be written and seek back.
-    // TODO: use memmove, see bug 730873
-    let len = data.offset - begin;
-    data.offset = begin;
-
-    WSP.ValueLength.encode(data, len + 1);
-    if (isDate) {
-      WSP.Octet.encode(data, 128);
-      WSP.DateValue.encode(data, value);
-    } else {
-      WSP.Octet.encode(data, 129);
-      WSP.DeltaSecondsValue.encode(data, value);
-    }
-  },
-};
-
-/**
- * From-value = Value-length (Address-present-token Address | Insert-address-token)
- * Address-present-token = <Octet 128>
- * Insert-address-token = <Octet 129>
- *
- * @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.21
- */
-this.FromValue = {
-  /**
-   * @param data
-   *        A wrapped object containing raw PDU data.
-   *
-   * @return A decoded Address-value or null for MMS Proxy-Relay Insert-Address
-   *         mode.
-   *
-   * @throws CodeError if decoded token equals to neither 128 nor 129.
-   */
-  decode: function(data) {
-    let length = WSP.ValueLength.decode(data);
-    let end = data.offset + length;
-
-    let token = WSP.Octet.decode(data);
-    if ((token != 128) && (token != 129)) {
-      throw new WSP.CodeError("From-value: invalid token " + token);
-    }
-
-    let result = null;
-    if (token == 128) {
-      result = Address.decode(data);
-    }
-
-    if (data.offset != end) {
-      data.offset = end;
-    }
-
-    return result;
-  },
-
-  /**
-   * @param data
-   *        A wrapped object to store encoded raw data.
-   * @param value
-   *        A Address-value or null for MMS Proxy-Relay Insert-Address mode.
-   */
-  encode: function(data, value) {
-    if (!value) {
-      WSP.ValueLength.encode(data, 1);
-      WSP.Octet.encode(data, 129);
-      return;
-    }
-
-    // Calculate how much octets will be written and seek back.
-    // TODO: use memmove, see bug 730873
-    let begin = data.offset;
-    Address.encode(data, value);
-    let len = data.offset - begin;
-    data.offset = begin;
-
-    WSP.ValueLength.encode(data, len + 1);
-    WSP.Octet.encode(data, 128);
-    Address.encode(data, value);
-  },
-};
-
-/**
- * Previously-sent-by-value = Value-length Forwarded-count-value Address
- * Forwarded-count-value = Integer-value
- *
- * @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.23
- */
-this.PreviouslySentByValue = {
-  /**
-   * @param data
-   *        A wrapped object containing raw PDU data.
-   *
-   * @return Decoded object containing an integer `forwardedCount` and an
-   *         string-typed `originator` attributes.
-   */
-  decode: function(data) {
-    let length = WSP.ValueLength.decode(data);
-    let end = data.offset + length;
-
-    let result = {};
-    result.forwardedCount = WSP.IntegerValue.decode(data);
-    result.originator = Address.decode(data);
-
-    if (data.offset != end) {
-      data.offset = end;
-    }
-
-    return result;
-  },
-};
-
-/**
- * Previously-sent-date-value = Value-length Forwarded-count-value Date-value
- *
- * @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.23
- * @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.24
- */
-this.PreviouslySentDateValue = {
-  /**
-   * @param data
-   *        A wrapped object containing raw PDU data.
-   *
-   * @return Decoded object containing an integer `forwardedCount` and an
-   *         Date-typed `timestamp` attributes.
-   */
-  decode: function(data) {
-    let length = WSP.ValueLength.decode(data);
-    let end = data.offset + length;
-
-    let result = {};
-    result.forwardedCount = WSP.IntegerValue.decode(data);
-    result.timestamp = WSP.DateValue.decode(data);
-
-    if (data.offset != end) {
-      data.offset = end;
-    }
-
-    return result;
-  },
-};
-
-/**
- * Message-class-value = Class-identifier | Token-text
- * Class-identifier = Personal | Advertisement | Informational | Auto
- * Personal = <Octet 128>
- * Advertisement = <Octet 129>
- * Informational = <Octet 130>
- * Auto = <Octet 131>
- *
- * @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.27
- */
-this.MessageClassValue = {
-  WELL_KNOWN_CLASSES: ["personal", "advertisement", "informational", "auto"],
-
-  /**
-   * @param data
-   *        A wrapped object containing raw PDU data.
-   *
-   * @return A decoded string.
-   *
-   * @throws CodeError if decoded value is not in the range 128..131.
-   */
-  decodeClassIdentifier: function(data) {
-    let value = WSP.Octet.decode(data);
-    if ((value >= 128) && (value < (128 + this.WELL_KNOWN_CLASSES.length))) {
-      return this.WELL_KNOWN_CLASSES[value - 128];
-    }
-
-    throw new WSP.CodeError("Class-identifier: invalid id " + value);
-  },
-
-  /**
-   * @param data
-   *        A wrapped object containing raw PDU data.
-   *
-   * @return A decoded string.
-   */
-  decode: function(data) {
-    let begin = data.offset;
-    try {
-      return this.decodeClassIdentifier(data);
-    } catch (e) {
-      data.offset = begin;
-      return WSP.TokenText.decode(data);
-    }
-  },
-
-  /**
-   * @param data
-   *        A wrapped object to store encoded raw data.
-   * @param klass
-   */
-  encode: function(data, klass) {
-    let index = this.WELL_KNOWN_CLASSES.indexOf(klass.toLowerCase());
-    if (index >= 0) {
-      WSP.Octet.encode(data, index + 128);
-    } else {
-      WSP.TokenText.encode(data, klass);
-    }
-  },
-};
-
- /**
- * Message-type-value = <Octet 128..151>
- *
- * @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.30
- */
-this.MessageTypeValue = new RangedValue("Message-type-value", 128, 151);
-
-/**
- * MM-flags-value = Value-length ( Add-token | Remove-token | Filter-token ) Encoded-string-value
- * Add-token = <Octet 128>
- * Remove-token = <Octet 129>
- * Filter-token = <Octet 130>
- *
- * @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.32
- */
-this.MmFlagsValue = {
-  /**
-   * @param data
-   *        A wrapped object containing raw PDU data.
-   *
-   * @return Decoded object containing an integer `type` and an string-typed
-   *         `text` attributes.
-   *
-   * @throws CodeError if decoded value is not in the range 128..130.
-   */
-  decode: function(data) {
-    let length = WSP.ValueLength.decode(data);
-    let end = data.offset + length;
-
-    let result = {};
-    result.type = WSP.Octet.decode(data);
-    if ((result.type < 128) || (result.type > 130)) {
-      throw new WSP.CodeError("MM-flags-value: invalid type " + result.type);
-    }
-    result.text = EncodedStringValue.decode(data);
-
-    if (data.offset != end) {
-      data.offset = end;
-    }
-
-    return result;
-  },
-
-  /**
-   * @param data
-   *        A wrapped object to store encoded raw data.
-   * @param value
-   *        An object containing an integer `type` and an string-typed
-   *        `text` attributes.
-   */
-  encode: function(data, value) {
-    if ((value.type < 128) || (value.type > 130)) {
-      throw new WSP.CodeError("MM-flags-value: invalid type " + value.type);
-    }
-
-    // Calculate how much octets will be written and seek back.
-    // TODO: use memmove, see bug 730873
-    let begin = data.offset;
-    EncodedStringValue.encode(data, value.text);
-    let len = data.offset - begin;
-    data.offset = begin;
-
-    WSP.ValueLength.encode(data, len + 1);
-    WSP.Octet.encode(data, value.type);
-    EncodedStringValue.encode(data, value.text);
-  },
-};
-
-/**
- * MM-state-value = Draft | Sent | New | Retrieved | Forwarded
- * Draft = <Octet 128>
- * Sent = <Octet 129>
- * New = <Octet 130>
- * Retrieved = <Octet 131>
- * Forwarded = <Octet 132>
- *
- * @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.33
- */
-this.MmStateValue = new RangedValue("MM-state-value", 128, 132);
-
-/**
- * Priority-value = Low | Normal | High
- * Low = <Octet 128>
- * Normal = <Octet 129>
- * High = <Octet 130>
- *
- * @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.35
- */
-this.PriorityValue = new RangedValue("Priority-value", 128, 130);
-
-/**
- * Read-status-value = Read | Deleted without being read
- *
- * @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.38
- */
-this.ReadStatusValue = new RangedValue("Read-status-value", 128, 129);
-
-/**
- * Recommended-Retrieval-Mode-value = Manual
- * Manual = <Octet 128>
- *
- * @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.39
- */
-this.RecommendedRetrievalModeValue = {
-  /**
-   * @param data
-   *        A wrapped object containing raw PDU data.
-   *
-   * @return A decoded integer.
-   */
-  decode: function(data) {
-    return WSP.Octet.decodeEqualTo(data, 128);
-  },
-};
-
-/**
- * Reply-charging-value = Requested | Requested text only | Accepted |
- *                        Accepted text only
- * Requested = <Octet 128>
- * Requested text only = <Octet 129>
- * Accepted = <Octet 130>
- * Accepted text only = <Octet 131>
- *
- * @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.43
- */
-this.ReplyChargingValue = new RangedValue("Reply-charging-value", 128, 131);
-
-/**
- * When used in a PDU other than M-Mbox-Delete.conf and M-Delete.conf:
- *
- *   Response-text-value = Encoded-string-value
- *
- * When used in the M-Mbox-Delete.conf and M-Delete.conf PDUs:
- *
- *   Response-text-Del-value = Value-length Status-count-value Response-text-value
- *
- * @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.49
- */
-this.ResponseText = {
-  /**
-   * @param data
-   *        A wrapped object containing raw PDU data.
-   * @param options
-   *        Extra context for decoding.
-   *
-   * @return An object containing a string-typed `text` attribute and a
-   *         integer-typed `statusCount` one.
-   */
-  decode: function(data, options) {
-    let type = WSP.ensureHeader(options, "x-mms-message-type");
-
-    let result = {};
-    if ((type == MMS_PDU_TYPE_MBOX_DELETE_CONF)
-        || (type == MMS_PDU_TYPE_DELETE_CONF)) {
-      let length = WSP.ValueLength.decode(data);
-      let end = data.offset + length;
-
-      result.statusCount = WSP.IntegerValue.decode(data);
-      result.text = EncodedStringValue.decode(data);
-
-      if (data.offset != end) {
-        data.offset = end;
-      }
-    } else {
-      result.text = EncodedStringValue.decode(data);
-    }
-
-    return result;
-  },
-};
-
-/**
- * Retrieve-status-value = Ok | Error-transient-failure |
- *                         Error-transient-message-not-found |
- *                         Error-transient-network-problem |
- *                         Error-permanent-failure |
- *                         Error-permanent-service-denied |
- *                         Error-permanent-message-not-found |
- *                         Error-permanent-content-unsupported
- * Ok = <Octet 128>
- * Error-transient-failure = <Octet 192>
- * Error-transient-message-not-found = <Octet 193>
- * Error-transient-network-problem = <Octet 194>
- * Error-permanent-failure = <Octet 224>
- * Error-permanent-service-denied = <Octet 225>
- * Error-permanent-message-not-found = <Octet 226>
- * Error-permanent-content-unsupported = <Octet 227>
- *
- * @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.50
- */
-this.RetrieveStatusValue = {
-  /**
-   * @param data
-   *        A wrapped object containing raw PDU data.
-   *
-   * @return A decoded integer.
-   */
-  decode: function(data) {
-    let value = WSP.Octet.decode(data);
-    if (value == MMS_PDU_ERROR_OK) {
-      return value;
-    }
-
-    if ((value >= MMS_PDU_ERROR_TRANSIENT_FAILURE) && (value < 256)) {
-      return value;
-    }
-
-    // Any other values SHALL NOT be used. They are reserved for future use.
-    // An MMS Client that receives such a reserved value MUST react the same
-    // as it does to the value 224 (Error-permanent-failure).
-    return MMS_PDU_ERROR_PERMANENT_FAILURE;
-  },
-};
-
-/**
- * Sender-visibility-value = Hide | Show
- *
- * @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.52
- */
-this.SenderVisibilityValue = new RangedValue("Sender-visibility-value", 128, 129);
-
-/**
- * Status-value = Expired | Retrieved | Rejected | Deferred | Unrecognised |
- *                Indeterminate | Forwarded | Unreachable
- * Expired = <Octet 128>
- * Retrieved = <Octet 129>
- * Rejected = <Octet 130>
- * Deferred = <Octet 131>
- * Unrecognised = <Octet 132>
- * Indeterminate = <Octet 133>
- * Forwarded = <Octet 134>
- * Unreachable = <Octet 135>
- *
- * @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.3.54
- */
-this.StatusValue = new RangedValue("Status-value", 128, 135);
-
-this.PduHelper = {
-  /**
-   * @param data
-   *        A wrapped object containing raw PDU data.
-   * @param headers
-   *        An optional object to store parsed header fields. Created
-   *        automatically if undefined.
-   *
-   * @return A boolean value indicating whether it's followed by message body.
-   */
-  parseHeaders: function(data, headers) {
-    if (!headers) {
-      headers = {};
-    }
-
-    let header;
-    while (data.offset < data.array.length) {
-      // There is no `header length` information in MMS PDU. If we just got
-      // something wrong in parsing header fields, we might not be able to
-      // determine the correct header-content boundary.
-      header = HeaderField.decode(data, headers);
-
-      if (header) {
-        let orig = headers[header.name];
-        if (Array.isArray(orig)) {
-          headers[header.name].push(header.value);
-        } else if (orig) {
-          headers[header.name] = [orig, header.value];
-        } else {
-          headers[header.name] = header.value;
-        }
-        if (header.name == "content-type") {
-          // `... if the PDU contains a message body the Content Type MUST be
-          // the last header field, followed by message body.` See
-          // OMA-TS-MMS_ENC-V1_3-20110913-A section 7.
-          break;
-        }
-      }
-    }
-
-    return headers;
-  },
-
-  /**
-   * @param data
-   *        A wrapped object containing raw PDU data.
-   * @param msg
-   *        A message object to store decoded multipart or octet array content.
-   */
-  parseContent: function(data, msg) {
-    let contentType = msg.headers["content-type"].media;
-    if ((contentType == "application/vnd.wap.multipart.related")
-        || (contentType == "application/vnd.wap.multipart.mixed")) {
-      msg.parts = WSP.PduHelper.parseMultiPart(data);
-      return;
-    }
-
-    if (data.offset >= data.array.length) {
-      return;
-    }
-
-    msg.content = WSP.Octet.decodeMultiple(data, data.array.length);
-    if (false) {
-      for (let begin = 0; begin < msg.content.length; begin += 20) {
-        debug("content: " + JSON.stringify(msg.content.subarray(begin, begin + 20)));
-      }
-    }
-  },
-
-  /**
-   * Check existences of all mandatory fields of a MMS message. Also sets `type`
-   * for convenient access.
-   *
-   * @param msg
-   *        A MMS message object.
-   *
-   * @return The corresponding entry in MMS_PDU_TYPES;
-   *
-   * @throws FatalCodeError if the PDU type is not supported yet.
-   */
-  checkMandatoryFields: function(msg) {
-    let type = WSP.ensureHeader(msg.headers, "x-mms-message-type");
-    let entry = MMS_PDU_TYPES[type];
-    if (!entry) {
-      throw new WSP.FatalCodeError(
-        "checkMandatoryFields: unsupported message type " + type);
-    }
-
-    entry.mandatoryFields.forEach(function(name) {
-      WSP.ensureHeader(msg.headers, name);
-    });
-
-    // Setup convenient alias that referenced frequently.
-    msg.type = type;
-
-    return entry;
-  },
-
-  /**
-   * @param data
-   *        A wrapped object containing raw PDU data.
-   * @param msg [optional]
-   *        Optional target object for decoding.
-   *
-   * @return A MMS message object or null in case of errors found.
-   */
-  parse: function(data, msg) {
-    if (!msg) {
-      msg = {};
-    }
-
-    try {
-      msg.headers = this.parseHeaders(data, msg.headers);
-
-      // Validity checks
-      let typeinfo = this.checkMandatoryFields(msg);
-      if (typeinfo.hasContent) {
-        this.parseContent(data, msg);
-      }
-    } catch (e) {
-      debug("Failed to parse MMS message, error message: " + e.message);
-      return null;
-    }
-
-    return msg;
-  },
-
-  /**
-   * @param data
-   *        A wrapped object to store encoded raw data.
-   * @param headers
-   *        A dictionary object containing multiple name/value mapping.
-   * @param name
-   *        Name of the header field to be encoded.
-   */
-  encodeHeader: function(data, headers, name) {
-    let value = headers[name];
-    if (Array.isArray(value)) {
-      for (let i = 0; i < value.length; i++) {
-        HeaderField.encode(data, {name: name, value: value[i]}, headers);
-      }
-    } else {
-      HeaderField.encode(data, {name: name, value: value}, headers);
-    }
-  },
-
-  /**
-   * @param data
-   *        A wrapped object to store encoded raw data.
-   * @param headers
-   *        A dictionary object containing multiple name/value mapping.
-   */
-  encodeHeaderIfExists: function(data, headers, name) {
-    // Header value could be zero or null.
-    if (headers[name] !== undefined) {
-      this.encodeHeader(data, headers, name);
-    }
-  },
-
-  /**
-   * @param data [optional]
-   *        A wrapped object to store encoded raw data. Created if undefined.
-   * @param headers
-   *        A dictionary object containing multiple name/value mapping.
-   *
-   * @return the passed data parameter or a created one.
-   */
-  encodeHeaders: function(data, headers) {
-    if (!data) {
-      data = {array: [], offset: 0};
-    }
-
-    // `In the encoding of the header fields, the order of the fields is not
-    // significant, except that X-Mms-Message-Type, X-Mms-Transaction-ID (when
-    // present) and X-Mms-MMS-Version MUST be at the beginning of the message
-    // headers, in that order, and if the PDU contains a message body the
-    // Content Type MUST be the last header field, followed by message body.`
-    // ~ OMA-TS-MMS_ENC-V1_3-20110913-A section 7
-    this.encodeHeader(data, headers, "x-mms-message-type");
-    this.encodeHeaderIfExists(data, headers, "x-mms-transaction-id");
-    this.encodeHeaderIfExists(data, headers, "x-mms-mms-version");
-
-    for (let key in headers) {
-      if ((key == "x-mms-message-type")
-          || (key == "x-mms-transaction-id")
-          || (key == "x-mms-mms-version")
-          || (key == "content-type")) {
-        continue;
-      }
-      this.encodeHeader(data, headers, key);
-    }
-
-    this.encodeHeaderIfExists(data, headers, "content-type");
-
-    return data;
-  },
-
-  /**
-   * @param multiStream
-   *        An exsiting nsIMultiplexInputStream.
-   * @param msg
-   *        A MMS message object.
-   *
-   * @return An instance of nsIMultiplexInputStream or null in case of errors.
-   */
-  compose: function(multiStream, msg) {
-    if (!multiStream) {
-      multiStream = Cc["@mozilla.org/io/multiplex-input-stream;1"]
-                    .createInstance(Ci.nsIMultiplexInputStream);
-    }
-
-    try {
-      // Validity checks
-      let typeinfo = this.checkMandatoryFields(msg);
-
-      let data = this.encodeHeaders(null, msg.headers);
-      debug("Composed PDU Header: " + JSON.stringify(data.array));
-      WSP.PduHelper.appendArrayToMultiStream(multiStream, data.array, data.offset);
-
-      if (msg.content) {
-        WSP.PduHelper.appendArrayToMultiStream(multiStream, msg.content, msg.content.length);
-      } else if (msg.parts) {
-        WSP.PduHelper.composeMultiPart(multiStream, msg.parts);
-      } else if (typeinfo.hasContent) {
-        throw new WSP.CodeError("Missing message content");
-      }
-
-      return multiStream;
-    } catch (e) {
-      debug("Failed to compose MMS message, error message: " + e.message);
-      return null;
-    }
-  },
-};
-
-const MMS_PDU_TYPES = (function() {
-  let pdus = {};
-  function add(number, hasContent, mandatoryFields) {
-    pdus[number] = {
-      number: number,
-      hasContent: hasContent,
-      mandatoryFields: mandatoryFields,
-    };
-  }
-
-  add(MMS_PDU_TYPE_SEND_REQ, true, ["x-mms-message-type",
-                                    "x-mms-transaction-id",
-                                    "x-mms-mms-version",
-                                    "from",
-                                    "content-type"]);
-  add(MMS_PDU_TYPE_SEND_CONF, false, ["x-mms-message-type",
-                                      "x-mms-transaction-id",
-                                      "x-mms-mms-version",
-                                      "x-mms-response-status"]);
-  add(MMS_PDU_TYPE_NOTIFICATION_IND, false, ["x-mms-message-type",
-                                             "x-mms-transaction-id",
-                                             "x-mms-mms-version",
-                                             "x-mms-message-class",
-                                             "x-mms-message-size",
-                                             "x-mms-expiry",
-                                             "x-mms-content-location"]);
-  add(MMS_PDU_TYPE_RETRIEVE_CONF, true, ["x-mms-message-type",
-                                         "x-mms-mms-version",
-                                         "date",
-                                         "content-type"]);
-  add(MMS_PDU_TYPE_NOTIFYRESP_IND, false, ["x-mms-message-type",
-                                           "x-mms-transaction-id",
-                                           "x-mms-mms-version",
-                                           "x-mms-status"]);
-  add(MMS_PDU_TYPE_DELIVERY_IND, false, ["x-mms-message-type",
-                                         "x-mms-mms-version",
-                                         "message-id",
-                                         "to",
-                                         "date",
-                                         "x-mms-status"]);
-  add(MMS_PDU_TYPE_ACKNOWLEDGE_IND, false, ["x-mms-message-type",
-                                            "x-mms-transaction-id",
-                                            "x-mms-mms-version"]);
-  add(MMS_PDU_TYPE_READ_REC_IND, false, ["x-mms-message-type",
-                                         "message-id",
-                                         "x-mms-mms-version",
-                                         "to",
-                                         "from",
-                                         "x-mms-read-status"]);
-  add(MMS_PDU_TYPE_READ_ORIG_IND, false, ["x-mms-message-type",
-                                          "x-mms-mms-version",
-                                          "message-id",
-                                          "to",
-                                          "from",
-                                          "date",
-                                          "x-mms-read-status"]);
-
-  return pdus;
-})();
-
-/**
- * Header field names and assigned numbers.
- *
- * @see OMA-TS-MMS_ENC-V1_3-20110913-A clause 7.4
- */
-const MMS_HEADER_FIELDS = (function() {
-  let names = {};
-  function add(name, number, coder) {
-    let entry = {
-      name: name,
-      number: number,
-      coder: coder,
-    };
-    names[name] = names[number] = entry;
-  }
-
-  add("bcc",                                     0x01, Address);
-  add("cc",                                      0x02, Address);
-  add("x-mms-content-location",                  0x03, ContentLocationValue);
-  add("content-type",                            0x04, WSP.ContentTypeValue);
-  add("date",                                    0x05, WSP.DateValue);
-  add("x-mms-delivery-report",                   0x06, BooleanValue);
-  add("x-mms-delivery-time",                     0x07, ExpiryValue);
-  add("x-mms-expiry",                            0x08, ExpiryValue);
-  add("from",                                    0x09, FromValue);
-  add("x-mms-message-class",                     0x0A, MessageClassValue);
-  add("message-id",                              0x0B, WSP.TextString);
-  add("x-mms-message-type",                      0x0C, MessageTypeValue);
-  add("x-mms-mms-version",                       0x0D, WSP.ShortInteger);
-  add("x-mms-message-size",                      0x0E, WSP.LongInteger);
-  add("x-mms-priority",                          0x0F, PriorityValue);
-  add("x-mms-read-report",                       0x10, BooleanValue);
-  add("x-mms-report-allowed",                    0x11, BooleanValue);
-  add("x-mms-response-status",                   0x12, RetrieveStatusValue);
-  add("x-mms-response-text",                     0x13, ResponseText);
-  add("x-mms-sender-visibility",                 0x14, SenderVisibilityValue);
-  add("x-mms-status",                            0x15, StatusValue);
-  add("subject",                                 0x16, EncodedStringValue);
-  add("to",                                      0x17, Address);
-  add("x-mms-transaction-id",                    0x18, WSP.TextString);
-  add("x-mms-retrieve-status",                   0x19, RetrieveStatusValue);
-  add("x-mms-retrieve-text",                     0x1A, EncodedStringValue);
-  add("x-mms-read-status",                       0x1B, ReadStatusValue);
-  add("x-mms-reply-charging",                    0x1C, ReplyChargingValue);
-  add("x-mms-reply-charging-deadline",           0x1D, ExpiryValue);
-  add("x-mms-reply-charging-id",                 0x1E, WSP.TextString);
-  add("x-mms-reply-charging-size",               0x1F, WSP.LongInteger);
-  add("x-mms-previously-sent-by",                0x20, PreviouslySentByValue);
-  add("x-mms-previously-sent-date",              0x21, PreviouslySentDateValue);
-  add("x-mms-store",                             0x22, BooleanValue);
-  add("x-mms-mm-state",                          0x23, MmStateValue);
-  add("x-mms-mm-flags",                          0x24, MmFlagsValue);
-  add("x-mms-store-status",                      0x25, RetrieveStatusValue);
-  add("x-mms-store-status-text",                 0x26, EncodedStringValue);
-  add("x-mms-stored",                            0x27, BooleanValue);
-  //add("x-mms-attributes", 0x28);
-  add("x-mms-totals",                            0x29, BooleanValue);
-  //add("x-mms-mbox-totals", 0x2A);
-  add("x-mms-quotas",                            0x2B, BooleanValue);
-  //add("x-mms-mbox-quotas", 0x2C);
-  add("x-mms-message-count",                     0x2D, WSP.IntegerValue);
-  //add("content", 0x2E);
-  add("x-mms-start",                             0x2F, WSP.IntegerValue);
-  //add("additional-headers", 0x30);
-  add("x-mms-distribution-indicator",            0x31, BooleanValue);
-  add("x-mms-element-descriptor",                0x32, ElementDescriptorValue);
-  add("x-mms-limit",                             0x33, WSP.IntegerValue);
-  add("x-mms-recommended-retrieval-mode",        0x34, RecommendedRetrievalModeValue);
-  add("x-mms-recommended-retrieval-mode-text",   0x35, EncodedStringValue);
-  //add("x-mms-status-text", 0x36);
-  add("x-mms-applic-id",                         0x37, WSP.TextString);
-  add("x-mms-reply-applic-id",                   0x38, WSP.TextString);
-  add("x-mms-aux-applic-id",                     0x39, WSP.TextString);
-  add("x-mms-content-class",                     0x3A, ContentClassValue);
-  add("x-mms-drm-content",                       0x3B, BooleanValue);
-  add("x-mms-adaptation-allowed",                0x3C, BooleanValue);
-  add("x-mms-replace-id",                        0x3D, WSP.TextString);
-  add("x-mms-cancel-id",                         0x3E, WSP.TextString);
-  add("x-mms-cancel-status",                     0x3F, CancelStatusValue);
-
-  return names;
-})();
-
-// @see OMA-TS-MMS_ENC-V1_3-20110913-A Table 27: Parameter Name Assignments
-const MMS_WELL_KNOWN_PARAMS = (function() {
-  let params = {};
-
-  function add(name, number, coder) {
-    let entry = {
-      name: name,
-      number: number,
-      coder: coder,
-    };
-    params[name] = params[number] = entry;
-  }
-
-  // Encoding Version: 1.2
-  add("type", 0x02, WSP.TypeValue);
-
-  return params;
-})();
-
-var debug;
-if (DEBUG) {
-  debug = function(s) {
-    dump("-$- MmsPduHelper: " + s + "\n");
-  };
-} else {
-  debug = function(s) {};
-}
-
-this.EXPORTED_SYMBOLS = ALL_CONST_SYMBOLS.concat([
-  // Constant values
-  "MMS_VERSION",
-
-  // Utility functions
-  "translatePduErrorToStatus",
-
-  // Decoders
-  "BooleanValue",
-  "Address",
-  "HeaderField",
-  "MmsHeader",
-  "CancelStatusValue",
-  "ContentClassValue",
-  "ContentLocationValue",
-  "ElementDescriptorValue",
-  "Parameter",
-  "EncodedStringValue",
-  "ExpiryValue",
-  "FromValue",
-  "PreviouslySentByValue",
-  "PreviouslySentDateValue",
-  "MessageClassValue",
-  "MessageTypeValue",
-  "MmFlagsValue",
-  "MmStateValue",
-  "PriorityValue",
-  "ReadStatusValue",
-  "RecommendedRetrievalModeValue",
-  "ReplyChargingValue",
-  "ResponseText",
-  "RetrieveStatusValue",
-  "SenderVisibilityValue",
-  "StatusValue",
-
-  // Parser
-  "PduHelper",
-]);
-
deleted file mode 100644
--- a/dom/mobilemessage/gonk/MmsService.js
+++ /dev/null
@@ -1,2736 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
- * vim: sw=2 ts=2 sts=2 et filetype=javascript
- * 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/. */
-
-"use strict";
-
-const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
-
-Cu.importGlobalProperties(['Blob', 'FileReader']);
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/PhoneNumberUtils.jsm");
-Cu.import("resource://gre/modules/Promise.jsm");
-
-const GONK_MMSSERVICE_CONTRACTID = "@mozilla.org/mms/gonkmmsservice;1";
-const GONK_MMSSERVICE_CID = Components.ID("{9b069b8c-8697-11e4-a406-474f5190272b}");
-
-var DEBUG = false;
-function debug(s) {
-  dump("-@- MmsService: " + s + "\n");
-};
-
-const kSmsSendingObserverTopic           = "sms-sending";
-const kSmsSentObserverTopic              = "sms-sent";
-const kSmsFailedObserverTopic            = "sms-failed";
-const kSmsReceivedObserverTopic          = "sms-received";
-const kSmsRetrievingObserverTopic        = "sms-retrieving";
-const kSmsDeliverySuccessObserverTopic   = "sms-delivery-success";
-const kSmsDeliveryErrorObserverTopic     = "sms-delivery-error";
-const kSmsReadSuccessObserverTopic       = "sms-read-success";
-const kSmsReadErrorObserverTopic         = "sms-read-error";
-const kSmsDeletedObserverTopic           = "sms-deleted";
-
-const NS_XPCOM_SHUTDOWN_OBSERVER_ID      = "xpcom-shutdown";
-const kNetworkConnStateChangedTopic      = "network-connection-state-changed";
-
-const kPrefMmsDebuggingEnabled           = "mms.debugging.enabled";
-
-// HTTP status codes:
-// @see http://tools.ietf.org/html/rfc2616#page-39
-const HTTP_STATUS_OK = 200;
-
-// Non-standard HTTP status for internal use.
-const _HTTP_STATUS_ACQUIRE_CONNECTION_SUCCESS  =  0;
-const _HTTP_STATUS_USER_CANCELLED              = -1;
-const _HTTP_STATUS_RADIO_DISABLED              = -2;
-const _HTTP_STATUS_NO_SIM_CARD                 = -3;
-const _HTTP_STATUS_ACQUIRE_TIMEOUT             = -4;
-const _HTTP_STATUS_FAILED_TO_ROUTE             = -5;
-
-// Non-standard MMS status for internal use.
-const _MMS_ERROR_MESSAGE_DELETED               = -1;
-const _MMS_ERROR_RADIO_DISABLED                = -2;
-const _MMS_ERROR_NO_SIM_CARD                   = -3;
-const _MMS_ERROR_SIM_CARD_CHANGED              = -4;
-const _MMS_ERROR_SHUTDOWN                      = -5;
-const _MMS_ERROR_USER_CANCELLED_NO_REASON      = -6;
-const _MMS_ERROR_SIM_NOT_MATCHED               = -7;
-const _MMS_ERROR_FAILED_TO_ROUTE               = -8;
-
-const CONFIG_SEND_REPORT_NEVER       = 0;
-const CONFIG_SEND_REPORT_DEFAULT_NO  = 1;
-const CONFIG_SEND_REPORT_DEFAULT_YES = 2;
-const CONFIG_SEND_REPORT_ALWAYS      = 3;
-
-const NS_PREFBRANCH_PREFCHANGE_TOPIC_ID = "nsPref:changed";
-
-const TIME_TO_BUFFER_MMS_REQUESTS    = 30000;
-const PREF_TIME_TO_RELEASE_MMS_CONNECTION =
-  Services.prefs.getIntPref("network.gonk.ms-release-mms-connection");
-
-const kPrefRetrievalMode       = 'dom.mms.retrieval_mode';
-const RETRIEVAL_MODE_MANUAL    = "manual";
-const RETRIEVAL_MODE_AUTOMATIC = "automatic";
-const RETRIEVAL_MODE_AUTOMATIC_HOME = "automatic-home";
-const RETRIEVAL_MODE_NEVER     = "never";
-
-//Internal const values.
-const DELIVERY_RECEIVED       = "received";
-const DELIVERY_NOT_DOWNLOADED = "not-downloaded";
-const DELIVERY_SENDING        = "sending";
-const DELIVERY_SENT           = "sent";
-const DELIVERY_ERROR          = "error";
-
-const DELIVERY_STATUS_SUCCESS        = "success";
-const DELIVERY_STATUS_PENDING        = "pending";
-const DELIVERY_STATUS_ERROR          = "error";
-const DELIVERY_STATUS_REJECTED       = "rejected";
-const DELIVERY_STATUS_MANUAL         = "manual";
-const DELIVERY_STATUS_NOT_APPLICABLE = "not-applicable";
-
-const PREF_SEND_RETRY_COUNT =
-  Services.prefs.getIntPref("dom.mms.sendRetryCount");
-
-const PREF_SEND_RETRY_INTERVAL = (function () {
-  let intervals =
-    Services.prefs.getCharPref("dom.mms.sendRetryInterval").split(",");
-  for (let i = 0; i < PREF_SEND_RETRY_COUNT; ++i) {
-    intervals[i] = parseInt(intervals[i], 10);
-    // If one of the intervals isn't valid (e.g., 0 or NaN),
-    // assign a 1-minute interval to it as a default.
-    if (!intervals[i]) {
-      intervals[i] = 60000;
-    }
-  }
-  intervals.length = PREF_SEND_RETRY_COUNT;
-  return intervals;
-})();
-
-const PREF_RETRIEVAL_RETRY_COUNT =
-  Services.prefs.getIntPref("dom.mms.retrievalRetryCount");
-
-const PREF_RETRIEVAL_RETRY_INTERVALS = (function() {
-  let intervals =
-    Services.prefs.getCharPref("dom.mms.retrievalRetryIntervals").split(",");
-  for (let i = 0; i < PREF_RETRIEVAL_RETRY_COUNT; ++i) {
-    intervals[i] = parseInt(intervals[i], 10);
-    // If one of the intervals isn't valid (e.g., 0 or NaN),
-    // assign a 10-minute interval to it as a default.
-    if (!intervals[i]) {
-      intervals[i] = 600000;
-    }
-  }
-  intervals.length = PREF_RETRIEVAL_RETRY_COUNT;
-  return intervals;
-})();
-
-const kPrefRilNumRadioInterfaces = "ril.numRadioInterfaces";
-const kPrefDefaultServiceId = "dom.mms.defaultServiceId";
-
-XPCOMUtils.defineLazyServiceGetter(this, "gpps",
-                                   "@mozilla.org/network/protocol-proxy-service;1",
-                                   "nsIProtocolProxyService");
-
-XPCOMUtils.defineLazyServiceGetter(this, "gIccService",
-                                   "@mozilla.org/icc/iccservice;1",
-                                   "nsIIccService");
-
-XPCOMUtils.defineLazyServiceGetter(this, "gUUIDGenerator",
-                                   "@mozilla.org/uuid-generator;1",
-                                   "nsIUUIDGenerator");
-
-XPCOMUtils.defineLazyServiceGetter(this, "gMobileMessageDatabaseService",
-                                   "@mozilla.org/mobilemessage/gonkmobilemessagedatabaseservice;1",
-                                   "nsIGonkMobileMessageDatabaseService");
-
-XPCOMUtils.defineLazyServiceGetter(this, "gMobileMessageService",
-                                   "@mozilla.org/mobilemessage/mobilemessageservice;1",
-                                   "nsIMobileMessageService");
-
-XPCOMUtils.defineLazyServiceGetter(this, "gSystemMessenger",
-                                   "@mozilla.org/system-message-internal;1",
-                                   "nsISystemMessagesInternal");
-
-XPCOMUtils.defineLazyServiceGetter(this, "gRil",
-                                   "@mozilla.org/ril;1",
-                                   "nsIRadioInterfaceLayer");
-
-XPCOMUtils.defineLazyServiceGetter(this, "gNetworkManager",
-                                   "@mozilla.org/network/manager;1",
-                                   "nsINetworkManager");
-
-XPCOMUtils.defineLazyServiceGetter(this, "gMobileConnectionService",
-                                   "@mozilla.org/mobileconnection/mobileconnectionservice;1",
-                                   "nsIMobileConnectionService");
-
-XPCOMUtils.defineLazyServiceGetter(this, "gNetworkService",
-                                   "@mozilla.org/network/service;1",
-                                   "nsINetworkService");
-
-XPCOMUtils.defineLazyGetter(this, "MMS", function() {
-  let MMS = {};
-  Cu.import("resource://gre/modules/MmsPduHelper.jsm", MMS);
-  return MMS;
-});
-
-// Internal Utilities
-
-/**
- * Return default service Id for MMS.
- */
-function getDefaultServiceId() {
-  let id = Services.prefs.getIntPref(kPrefDefaultServiceId);
-  let numRil = Services.prefs.getIntPref(kPrefRilNumRadioInterfaces);
-
-  if (id >= numRil || id < 0) {
-    id = 0;
-  }
-
-  return id;
-}
-
-/**
- * Return radio disabled state.
- */
-function isRadioOff(aServiceId) {
-    let connection = gMobileConnectionService.getItemByServiceId(aServiceId);
-    return connection.radioState
-      !== Ci.nsIMobileConnection.MOBILE_RADIO_STATE_ENABLED;
-}
-
-/**
- * Helper Class to control MMS Data Connection.
- */
-function MmsConnection(aServiceId) {
-  this.serviceId = aServiceId;
-  this.radioInterface = gRil.getRadioInterface(aServiceId);
-  this.pendingCallbacks = [];
-  this.hostsToRoute = [];
-  this.connectTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
-  this.disconnectTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
-};
-
-MmsConnection.prototype = {
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
-
-  /** MMS proxy settings. */
-  mmsc:     "",
-  mmsProxy: "",
-  mmsPort:  -1,
-
-  setApnSetting: function(networkInfo) {
-    this.mmsc = networkInfo.mmsc;
-    this.mmsProxy = networkInfo.mmsProxy;
-    this.mmsPort = networkInfo.mmsPort;
-  },
-
-  get proxyInfo() {
-    if (!this.mmsProxy) {
-      if (DEBUG) debug("getProxyInfo: MMS proxy is not available.");
-      return null;
-    }
-
-    let port = this.mmsPort;
-
-    if (port <= 0) {
-      port = 80;
-      if (DEBUG) debug("getProxyInfo: port is not valid. Set to defult (80).");
-    }
-
-    let proxyInfo =
-      gpps.newProxyInfo("http", this.mmsProxy, port,
-                        Ci.nsIProxyInfo.TRANSPARENT_PROXY_RESOLVES_HOST,
-                        -1, null);
-    if (DEBUG) debug("getProxyInfo: " + JSON.stringify(proxyInfo));
-
-    return proxyInfo;
-  },
-
-  connected: false,
-
-  //A queue to buffer the MMS HTTP requests when the MMS network
-  //is not yet connected. The buffered requests will be cleared
-  //if the MMS network fails to be connected within a timer.
-  pendingCallbacks: null,
-
-  /** MMS network connection reference count. */
-  refCount: 0,
-
-  // cache of hosts to be accessed when this connection is alive.
-  hostsToRoute: null,
-
-  // cache of the networkInfo acquired during this connection.
-  networkInfo: null,
-
-  connectTimer: null,
-
-  disconnectTimer: null,
-
-  /**
-   * Callback when |connectTimer| is timeout or cancelled by shutdown.
-   */
-  flushPendingCallbacks: function(status) {
-    if (DEBUG) debug("flushPendingCallbacks: " + this.pendingCallbacks.length
-                     + " pending callbacks with status: " + status);
-    while (this.pendingCallbacks.length) {
-      let callback = this.pendingCallbacks.shift();
-      let connected = (status == _HTTP_STATUS_ACQUIRE_CONNECTION_SUCCESS);
-      callback(connected, status);
-    }
-  },
-
-  /**
-   * Callback when |disconnectTimer| is timeout or cancelled by shutdown.
-   */
-  onDisconnectTimerTimeout: function() {
-    if (DEBUG) debug("onDisconnectTimerTimeout: deactivate the MMS data call.");
-
-    if (!this.connected) {
-      return;
-    }
-
-    let deactivateMmsDataCall = (aError) => {
-      if (aError) debug("Failed to removeHostRoute: " + aError);
-
-      // Clear cache.
-      this.hostsToRoute = [];
-      this.networkInfo = null;
-
-      this.radioInterface.deactivateDataCallByType(Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_MMS);
-    };
-
-    let promises =
-      this.hostsToRoute.map((aHost) => {
-        return gNetworkManager.removeHostRoute(this.networkInfo, aHost);
-      });
-
-    return Promise.all(promises)
-      .then(() => deactivateMmsDataCall(),
-            (aError) => deactivateMmsDataCall(aError));
-  },
-
-  init: function() {
-    Services.obs.addObserver(this, kNetworkConnStateChangedTopic,
-                             false);
-    Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
-  },
-
-  /**
-   * Return the roaming status of voice call.
-   *
-   * @return true if voice call is roaming.
-   */
-  isVoiceRoaming: function() {
-    let connection =
-      gMobileConnectionService.getItemByServiceId(this.serviceId);
-    let isRoaming = connection && connection.voice && connection.voice.roaming;
-    if (DEBUG) debug("isVoiceRoaming = " + isRoaming);
-    return isRoaming;
-  },
-
-  /**
-   * Get phone number from iccInfo.
-   *
-   * If the icc card is gsm card, the phone number is in msisdn.
-   * @see nsIGsmIccInfo
-   *
-   * Otherwise, the phone number is in mdn.
-   * @see nsICdmaIccInfo
-   */
-  getPhoneNumber: function() {
-    let number;
-    // Get the proper IccInfo based on the current card type.
-    try {
-      let iccInfo = null;
-      let baseIccInfo = this.getIccInfo();
-      if (baseIccInfo.iccType === 'ruim' || baseIccInfo.iccType === 'csim') {
-        iccInfo = baseIccInfo.QueryInterface(Ci.nsICdmaIccInfo);
-        number = iccInfo.mdn;
-      } else {
-        iccInfo = baseIccInfo.QueryInterface(Ci.nsIGsmIccInfo);
-        number = iccInfo.msisdn;
-      }
-    } catch (e) {
-      if (DEBUG) {
-       debug("Exception - QueryInterface failed on iccinfo for GSM/CDMA info");
-      }
-      return null;
-    }
-
-    return number;
-  },
-
-  /**
-   * A utility function to get IccInfo of the SIM card (if installed).
-   */
-  getIccInfo: function() {
-    let icc = gIccService.getIccByServiceId(this.serviceId);
-    return icc ? icc.iccInfo : null;
-  },
-
-  /**
-   * A utility function to get CardState of the SIM card (if installed).
-   */
-  getCardState: function() {
-    let icc = gIccService.getIccByServiceId(this.serviceId);
-    return icc ? icc.cardState : Ci.nsIIcc.CARD_STATE_UNKNOWN;
-  },
-
-  /**
-  * A utility function to get the ICC ID of the SIM card (if installed).
-  */
-  getIccId: function() {
-    let iccInfo = this.getIccInfo();
-
-    if (!iccInfo) {
-      return null;
-    }
-
-    return iccInfo.iccid;
-  },
-
-  /**
-   * Acquire the MMS network connection.
-   *
-   * @param callback
-   *        Callback function when either the connection setup is done,
-   *        timeout, or failed. Parameters are:
-   *        - A boolean value indicates whether the connection is ready.
-   *        - Acquire connection status: _HTTP_STATUS_ACQUIRE_*.
-   *
-   * @return true if the callback for MMS network connection is done; false
-   *         otherwise.
-   */
-  acquire: function(callback) {
-    this.refCount++;
-    this.connectTimer.cancel();
-    this.disconnectTimer.cancel();
-
-    // If the MMS network is not yet connected, buffer the
-    // MMS request and try to setup the MMS network first.
-    if (!this.connected) {
-      this.pendingCallbacks.push(callback);
-
-      let errorStatus;
-      if (isRadioOff(this.serviceId)) {
-        if (DEBUG) debug("Error! Radio is disabled when sending MMS.");
-        errorStatus = _HTTP_STATUS_RADIO_DISABLED;
-      } else if (this.getCardState() != Ci.nsIIcc.CARD_STATE_READY) {
-        if (DEBUG) debug("Error! SIM card is not ready when sending MMS.");
-        errorStatus = _HTTP_STATUS_NO_SIM_CARD;
-      }
-      if (errorStatus != null) {
-        this.flushPendingCallbacks(errorStatus);
-        return true;
-      }
-
-      // Set a timer to clear the buffered MMS requests if the
-      // MMS network fails to be connected within a time period.
-      this.connectTimer.
-        initWithCallback(() => this.flushPendingCallbacks(_HTTP_STATUS_ACQUIRE_TIMEOUT),
-                         TIME_TO_BUFFER_MMS_REQUESTS,
-                         Ci.nsITimer.TYPE_ONE_SHOT);
-
-      // Bug 1059110: Ensure all the initialization are done before setup data call.
-      if (DEBUG) debug("acquire: buffer the MMS request and setup the MMS data call.");
-      this.radioInterface.setupDataCallByType(Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_MMS);
-
-      return false;
-    }
-
-    callback(true, _HTTP_STATUS_ACQUIRE_CONNECTION_SUCCESS);
-    return true;
-  },
-
-  /**
-   * Release the MMS network connection.
-   */
-  release: function() {
-    this.refCount--;
-    if (this.refCount <= 0) {
-      this.refCount = 0;
-
-      // The waiting is too small, just skip the timer creation.
-      if (PREF_TIME_TO_RELEASE_MMS_CONNECTION < 1000) {
-        this.onDisconnectTimerTimeout();
-        return;
-      }
-
-      // Set a timer to delay the release of MMS network connection,
-      // since the MMS requests often come consecutively in a short time.
-      this.disconnectTimer.
-        initWithCallback(() => this.onDisconnectTimerTimeout(),
-                         PREF_TIME_TO_RELEASE_MMS_CONNECTION,
-                         Ci.nsITimer.TYPE_ONE_SHOT);
-    }
-  },
-
-  /**
-   * Helper to ensure the routing of each transaction.
-   *
-   * @param url
-   *        Optional url for retrieving mms.
-   *
-   * @return a Promise resolved if added or rejected, otherwise.
-   */
-  ensureRouting: function(url) {
-    let host = this.mmsProxy;
-
-    if (!this.mmsProxy) {
-      host = url;
-    }
-
-    try {
-      let uri = Services.io.newURI(host, null, null);
-      host = uri.host;
-    } catch (e) {}
-
-    return gNetworkManager.addHostRoute(this.networkInfo, host)
-      .then(() => {
-        if (this.hostsToRoute.indexOf(host) < 0) {
-          this.hostsToRoute.push(host);
-        }
-      });
-  },
-
-  shutdown: function() {
-    Services.obs.removeObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
-    Services.obs.removeObserver(this, kNetworkConnStateChangedTopic);
-
-    this.connectTimer.cancel();
-    this.flushPendingCallbacks(_HTTP_STATUS_RADIO_DISABLED);
-    this.disconnectTimer.cancel();
-    this.onDisconnectTimerTimeout();
-  },
-
-  // nsIObserver
-
-  observe: function(subject, topic, data) {
-    switch (topic) {
-      case kNetworkConnStateChangedTopic: {
-        // The network info for MMS connection must be nsIRilNetworkInfo.
-        if (!(subject instanceof Ci.nsIRilNetworkInfo)) {
-          return;
-        }
-
-        // Check if the network state change belongs to this service.
-        let networkInfo = subject.QueryInterface(Ci.nsIRilNetworkInfo);
-        if (networkInfo.serviceId != this.serviceId ||
-            networkInfo.type != Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_MMS) {
-          return;
-        }
-
-        let connected =
-          networkInfo.state == Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED;
-
-        // Return if the MMS network state doesn't change, where the network
-        // state change can come from other non-MMS networks.
-        if (connected == this.connected) {
-          return;
-        }
-
-        this.connected = connected;
-        if (!this.connected) {
-          this.hostsToRoute = [];
-          this.networkInfo = null;
-          return;
-        }
-
-        // Set up the MMS APN setting based on the connected MMS network,
-        // which is going to be used for the HTTP requests later.
-        this.setApnSetting(networkInfo);
-
-        // Cache connected network info.
-        this.networkInfo = networkInfo;
-
-        if (DEBUG) debug("Got the MMS network connected! Resend the buffered " +
-                         "MMS requests: number: " + this.pendingCallbacks.length);
-        this.connectTimer.cancel();
-        this.flushPendingCallbacks(_HTTP_STATUS_ACQUIRE_CONNECTION_SUCCESS);
-        break;
-      }
-      case NS_XPCOM_SHUTDOWN_OBSERVER_ID: {
-        this.shutdown();
-      }
-    }
-  }
-};
-
-XPCOMUtils.defineLazyGetter(this, "gMmsConnections", function() {
-  return {
-    _connections: null,
-    getConnByServiceId: function(id) {
-      if (!this._connections) {
-        this._connections = [];
-      }
-
-      let conn = this._connections[id];
-      if (conn) {
-        return conn;
-      }
-
-      conn = this._connections[id] = new MmsConnection(id);
-      conn.init();
-      return conn;
-    },
-    getConnByIccId: function(aIccId) {
-      if (!aIccId) {
-        // If the ICC ID isn't available, it means the MMS has been received
-        // during the previous version that didn't take the DSDS scenario
-        // into consideration. Tentatively, get connection from serviceId(0) by
-        // default is better than nothing. Although it might use the wrong
-        // SIM to download the desired MMS, eventually it would still fail to
-        // download due to the wrong MMSC and proxy settings.
-        return this.getConnByServiceId(0);
-      }
-
-      let numCardAbsent = 0;
-      let numRadioInterfaces = gRil.numRadioInterfaces;
-      for (let clientId = 0; clientId < numRadioInterfaces; clientId++) {
-        let mmsConnection = this.getConnByServiceId(clientId);
-        let iccId = mmsConnection.getIccId();
-        if (iccId === null) {
-          numCardAbsent++;
-          continue;
-        }
-
-        if (iccId === aIccId) {
-          return mmsConnection;
-        }
-      }
-
-      throw ((numCardAbsent === numRadioInterfaces)?
-               _MMS_ERROR_NO_SIM_CARD: _MMS_ERROR_SIM_NOT_MATCHED);
-    },
-  };
-});
-
-/**
- * Implementation of nsIProtocolProxyFilter for MMS Proxy
- */
-function MmsProxyFilter(mmsConnection, url) {
-  this.mmsConnection = mmsConnection;
-  this.uri = Services.io.newURI(url, null, null);
-}
-MmsProxyFilter.prototype = {
-
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIProtocolProxyFilter]),
-
-  // nsIProtocolProxyFilter
-
-  applyFilter: function(proxyService, uri, proxyInfo) {
-    if (!this.uri.equals(uri)) {
-      if (DEBUG) debug("applyFilter: content uri = " + JSON.stringify(this.uri) +
-                       " is not matched with uri = " + JSON.stringify(uri) + " .");
-      return proxyInfo;
-    }
-
-    // Fall-through, reutrn the MMS proxy info.
-    let mmsProxyInfo = this.mmsConnection.proxyInfo;
-
-    if (DEBUG) {
-      debug("applyFilter: MMSC/Content Location is matched with: " +
-            JSON.stringify({ uri: JSON.stringify(this.uri),
-                             mmsProxyInfo: mmsProxyInfo }));
-    }
-
-    return mmsProxyInfo ? mmsProxyInfo : proxyInfo;
-  }
-};
-
-XPCOMUtils.defineLazyGetter(this, "gMmsTransactionHelper", function() {
-  let helper = {
-    /**
-     * Send MMS request to MMSC.
-     *
-     * @param mmsConnection
-     *        The MMS connection.
-     * @param method
-     *        "GET" or "POST".
-     * @param url
-     *        Target url string or null to be replaced by mmsc url.
-     * @param istream
-     *        An nsIInputStream instance as data source to be sent or null.
-     * @param callback
-     *        A callback function that takes two arguments: one for http
-     *        status, the other for wrapped PDU data for further parsing.
-     */
-    sendRequest: function(mmsConnection, method, url, istream, callback) {
-      // TODO: bug 810226 - Support GPRS bearer for MMS transmission and reception.
-      let cancellable = {
-        callback: callback,
-
-        isDone: false,
-        isCancelled: false,
-
-        cancel: function() {
-          if (this.isDone) {
-            // It's too late to cancel.
-            return;
-          }
-
-          this.isCancelled = true;
-          if (this.isAcquiringConn) {
-            // We cannot cancel data connection setup here, so we invoke done()
-            // here and handle |cancellable.isDone| in callback function of
-            // |mmsConnection.acquire|.
-            this.done(_HTTP_STATUS_USER_CANCELLED, null);
-          } else if (this.xhr) {
-            // Client has already sent the HTTP request. Try to abort it.
-            this.xhr.abort();
-          }
-        },
-
-        done: function(httpStatus, data) {
-          this.isDone = true;
-          if (!this.callback) {
-            return;
-          }
-
-          if (this.isCancelled) {
-            this.callback(_HTTP_STATUS_USER_CANCELLED, null);
-          } else {
-            this.callback(httpStatus, data);
-          }
-        }
-      };
-
-      cancellable.isAcquiringConn =
-        !mmsConnection.acquire((connected, errorCode) => {
-
-        cancellable.isAcquiringConn = false;
-
-        if (!connected || cancellable.isCancelled) {
-          mmsConnection.release();
-
-          if (!cancellable.isDone) {
-            cancellable.done(cancellable.isCancelled ?
-                             _HTTP_STATUS_USER_CANCELLED : errorCode, null);
-          }
-          return;
-        }
-
-        // MMSC is available after an MMS connection is successfully acquired.
-        if (!url) {
-          url = mmsConnection.mmsc;
-        }
-
-        let startTransaction = netId => {
-          if (DEBUG) debug("sendRequest: register proxy filter to " + url);
-          let proxyFilter = new MmsProxyFilter(mmsConnection, url);
-          gpps.registerFilter(proxyFilter, 0);
-
-          cancellable.xhr =
-            this.sendHttpRequest(mmsConnection, method,
-                                 url, istream, proxyFilter, netId,
-                                 (aHttpStatus, aData) =>
-                                   cancellable.done(aHttpStatus, aData));
-        };
-
-        let onRejected = aReason => {
-          debug('Failed to start a transaction: ' + aReason);
-          mmsConnection.release();
-          cancellable.done(_HTTP_STATUS_FAILED_TO_ROUTE, null);
-        };
-
-        // TODO: |getNetId| will be implemented as a sync call in nsINetworkManager
-        //       once Bug 1141903 is landed.
-        mmsConnection.ensureRouting(url)
-          .then(() => gNetworkService.getNetId(mmsConnection.networkInfo.name))
-          .then((netId) => startTransaction(netId))
-          .catch((aReason) => onRejected(aReason));
-      });
-
-      return cancellable;
-    },
-
-    sendHttpRequest: function(mmsConnection, method, url, istream, proxyFilter,
-                              netId, callback) {
-      let releaseMmsConnectionAndCallback = (httpStatus, data) => {
-        gpps.unregisterFilter(proxyFilter);
-        // Always release the MMS network connection before callback.
-        mmsConnection.release();
-        callback(httpStatus, data);
-      };
-
-      try {
-        let xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]
-                  .createInstance(Ci.nsIXMLHttpRequest);
-
-        // Basic setups
-        xhr.networkInterfaceId = netId;
-        xhr.open(method, url, true);
-        xhr.responseType = "arraybuffer";
-        if (istream) {
-          xhr.setRequestHeader("Content-Type",
-                               "application/vnd.wap.mms-message");
-          xhr.setRequestHeader("Content-Length", istream.available());
-        }
-
-        // UAProf headers.
-        let uaProfUrl, uaProfTagname = "x-wap-profile";
-        try {
-          uaProfUrl = Services.prefs.getCharPref('wap.UAProf.url');
-          uaProfTagname = Services.prefs.getCharPref('wap.UAProf.tagname');
-        } catch (e) {}
-
-        if (uaProfUrl) {
-          xhr.setRequestHeader(uaProfTagname, uaProfUrl);
-        }
-
-        // Setup event listeners
-        xhr.onreadystatechange = () => {
-          if (xhr.readyState != Ci.nsIXMLHttpRequest.DONE) {
-            return;
-          }
-          let data = null;
-          switch (xhr.status) {
-            case HTTP_STATUS_OK: {
-              if (DEBUG) debug("xhr success, response headers: "
-                               + xhr.getAllResponseHeaders());
-              let array = new Uint8Array(xhr.response);
-              if (false) {
-                for (let begin = 0; begin < array.length; begin += 20) {
-                  let partial = array.subarray(begin, begin + 20);
-                  if (DEBUG) debug("res: " + JSON.stringify(partial));
-                }
-              }
-
-              data = {array: array, offset: 0};
-              break;
-            }
-
-            default: {
-              if (DEBUG) debug("xhr done, but status = " + xhr.status +
-                               ", statusText = " + xhr.statusText);
-              break;
-            }
-          }
-          releaseMmsConnectionAndCallback(xhr.status, data);
-        };
-        // Send request
-        xhr.send(istream);
-        return xhr;
-      } catch (e) {
-        if (DEBUG) debug("xhr error, can't send: " + e.message);
-        releaseMmsConnectionAndCallback(0, null);
-        return null;
-      }
-    },
-
-    /**
-     * Count number of recipients(to, cc, bcc fields).
-     *
-     * @param recipients
-     *        The recipients in MMS message object.
-     * @return the number of recipients
-     * @see OMA-TS-MMS_CONF-V1_3-20110511-C section 10.2.5
-     */
-    countRecipients: function(recipients) {
-      if (recipients && recipients.address) {
-        return 1;
-      }
-      let totalRecipients = 0;
-      if (!Array.isArray(recipients)) {
-        return 0;
-      }
-      totalRecipients += recipients.length;
-      for (let ix = 0; ix < recipients.length; ++ix) {
-        if (recipients[ix].address.length > MMS.MMS_MAX_LENGTH_RECIPIENT) {
-          throw new Error("MMS_MAX_LENGTH_RECIPIENT error");
-        }
-        if (recipients[ix].type === "email") {
-          let found = recipients[ix].address.indexOf("<");
-          let lenMailbox = recipients[ix].address.length - found;
-          if(lenMailbox > MMS.MMS_MAX_LENGTH_MAILBOX_PORTION) {
-            throw new Error("MMS_MAX_LENGTH_MAILBOX_PORTION error");
-          }
-        }
-      }
-      return totalRecipients;
-    },
-
-    /**
-     * Check maximum values of MMS parameters.
-     *
-     * @param msg
-     *        The MMS message object.
-     * @return true if the lengths are less than the maximum values of MMS
-     *         parameters.
-     * @see OMA-TS-MMS_CONF-V1_3-20110511-C section 10.2.5
-     */
-    checkMaxValuesParameters: function(msg) {
-      let subject = msg.headers["subject"];
-      if (subject && subject.length > MMS.MMS_MAX_LENGTH_SUBJECT) {
-        return false;
-      }
-
-      let totalRecipients = 0;
-      try {
-        totalRecipients += this.countRecipients(msg.headers["to"]);
-        totalRecipients += this.countRecipients(msg.headers["cc"]);
-        totalRecipients += this.countRecipients(msg.headers["bcc"]);
-      } catch (ex) {
-        if (DEBUG) debug("Exception caught : " + ex);
-        return false;
-      }
-
-      if (totalRecipients < 1 ||
-          totalRecipients > MMS.MMS_MAX_TOTAL_RECIPIENTS) {
-        return false;
-      }
-
-      if (!Array.isArray(msg.parts)) {
-        return true;
-      }
-      for (let i = 0; i < msg.parts.length; i++) {
-        if (msg.parts[i].headers["content-type"] &&
-          msg.parts[i].headers["content-type"].params) {
-          let name = msg.parts[i].headers["content-type"].params["name"];
-          if (name && name.length > MMS.MMS_MAX_LENGTH_NAME_CONTENT_TYPE) {
-            return false;
-          }
-        }
-      }
-      return true;
-    },
-
-    translateHttpStatusToMmsStatus: function(httpStatus, cancelledReason,
-                                             defaultStatus) {
-      switch(httpStatus) {
-        case _HTTP_STATUS_USER_CANCELLED:
-          return cancelledReason;
-        case _HTTP_STATUS_RADIO_DISABLED:
-          return _MMS_ERROR_RADIO_DISABLED;
-        case _HTTP_STATUS_NO_SIM_CARD:
-          return _MMS_ERROR_NO_SIM_CARD;
-        case _HTTP_STATUS_FAILED_TO_ROUTE:
-          return _MMS_ERROR_FAILED_TO_ROUTE;
-        case HTTP_STATUS_OK:
-          return MMS.MMS_PDU_ERROR_OK;
-        default:
-          return defaultStatus;
-      }
-    }
-  };
-
-  return helper;
-});
-
-/**
- * Send M-NotifyResp.ind back to MMSC.
- *
- * @param mmsConnection
- *        The MMS connection.
- * @param transactionId
- *        X-Mms-Transaction-ID of the message.
- * @param status
- *        X-Mms-Status of the response.
- * @param reportAllowed
- *        X-Mms-Report-Allowed of the response.
- *
- * @see OMA-TS-MMS_ENC-V1_3-20110913-A section 6.2
- */
-function NotifyResponseTransaction(mmsConnection, transactionId, status,
-                                   reportAllowed) {
-  this.mmsConnection = mmsConnection;
-  let headers = {};
-
-  // Mandatory fields
-  headers["x-mms-message-type"] = MMS.MMS_PDU_TYPE_NOTIFYRESP_IND;
-  headers["x-mms-transaction-id"] = transactionId;
-  headers["x-mms-mms-version"] = MMS.MMS_VERSION;
-  headers["x-mms-status"] = status;
-  // Optional fields
-  headers["x-mms-report-allowed"] = reportAllowed;
-
-  this.istream = MMS.PduHelper.compose(null, {headers: headers});
-}
-NotifyResponseTransaction.prototype = {
-  /**
-   * @param callback [optional]
-   *        A callback function that takes one argument -- the http status.
-   */
-  run: function(callback) {
-    let requestCallback;
-    if (callback) {
-      requestCallback = (httpStatus, data) => {
-        // `The MMS Client SHOULD ignore the associated HTTP POST response
-        // from the MMS Proxy-Relay.` ~ OMA-TS-MMS_CTR-V1_3-20110913-A
-        // section 8.2.2 "Notification".
-        callback(httpStatus);
-      };
-    }
-    gMmsTransactionHelper.sendRequest(this.mmsConnection,
-                                      "POST",
-                                      null,
-                                      this.istream,
-                                      requestCallback);
-  }
-};
-
-/**
- * CancellableTransaction - base class inherited by [Send|Retrieve]Transaction.
- * We can call |cancelRunning(reason)| to cancel the on-going transaction.
- * @param cancellableId
- *        An ID used to keep track of if an message is deleted from DB.
- * @param serviceId
- *        An ID used to keep track of if the primary SIM service is changed.
- */
-function CancellableTransaction(cancellableId, serviceId) {
-  this.cancellableId = cancellableId;
-  this.serviceId = serviceId;
-  this.isCancelled = false;
-}
-CancellableTransaction.prototype = {
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
-                                         Ci.nsIMobileConnectionListener]),
-
-  // The timer for retrying sending or retrieving process.
-  timer: null,
-
-  // Keep a reference to the callback when calling
-  // |[Send|Retrieve]Transaction.run(callback)|.
-  runCallback: null,
-
-  isObserversAdded: false,
-
-  cancelledReason: _MMS_ERROR_USER_CANCELLED_NO_REASON,
-
-  registerRunCallback: function(callback) {
-    if (!this.isObserversAdded) {
-      Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
-      Services.obs.addObserver(this, kSmsDeletedObserverTopic, false);
-      Services.prefs.addObserver(kPrefDefaultServiceId, this, false);
-      gMobileConnectionService
-        .getItemByServiceId(this.serviceId).registerListener(this);
-      this.isObserversAdded = true;
-    }
-
-    this.runCallback = callback;
-    this.isCancelled = false;
-  },
-
-  removeObservers: function() {
-    if (this.isObserversAdded) {
-      Services.obs.removeObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
-      Services.obs.removeObserver(this, kSmsDeletedObserverTopic);
-      Services.prefs.removeObserver(kPrefDefaultServiceId, this);
-      gMobileConnectionService
-        .getItemByServiceId(this.serviceId).unregisterListener(this);
-      this.isObserversAdded = false;
-    }
-  },
-
-  runCallbackIfValid: function(mmsStatus, msg) {
-    this.removeObservers();
-
-    if (this.runCallback) {
-      this.runCallback(mmsStatus, msg);
-      this.runCallback = null;
-    }
-  },
-
-  // Keep a reference to the cancellable when calling
-  // |gMmsTransactionHelper.sendRequest(...)|.
-  cancellable: null,
-
-  cancelRunning: function(reason) {
-    this.isCancelled = true;
-    this.cancelledReason = reason;
-
-    if (this.timer) {
-      // The sending or retrieving process is waiting for the next retry.
-      // What we only need to do is to cancel the timer.
-      this.timer.cancel();
-      this.timer = null;
-      this.runCallbackIfValid(reason, null);
-      return;
-    }
-
-    if (this.cancellable) {
-      // The sending or retrieving process is still running. We attempt to
-      // abort the HTTP request.
-      this.cancellable.cancel();
-      this.cancellable = null;
-    }
-  },
-
-  // nsIObserver
-
-  observe: function(subject, topic, data) {
-    switch (topic) {
-      case NS_XPCOM_SHUTDOWN_OBSERVER_ID: {
-        this.cancelRunning(_MMS_ERROR_SHUTDOWN);
-        break;
-      }
-      case kSmsDeletedObserverTopic: {
-        let deletedInfo = subject.QueryInterface(Ci.nsIDeletedMessageInfo);
-        if (deletedInfo && deletedInfo.deletedMessageIds &&
-            deletedInfo.deletedMessageIds.indexOf(this.cancellableId) >= 0) {
-          this.cancelRunning(_MMS_ERROR_MESSAGE_DELETED);
-        }
-        break;
-      }
-      case NS_PREFBRANCH_PREFCHANGE_TOPIC_ID: {
-        if (data === kPrefDefaultServiceId &&
-                   this.serviceId != getDefaultServiceId()) {
-          this.cancelRunning(_MMS_ERROR_SIM_CARD_CHANGED);
-        }
-        break;
-      }
-    }
-  },
-
-  // nsIMobileConnectionListener
-
-  notifyVoiceChanged: function() {},
-  notifyDataChanged: function() {},
-  notifyDataError: function(message) {},
-  notifyCFStateChanged: function(action, reason, number, timeSeconds, serviceClass) {},
-  notifyEmergencyCbModeChanged: function(active, timeoutMs) {},
-  notifyOtaStatusChanged: function(status) {},
-
-  notifyRadioStateChanged: function() {
-    if (isRadioOff(this.serviceId)) {
-      this.cancelRunning(_MMS_ERROR_RADIO_DISABLED);
-    }
-  },
-
-  notifyClirModeChanged: function(mode) {},
-  notifyLastKnownNetworkChanged: function() {},
-  notifyLastKnownHomeNetworkChanged: function() {},
-  notifyNetworkSelectionModeChanged: function() {},
-  notifyDeviceIdentitiesChanged: function() {}
-};
-
-/**
- * Class for retrieving message from MMSC, which inherits CancellableTransaction.
- *
- * @param contentLocation
- *        X-Mms-Content-Location of the message.
- */
-function RetrieveTransaction(mmsConnection, cancellableId, contentLocation) {
-  this.mmsConnection = mmsConnection;
-
-  // Call |CancellableTransaction| constructor.
-  CancellableTransaction.call(this, cancellableId, mmsConnection.serviceId);
-
-  this.contentLocation = contentLocation;
-}
-RetrieveTransaction.prototype = Object.create(CancellableTransaction.prototype, {
-  /**
-   * @param callback [optional]
-   *        A callback function that takes two arguments: one for X-Mms-Status,
-   *        the other for the parsed M-Retrieve.conf message.
-   */
-  run: {
-    value: function(callback) {
-      this.registerRunCallback(callback);
-
-      this.retryCount = 0;
-      let retryCallback = (mmsStatus, msg) => {
-        if (MMS.MMS_PDU_STATUS_DEFERRED == mmsStatus &&
-            this.retryCount < PREF_RETRIEVAL_RETRY_COUNT) {
-          let time = PREF_RETRIEVAL_RETRY_INTERVALS[this.retryCount];
-          if (DEBUG) debug("Fail to retrieve. Will retry after: " + time);
-
-          if (this.timer == null) {
-            this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
-          }
-
-          this.timer.initWithCallback(() => this.retrieve(retryCallback),
-                                      time, Ci.nsITimer.TYPE_ONE_SHOT);
-          this.retryCount++;
-          return;
-        }
-        this.runCallbackIfValid(mmsStatus, msg);
-      };
-
-      this.retrieve(retryCallback);
-    },
-    enumerable: true,
-    configurable: true,
-    writable: true
-  },
-
-  /**
-   * @param callback
-   *        A callback function that takes two arguments: one for X-Mms-Status,
-   *        the other for the parsed M-Retrieve.conf message.
-   */
-  retrieve: {
-    value: function(callback) {
-      this.timer = null;
-
-      this.cancellable =
-        gMmsTransactionHelper.sendRequest(this.mmsConnection,
-                                          "GET", this.contentLocation, null,
-                                          (httpStatus, data) => {
-        let mmsStatus = gMmsTransactionHelper
-                        .translateHttpStatusToMmsStatus(httpStatus,
-                                                        this.cancelledReason,
-                                                        MMS.MMS_PDU_STATUS_DEFERRED);
-        if (mmsStatus != MMS.MMS_PDU_ERROR_OK) {
-           callback(mmsStatus, null);
-           return;
-        }
-        if (!data) {
-          callback(MMS.MMS_PDU_STATUS_DEFERRED, null);
-          return;
-        }
-
-        let retrieved = MMS.PduHelper.parse(data, null);
-        if (!retrieved || (retrieved.type != MMS.MMS_PDU_TYPE_RETRIEVE_CONF)) {
-          callback(MMS.MMS_PDU_STATUS_UNRECOGNISED, null);
-          return;
-        }
-
-        // Fix default header field values.
-        if (retrieved.headers["x-mms-delivery-report"] == null) {
-          retrieved.headers["x-mms-delivery-report"] = false;
-        }
-
-        let retrieveStatus = retrieved.headers["x-mms-retrieve-status"];
-        if ((retrieveStatus != null) &&
-            (retrieveStatus != MMS.MMS_PDU_ERROR_OK)) {
-          callback(MMS.translatePduErrorToStatus(retrieveStatus), retrieved);
-          return;
-        }
-
-        callback(MMS.MMS_PDU_STATUS_RETRIEVED, retrieved);
-      });
-    },
-    enumerable: true,
-    configurable: true,
-    writable: true
-  }
-});
-
-/**
- * SendTransaction.
- *   Class for sending M-Send.req to MMSC, which inherits CancellableTransaction.
- *   @throws Error("Check max values parameters fail.")
- */
-function SendTransaction(mmsConnection, cancellableId, msg, requestDeliveryReport) {
-  this.mmsConnection = mmsConnection;
-
-  // Call |CancellableTransaction| constructor.
-  CancellableTransaction.call(this, cancellableId, mmsConnection.serviceId);
-
-  msg.headers["x-mms-message-type"] = MMS.MMS_PDU_TYPE_SEND_REQ;
-  if (!msg.headers["x-mms-transaction-id"]) {
-    // Create an unique transaction id
-    let tid = gUUIDGenerator.generateUUID().toString();
-    msg.headers["x-mms-transaction-id"] = tid;
-  }
-  msg.headers["x-mms-mms-version"] = MMS.MMS_VERSION;
-
-  // Insert Phone number if available.
-  // Otherwise, Let MMS Proxy Relay insert from address automatically for us.
-  let phoneNumber = mmsConnection.getPhoneNumber();
-  let from = (phoneNumber) ? { address: phoneNumber, type: "PLMN" } : null;
-  msg.headers["from"] = from;
-
-  msg.headers["date"] = new Date();
-  msg.headers["x-mms-message-class"] = "personal";
-  msg.headers["x-mms-expiry"] = 7 * 24 * 60 * 60;
-  msg.headers["x-mms-priority"] = 129;
-  msg.headers["x-mms-delivery-report"] = requestDeliveryReport;
-
-  if (!gMmsTransactionHelper.checkMaxValuesParameters(msg)) {
-    //We should notify end user that the header format is wrong.
-    if (DEBUG) debug("Check max values parameters fail.");
-    throw new Error("Check max values parameters fail.");
-  }
-
-  if (msg.parts) {
-    let contentType = {
-      params: {
-        // `The type parameter must be specified and its value is the MIME
-        // media type of the "root" body part.` ~ RFC 2387 clause 3.1
-        type: msg.parts[0].headers["content-type"].media,
-      },
-    };
-
-    // `The Content-Type in M-Send.req and M-Retrieve.conf SHALL be
-    // application/vnd.wap.multipart.mixed when there is no presentation, and
-    // application/vnd.wap.multipart.related SHALL be used when there is SMIL
-    // presentation available.` ~ OMA-TS-MMS_CONF-V1_3-20110913-A clause 10.2.1
-    if (contentType.params.type === "application/smil") {
-      contentType.media = "application/vnd.wap.multipart.related";
-
-      // `The start parameter, if given, is the content-ID of the compound
-      // object's "root".` ~ RFC 2387 clause 3.2
-      contentType.params.start = msg.parts[0].headers["content-id"];
-    } else {
-      contentType.media = "application/vnd.wap.multipart.mixed";
-    }
-
-    // Assign to Content-Type
-    msg.headers["content-type"] = contentType;
-  }
-
-  if (DEBUG) debug("msg: " + JSON.stringify(msg));
-
-  this.msg = msg;
-}
-SendTransaction.prototype = Obj